I have Durable Function written in Python 3.10 available in Azure Repository, I want to Build and Deploy a function to Azure Function App (Linux Based).
I've tried with below pipeline configuration which deploy functions to azure function app but it gives 500 Error when we use. Although If I deploy this same code using VS Code manually, it works fine as expected.
Function App : OS: Linux Runtime Stack : Python - 3.10
Code Located in Azure Repos
Requirement : Need to Deploy Durable Function to Azure Function App using Azure Pipelines.
Image_Repository-Code Structure
Configured Pipeline Code
- task: UsePythonVersion@0
displayName: 'Use Python 3.10'
inputs:
versionSpec: 3.10
steps:
- script: |
python -m venv antenv
source antenv/bin/activate
# Upgrade pip
python -m pip install --upgrade pip
# Verify that pip is up to date
pip --version
pip install -r $(System.DefaultWorkingDirectory)/[FOLDER1_ReposReference]/requirements.txt
displayName: 'Command Line Script'
steps:
- task: ArchiveFiles@2
displayName: 'Archive $(System.DefaultWorkingDirectory)/[FOLDER1_ReposReference]'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/[FOLDER1_ReposReference]'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/durable_function.zip'
steps:
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/durable_function.zip'
steps:
- task: AzureFunctionApp@2
displayName: Deploy
inputs:
connectedServiceNameARM: 'SUBSCRIPTION_ID'
appType: functionAppLinux
appName: 'functionapp-name'
package: '$(Build.ArtifactStagingDirectory)/*.zip'
runtimeStack: 'PYTHON|3.10'```
In order to Deploy Azure Function to Azure Function App successfully from Azure Devops YAML pipeline, Refer below:-
My Azure Repository with sample Function:-
Now, Select Set up build and select the Default Template like below:-
In the Pop up window Select Your subscription and click continue > Sign in to your account and select your Linux Function app like below:-
DevOps YAML pipeline generated like below, Change Default python version to 3.10:-
Output:-
Refer my SO thread answer here for more details on deploying Function via Devops.