首页 > 解决方案 > 用于多个 Azure Functions 的 Devops 管道

问题描述

我有一个包含 2 个 Azure Functions 的解决方案。在我的构建管道中,我创建了 2 个不同的 zip 并且对我来说“似乎”很好。然后我在我的发布管道中使用这些 zip,一切似乎都很好(没有错误),但是当我进入 azure 门户时,我看不到任何可用的功能。虽然 App Insights 只给了我这个:加载函数元数据;已加载 0 个函数。有什么问题?

build pipeline:
name: Azure Pipelines
steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    projects: '**/*.csproj'

- task: DotNetCoreCLI@2
  displayName: 'Func1 Publish Zip'
  inputs:
    command: publish
    publishWebProjects: false
    projects:  '$(System.DefaultWorkingDirectory)/SolutionName/Function1/Function1.csproj'
arguments: '--output publish_output\Function1 --configuration Release'
modifyOutputPath: false

- task: PublishPipelineArtifact@1
  displayName: 'Func1 Publish Artifact'
  inputs:
    targetPath: 'publish_output\Function1\'
    artifact: Func1Artifact

- task: DotNetCoreCLI@2
  displayName: 'Func2 Publish Zip'
  inputs:
    command: publish
    publishWebProjects: false
    projects: '$(System.DefaultWorkingDirectory)/SolutionName/Function2/Function2.csproj'
arguments: '--output publish_output\Function2 --configuration Release'
modifyOutputPath: false

- task: PublishPipelineArtifact@1
  displayName: 'Func2 Publish Artifact'
  inputs:
    targetPath: 'publish_output\Func2\'
    artifact: Func2Artifact

1的发布管道:

steps:
- task: AzureFunctionApp@1
  displayName: 'Deploy Function 1'
  inputs:
    azureSubscription: '$(Parameters.AzureSubscription)'
    appType: '$(Parameters.AppType)'
    appName: '$(Parameters.AppName)'
    package: '$(System.DefaultWorkingDirectory)/xxx Build/Func1Artifact'

这是这篇文章的延续: Azure Devops Release pipeline(s) for multiple Azure Functions

编辑:

log for deploy function:
2021-06-29T08:53:49.6084003Z ##[section]Starting: Deploy Func1 Function
2021-06-29T08:53:49.6208602Z
====
2021-06-29T08:53:49.6209159Z Task         : Azure Functions
2021-06-29T08:53:49.6209483Z Description  : Update a function app with 
.NET, Python, JavaScript, PowerShell, Java based web applications
2021-06-29T08:53:49.6209969Z Version      : 1.187.0
2021-06-29T08:53:49.6210422Z Author       : Microsoft Corporation
2021-06-29T08:53:49.6211044Z Help         : 
https://aka.ms/azurefunctiontroubleshooting
2021-06-29T08:53:49.6211592Z
====
2021-06-29T08:53:50.6211817Z Got service connection details for Azure 
App Service:'func1-dev'
2021-06-29T08:53:52.6469625Z Deleting App Service Application settings. 
Data: ["WEBSITE_RUN_FROM_ZIP","WEBSITE_RUN_FROM_PACKAGE"]
2021-06-29T08:54:17.4575237Z Updated App Service Application settings 
and Kudu Application settings.
2021-06-29T08:54:17.5343524Z Package deployment using ZIP Deploy 
initiated.
2021-06-29T08:54:38.8090909Z Deploy logs can be viewed at https://func1- 
dev.scm.azurewebsites.net/api/deployments/xxxx/log
2021-06-29T08:54:38.8091932Z Successfully deployed web package to App 
Service.
2021-06-29T08:55:00.5393032Z Successfully added release annotation to 
the Application Insight : func1-dev
2021-06-29T08:55:10.1885833Z Successfully updated deployment History at 
https://func1-dev.scm.azurewebsites.net/api/deployments/xxx
2021-06-29T08:55:22.5301509Z App Service Application URL: http://func1- 
dev.azurewebsites.net
2021-06-29T08:56:06.1898662Z ##[section]Finishing: Deploy Func1 Function

标签: .net-coreazure-devopsazure-functionsazure-application-insights

解决方案


推荐阅读