如何通过Azure Devops部署Azure Function(Java)?

时间:2018-11-01 02:24:10

标签: azure azure-devops azure-functions azure-pipelines azure-pipelines-release-pipeline

我正在尝试配置管道以从Azure devops部署Java函数。以下是我的发布配置的屏幕截图以及部署日志的副本。该版本成功运行,但未在我的功能应用程序下创建/部署功能。任何帮助我理解此部署过程如何工作的参考资料都将不胜感激。

注意:我可以使用“部署到功能应用程序”选项直接从Visual Studio Code部署应用程序。

enter image description here

部署日志

2018-11-01T01:23:27.8081386Z ##[section]Starting: Deploy Azure App Service
2018-11-01T01:23:27.8089617Z ==============================================================================
2018-11-01T01:23:27.8089706Z Task         : Azure App Service Deploy
2018-11-01T01:23:27.8089797Z Description  : Update Azure App Services on Windows, Web App on Linux with built-in images or Docker containers, ASP.NET, .NET Core, PHP, Python or Node.js based Web applications, Function Apps on Windows or Linux with Docker Containers, Mobile Apps, API applications, Web Jobs using Web Deploy / Kudu REST APIs
2018-11-01T01:23:27.8089913Z Version      : 4.3.9
2018-11-01T01:23:27.8089958Z Author       : Microsoft Corporation
2018-11-01T01:23:27.8090030Z Help         : [More information](https://aka.ms/azurermwebdeployreadme)
2018-11-01T01:23:27.8090094Z ==============================================================================
2018-11-01T01:23:29.0637937Z Got service connection details for Azure App Service:'app-name'
2018-11-01T01:23:30.3390907Z App Service Application URL: http://app-name.azurewebsites.net
2018-11-01T01:23:30.3396999Z Successfully generated web.config file
2018-11-01T01:23:30.3851617Z Updating App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"0"}
2018-11-01T01:23:30.7694820Z Updated App Service Application settings and Kudu Application settings.
2018-11-01T01:23:31.6821221Z Package deployment using ZIP Deploy initiated.
2018-11-01T01:23:55.3835039Z Deploy logs can be viewed at https://app-name.scm.azurewebsites.net/api/deployments/00a9ea2e2c634b1f81355f26b7c0f52b/log
2018-11-01T01:23:55.3835345Z Successfully deployed web package to App Service.
2018-11-01T01:23:57.2965141Z Successfully added release annotation to the Application Insight : app-name
2018-11-01T01:23:58.4077123Z Successfully updated deployment History at https://app-name.scm.azurewebsites.net/api/deployments/12345667890
2018-11-01T01:23:59.0842425Z ##[section]Finishing: Deploy Azure App Service

2 个答案:

答案 0 :(得分:2)

要使您的Azure Functions成为Azure DevOps Pipelines版本(CD)部署中的一部分,您需要使用Azure门户设置和配置Azure Functions应用。

Azure Functions的配置中必须完成一些步骤,这些步骤很常见,无论您使用哪种语言来开发Azure Functions。

这些是任务:

  1. 确保您的功能应用满足特定的文件夹层次结构
  2. 使用Azure门户设置功能应用程序的持续部署,并确保您使用的是Azure DevOps存储库中的源。
  3. 配置部署选项,包括部署环境
  4. 配置部署凭据。使用凭据使Azure DevOps能够连接到功能应用程序部署

有关这些步骤的详细信息,请访问此MSFT文档,以在Azure Functions上启用连续部署:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-continuous-deployment

答案 1 :(得分:1)

看到您将* .jar文件发布到Function应用程序,实际上function应用程序的内容不仅仅是jar文件。在Azure DevOps上构建mvn之后,在本地检查文件夹functionappname/target/azure-functions/functionappname,应该发布相同的工件。

这是在Azure DevOps中部署Java函数的详尽tutorial

最后,构建和发布管道的几个步骤。

  1. 选择Maven任务,没什么特别的。
  2. 复制文件任务,如上所述,将 Content 设置为**/azure-functions/**
  3. 添加存档任务,将要存档的根文件夹或文件设置为$(build.artifactstagingdirectory)/target/azure-functions/<yourfunctionappname>,我们可以根据建议为functionappname添加变量。并记住取消选中“将根文件夹名称附加到存档路径”。
  4. 发布工件,将发布路径设置为$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
  5. 为了简化起见,教程直接在构建管道中添加了发布步骤,以与发布管道一起使用,添加一个默认的Azure应用服务部署任务就足够了,除了诸如应用名称之类的基本信息之外,无需进行任何设置。在4. *预览任务中,默认部署方法是Run from package,我们可以选择其他方法,如本教程所述。