java 如何从Azure DevOps中正确部署Azure Functions应用程序

d7v8vwbk  于 2024-01-05  发布在  Java
关注(0)|答案(2)|浏览(251)

从控制台部署java函数应用程序可以使用以下命令:./mvnw azure-functions:deploy
但是,当尝试从Azure devops部署时,函数无法工作。函数显示在函数门户上。
每个功能的状态均为“已启用”
设置与以前相同。
所以一切似乎都很正常,但当我试图唤起一个函数时。响应是500内部服务器错误。
构建工件的yaml:YAML

  1. Copy
  2. trigger:
  3. - master
  4. pool:
  5. vmImage: ubuntu-latest
  6. steps:
  7. - task: JavaToolInstaller@0
  8. displayName: 'JavaToolInstaller Java version 17 '
  9. inputs:
  10. versionSpec: '17'
  11. jdkArchitectureOption: 'x64'
  12. jdkSourceOption: 'PreInstalled'
  13. - task: Maven@3
  14. displayName: 'Maven Build and Package'
  15. inputs:
  16. mavenPomFile: 'pom.xml'
  17. goals: 'clean package'
  18. options: '-DskipTests' # Optional, to skip tests
  19. - task: Maven@3
  20. displayName: 'Azure Functions Package'
  21. inputs:
  22. mavenPomFile: 'pom.xml'
  23. goals: 'azure-functions:package'
  24. options: ''
  25. - task: CopyFiles@2
  26. displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  27. inputs:
  28. SourceFolder: '$(system.defaultworkingdirectory)'
  29. Contents: '**/azure-functions/**'
  30. TargetFolder: '$(build.artifactstagingdirectory)'
  31. condition: succeededOrFailed()
  32. - task: ArchiveFiles@2
  33. displayName: 'Archive $(Build.ArtifactStagingDirectory)/target/azure-functions/f-app-v2'
  34. inputs:
  35. rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/target/azure-functions/f-app-v2'
  36. includeRootFolder: false
  37. - task: PublishBuildArtifacts@1
  38. displayName: 'Publish Artifact: drop'
  39. inputs:
  40. PathtoPublish: '$(build.artifactstagingdirectory)'
  41. condition: succeededOrFailed()

字符串
我尝试将一个工件从Azure devops部署到Azure函数,看起来一切正常,但调用函数会返回500内部服务器错误。

i34xakig

i34xakig1#

根据您的描述,您正在Azure DevOps Pipeline Maven任务中运行./mvnw azure-functions:deploy
根据这份文件:
该工具包包含验证、编译、测试、打包、验证、安装和部署。
您需要将命令:azure-functions:deploy放在Maven任务的options字段中。
举例来说:

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

字符串
然后,您可以使用AzureRmWebAppDeployment@4将包部署到Azure Function。
举例来说:

  1. - task: AzureRmWebAppDeployment@4
  2. displayName: 'Azure App Service Deploy: kevin1014'
  3. inputs:
  4. azureSubscription: xx
  5. appType: functionApp
  6. WebAppName: xx
  7. packageForLinux: '$(System.DefaultWorkingDirectory)/_123-Maven-CI/drop/1.zip'
  8. enableCustomDeployment: true
  9. DeploymentType: runFromZip

展开查看全部
utugiqy6

utugiqy62#

Azure函数应用程序有一个部署任务:Azure Function Deployment: ARM
你必须创建一个服务连接Connect to Microsoft Azure with an ARM service connection。然后使用它通过Azure DevOps管道进行部署:

  1. steps:
  2. - task: AzureFunctionApp@2
  3. displayName: 'Azure Function App Deploy: $(YOUR_FUNCTION_APP)'
  4. inputs:
  5. connectedServiceNameARM: 'Your_Azure_Env_Deployment'
  6. appType: functionApp
  7. appName: '$(YOUR_FUNCTION_APP)'
  8. package: '$(System.DefaultWorkingDirectory)/_YOUR_BUILD/drop/your_function_app_folder'

字符串

相关问题