Your YAML deployment file seems mostly correct, but the issue could be related to one of the following common causes:
- You’re using
az functionapp deployment source config-zip
withaz CLI
, but the package path might not be correct. - Make sure that your Function App is properly created in Azure as a Function App and not a regular Web App
- If deploying to Linux, you need
appType: functionAppLinux
.
Updated YAML for Azure Function Deployment
- This corrects potential issues and improves reliability.
trigger:
- AEDev
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
azureServiceConnectionId: '3712d8e6-d1ae-4179-a46e-148801b1f253'
resourceGroupName: 'jltechdev-rg'
functionAppName: 'jltech-dev-aeserviceP01'
stages:
- stage: Build
displayName: "Build and Package"
jobs:
- job: Build
displayName: "Build Job"
pool:
vmImage: 'windows-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '8.x'
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
feedsToUse: 'config'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/t:Publish /p:Configuration=Release /p:PublishDir=$(build.artifactstagingdirectory)\publish_output'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
displayName: 'Build and Publish the project'
- task: ArchiveFiles@2
displayName: "Archive files"
inputs:
rootFolderOrFile: '$(build.artifactstagingdirectory)\publish_output'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(build.artifactstagingdirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: 'drop'
- stage: Deploy
displayName: "Deploy to Azure Function"
jobs:
- job: Deploy
displayName: "Deploy Job"
pool:
vmImage: 'ubuntu-latest'
steps:
- download: current
artifact: drop
- task: AzureFunctionApp@2
displayName: "Deploy to Azure Function App"
inputs:
azureSubscription: $(azureServiceConnectionId)
appType: functionApp
appName: $(functionAppName)
package: $(Pipeline.Workspace)/drop/*.zip
deploymentMethod: 'auto'
Hope this helps!
If you found this answer helpful, please click Accept Answer and consider upvoting it /click yes.
If you have any further questions, please click Comment.