Deploying a java functions app from the console works fine with the command:
./mvnw azure-functions:deploy
But while trying to deploy from Azure devops, the functions wont work.
The functions appear on the Functions portal.
The status for every function is "Enabled"
The settings are the same as before.
So everything seems in order, but when I try to evoke a functions. the response is 500 internal server error.
the yaml to buld the artifact:
YAML
Copy
trigger:
- master
pool:
vmImage: ubuntu-latest
steps:
- task: JavaToolInstaller@0
displayName: 'JavaToolInstaller Java version 17 '
inputs:
versionSpec: '17'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- task: Maven@3
displayName: 'Maven Build and Package'
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean package'
options: '-DskipTests' # Optional, to skip tests
- task: Maven@3
displayName: 'Azure Functions Package'
inputs:
mavenPomFile: 'pom.xml'
goals: 'azure-functions:package'
options: ''
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(system.defaultworkingdirectory)'
Contents: '**/azure-functions/**'
TargetFolder: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
- task: ArchiveFiles@2
displayName: 'Archive $(Build.ArtifactStagingDirectory)/target/azure-functions/f-app-v2'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/target/azure-functions/f-app-v2'
includeRootFolder: false
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
I tried to deploy an artifact from Azure devops to Azure functions,
It seems like everything is working, but invoking a functions returns 500 internal server error.
2
Answers
Based on your description, you are running the
./mvnw azure-functions:deploy
in Azure DevOps Pipeline Maven task.According to this doc:
You need to put the command: azure-functions:deploy in the options field of the Maven task.
For example:
Then you can use the AzureRmWebAppDeployment@4 to deploy the package to Azure Function.
For example:
There is a deployment task for azure function apps: Azure Function Deployment: ARM
You have to create a service connection Connect to Microsoft Azure with an ARM service connection. Then use it to deploy through Azure DevOps pipeline: