skip to Main Content

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


  1. Based on your description, you are running the ./mvnw azure-functions:deploy in Azure DevOps Pipeline Maven task.

    According to this doc:

    The Lifecycle contains validate,compile,test, package,verify ,install, deploy.

    You need to put the command: azure-functions:deploy in the options field of the Maven task.

    For example:

    - task: Maven@3
      displayName: 'Maven pom.xml'
      inputs:
        mavenPomFile: 'pom.xml'
        options: 'azure-functions:package'
    

    Then you can use the AzureRmWebAppDeployment@4 to deploy the package to Azure Function.

    For example:

    - task: AzureRmWebAppDeployment@4
      displayName: 'Azure App Service Deploy: kevin1014'
      inputs:
        azureSubscription: xx
        appType: functionApp
        WebAppName: xx
        packageForLinux: '$(System.DefaultWorkingDirectory)/_123-Maven-CI/drop/1.zip'
        enableCustomDeployment: true
        DeploymentType: runFromZip
    
    Login or Signup to reply.
  2. 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:

    steps:
    - task: AzureFunctionApp@2
      displayName: 'Azure Function App Deploy: $(YOUR_FUNCTION_APP)'
      inputs:
        connectedServiceNameARM: 'Your_Azure_Env_Deployment'
        appType: functionApp
        appName: '$(YOUR_FUNCTION_APP)'
        package: '$(System.DefaultWorkingDirectory)/_YOUR_BUILD/drop/your_function_app_folder'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search