1
votes

I would like to create pipeline which deploy Java Azure Function. The pipeline Job says successful (1 artifact produced.100% tests passed. 13 files uploaded) but I cannot see Functions deployed in Azure Portal.

Please advice me. I'm following tutorial as base, but I'm using Git Repo of Azure DevOps instead of GitHub. https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/java-function?view=azure-devops

My Visual Code project (unzipped) is located on git /MyProject/FunctionsJava/ Pom.xml is located (unzipped) /MyProject/FunctionsJava/pom.xml

My yml is followings:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

# at the top of your YAML file 
# set some variables that you'll need when you deploy
variables:
# the name of the service connection that you created above
  serviceConnectionToAzure: connection-to-TestRG-rg
  # the name of your web app here is the same one you used above
  # when you created the web app using the Azure CLI
  appName: JavaFuncApp

# ...


steps:

   # ...
   # add these as the last steps
   # to deploy to your app service
   - task: CopyFiles@2
   displayName: Copy Files
   inputs:
    SourceFolder: $(system.defaultworkingdirectory)/MyProject/FunctionsJava/
    Contents: '**'
    TargetFolder: $(build.artifactstagingdirectory)   

- task: Maven@3
  inputs:
   mavenPomFile: '$(System.DefaultWorkingDirectory)/MyProject/FunctionsJava/pom.xml'
    mavenOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    goals: 'package'

  - task: PublishBuildArtifacts@1
  displayName: Publish Artifact
  inputs:
   PathtoPublish: $(build.artifactstagingdirectory)    


- task: AzureWebApp@1
  inputs:
    azureSubscription: 'TestRG-Conn'
    appType: 'webApp'
    appName: '$(appName)'
    package:  $(build.artifactstagingdirectory)
    deploymentMethod: 'auto'
1

1 Answers

1
votes

The problem should be caused by appType: 'webApp' in the AzureWebApp task, appType should be functionApp. Web app is deployed to app service.

You can try Azure Function App deploy task or Azure App Service deploy task.

- task: AzureFunctionApp@1
  displayName: Azure Function App deploy
  inputs:
    azureSubscription: $(serviceConnectionToAzure)
    appType: functionApp
    appName: $(appName)
    package: $(build.artifactstagingdirectory)