繁体   English   中英

使用 Azure DevOps CI/CD 管道自动部署 ADF 管道

[英]Automated Deployment of ADF Pipelines using Azure DevOps CI/CD Pipelines

https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment (即)部署管道的帮助下,我使用 Azure DevOps CI/CD 管道自动化了 Azure ADF 管道部署过程从 DEV 到 PROD 环境 ADF。 我正在使用 ADF 的 ARM 模板将管道从一个环境部署到另一个环境。 因此,我将有一个单独的 ARM_Parameter.json 对应于每个环境(开发/生产)。 问题是每个 ADF 管道可能有很少的基本参数,这些基本参数没有被参数化,因此它在 parameter.json 中不可用。 在这个使用 CI/CD 管道的自动化 ADF 管道部署过程中,你们能帮我以自动化的方式在每个 ADF 管道下的基本参数部分用 PROD 值替换开发值吗?

我看到两个选项:

  1. 如果仅针对此 RUN_ENVIRONMENT 参数,则可以将参数更改为变量并使用系统变量 @pipeline().DataFactory 来确定您正在运行的环境。
  2. 另外,您可以配置数据工厂为您的管道参数默认值生成 ARM 参数,但您必须创建自定义 arm-template-parameters-definition.json 文件。 检查文档here

您可以将自定义参数与 ARM 模板一起使用 Pipeline 的自定义参数可能如下所示:

"Microsoft.DataFactory/factories/pipelines": {
    "properties": {
        "parameters": {
                "RUN_ENVIRONMENT": "=:-:string"
        }
    }
},

将开发值替换为基本参数部分中的 PROD 值

根据您的截图, RUN_ENVIRONMENT是管道的参数,这意味着在转换为 ARM 模板时,其格式如下:

 "resources": [
    {
      ....
      ....
      "properties": {
        "parameters": {
          "RUN_ENVIRONMENT": {
            "type": "string",
            "defaultValue": "pro"
          }
        },...      
      },...
    }
  ]

它不能被 ARM 部署任务中使用Override template parameters替换。 因为会提示The template parameters 'environment' in the parameters file are not valid; they are not present in the original template and can therefore not be provided at deployment time. The template parameters 'environment' in the parameters file are not valid; they are not present in the original template and can therefore not be provided at deployment time.


要解决此错误,只需安装一个扩展并将Replace token任务添加到 ARM 部署任务之前的管道中。 此任务将在构建运行时替换 content 的值:

在此处输入图片说明

有关如何在我们的管道中应用此任务,您可以参考我的answer1answer2

还有另一种从 master(协作)分支发布 ADF 的方法。 您可以为 JSON 文件(ADF 对象)中的每个节点(属性)定义(替换)值。 它将解决您的问题,因为您可以为每个环境(阶段)提供一个单独的 CSV 配置文件。

CSV 配置文件示例 ( config-stage-UAT.csv ):

type,name,path,value
pipeline,PL_CopyMovies,activities[0].outputs[0].parameters.BlobContainer,UAT

然后只需在 PowerShell 中运行这样的 cmdlet:

Publish-AdfV2FromJson -RootFolder "$RootFolder" -ResourceGroupName "$ResourceGroupName" -DataFactoryName "$DataFactoryName" -Location "$Location" -Stage "stage-UAT"

看看这个: azure.datafactory.tools (PowerShell 模块)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM