用于多个 Azure Functions 的 Azure Devops 发布管道 [英] Azure Devops Release pipeline(s) for multiple Azure Functions

查看:31
本文介绍了用于多个 Azure Functions 的 Azure Devops 发布管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

我可以看到我可以选择目标应用服务,但我似乎无法确定在那里部署哪个函数.似乎默认情况下,它部署了它们,并且部署的第一个只是被第二个覆盖.所以我不介意做 2 个发布管道,但我如何指定:从解决方案部署这个项目".

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

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

解决方案

Azure Function 内置于 zip 文件中,可以在函数构建过程中将其保存到工件中.您应该在每个功能项目中都有一个 azure-pipelines.yaml.在那里你可以指定

在您的发布管道中,单击包或文件夹"附近的 3 个点;选项.您应该在构建子文件夹中看到链接工件的文件夹,而不是包含函数应用 zip 的工件.

您可以在统一构建管道中为不同的函数应用生成多个工件,然后选择合适的工件部署在不同的发布管道中.

I have a solution containing 3 projects: 2 Azure Functions and a shared library. I have created 2 Function Apps in Azure.

My Build Pipeline is triggered every time something changes in the solution.

Now, trying to set my release pipeline

I can see I can choose the target App Service, but I can't seem to find a way to tell which function to deploy there. It seems by default, it deploys both of them, and the first one deployed is just overwritten by the second one. So I don't mind doing 2 release pipelines, but how do I specify : "deploy this proj from the solution".

EDIT1: I didnt put the yaml files directly in the solution, I just added the steps in the build :

But in the release pipeline I dont see the zip file

解决方案

Azure Function is built into a zip, which can be saved into an artifact during function building. You should have an azure-pipelines.yaml in each fuction project. There you can specify the artifact details, normally after restore and build steps, and zipping the build output:

    // 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'

Or in editor:

Than in your release pipeline click on the 3 dots near the "Package or folder" option. You should see a folder for linked artifacts, inside your build subfolder and than the artifact with your function app zip inside.

You can produce several artifacts for different function apps in your unified build pipeline, and than choose appropriate artifact to deploy in your different release pipelines.

这篇关于用于多个 Azure Functions 的 Azure Devops 发布管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆