用于多个 Azure Functions 的 Azure Devops 发布管道

Azure Devops Release pipeline(s) for multiple Azure Functions

我有一个包含 3 个项目的解决方案:2 个 Azure Functions 和一个共享库。 我在 Azure 中创建了 2 个函数应用程序。

每次解决方案发生变化时都会触发我的构建管道。

现在,尝试设置我的发布管道

我可以看到我可以选择目标应用服务,但我似乎无法找到一种方法来判断要在那里部署哪个功能。 似乎默认情况下,它同时部署了它们,部署的第一个只是被第二个覆盖。 所以我不介意做 2 个发布管道,但我如何指定:“从解决方案部署这个项目”。

编辑1: 我没有直接将 yaml 文件放在解决方案中,我只是在构建中添加了步骤:

但是在发布管道中我没有看到 zip 文件

Azure Function 内置在 zip 中,可以在构建函数时将其保存到工件中。您应该在每个功能项目中都有一个 azure-pipelines.yaml 。在那里您可以指定 artifact details,通常在恢复和构建步骤之后,并压缩构建输出:

    // restore step ...
    // build step ...
    
// now .net publishing step with zipping. You can also set this to false and use ArchiveFiles@2 step instead
    - task: DotNetCoreCLI@2
      displayName: 'MyFunction: Publish'
      inputs:
        command: publish
        arguments: '--configuration Release --output publish_output'
        projects: '$(System.DefaultWorkingDirectory)/MyFunction/MyFunction.sln'
        publishWebProjects: false
        zipAfterPublish: True

// Now publish your zip as artifact
    - task: PublishBuildArtifacts@1
      displayName: 'MyFunction: Publish Artifact MyFunction.zip'
      inputs:
        PathtoPublish: '$(System.DefaultWorkingDirectory)/.......'
        ArtifactName: 'MyFuction-Deploy'

或在编辑器中:

然后在您的发布管道中单击“包或文件夹”选项附近的 3 个点。您应该在构建子文件夹中看到一个用于链接工件的文件夹,而不是在其中包含函数应用程序 zip 的工件。

您可以在统一构建管道中为不同的功能应用程序生成多个工件,然后选择合适的工件部署到不同的发布管道中。