I was having challenge with deploying an Azure Function through Azure DevOps where the default channel was failing to capture the output of the build and deploy it to the target. I wanted to post a template for this, as there were a lot of people trying to solve the same problem, but no clear answer for this specific use case.
# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
# pip install -r requirements.txt
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
Python37:
python.version: '3.7'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
python -m pip install --upgrade pip
pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
displayName: 'Install dependencies'
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: AzureFunctionApp@1
inputs:
azureSubscription: 'Customer-Project-Production (11111111-1111-1111-1111-111111111111)'
appType: 'functionAppLinux'
appName: 'Customer-ImageData-Prod-01'
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
The main mis-match I didn’t have was the correct directory being copied and then sent to the AzureFunctionApp@1
Good luck!
Nathan Lasnoski