【问题标题】:How to get the Azure Data Factory parameters into the ARM template parameters file (ARMTemplateParametersForFactory.json) after publishing发布后如何将 Azure 数据工厂参数放入 ARM 模板参数文件 (ARMTemplateParametersForFactory.json)
【发布时间】:2019-05-08 14:55:22
【问题描述】:

我正在尝试为 Azure 数据工厂创建我的 Azure DevOps 发布管道。

我已遵循 Microsoft (https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment) 提供的关于向发布时生成的 ARM 模板添加其他参数的相当神秘的指南 (https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment#use-custom-parameters-with-the-resource-manager-template)

在 master 分支的路由中创建了一个arm-template-parameters-definition.json 文件。当我发布时,adf_publish 分支中的ARMTemplateParametersForFactory.json 保持完全不变。我尝试了很多配置。

我在数据工厂中定义了一些管道参数,并希望它们可以在我的部署管道中进行配置。对我来说似乎是一个明显的要求。

我错过了一些基本的东西吗?请帮忙!

JSON如下:

{
    "Microsoft.DataFactory/factories/pipelines": {
        "*": {
            "properties": {
                "parameters": {
                        "*": "="                
                }
            }
        }
    },
    "Microsoft.DataFactory/factories/integrationRuntimes": {
        "*": "="
    },
    "Microsoft.DataFactory/factories/triggers": {},
    "Microsoft.DataFactory/factories/linkedServices": {},
    "Microsoft.DataFactory/factories/datasets": {}
}

【问题讨论】:

  • 为什么你认为它必须改变?它不应该。它应该使用这些参数来部署你需要的任何东西。它不会在 repo 中更新该文件的内容(为什么会这样?)
  • @4c74356b41 是的,当您发布时应该这样做,但并非始终如一。我建议您阅读问题中发布的链接。

标签: azure azure-devops azure-pipelines azure-data-factory arm-template


【解决方案1】:

我已经为此苦苦挣扎了几天,并没有找到很多信息,所以这里是我发现的。您必须将arm-template-parameters-definition.json 放在协作分支的已配置根文件夹中:

所以在我的示例中,它必须如下所示:

如果您在单独的分支中工作,则可以通过从数据工厂下载 arm 模板来测试您的配置。当您更改参数定义时,您必须重新加载浏览器屏幕 (f5) 以刷新配置。

如果您真的想对所有管道中的所有参数进行参数化,以下应该可以工作:

"Microsoft.DataFactory/factories/pipelines": {
    "properties": {
        "parameters":{
            "*":{
                "defaultValue":"="
            }
        }
    }
}

我更喜欢指定要参数化的参数:

"Microsoft.DataFactory/factories/pipelines": {
    "properties": {
        "parameters":{
            "LogicApp_RemoveFileFromADLSURL":{
                "defaultValue":"=:-LogicApp_RemoveFileFromADLSURL:"
            },
            "LogicApp_RemoveBlob":{
                "defaultValue":"=:-LogicApp_RemoveBlob:"
            }
        }
    }
}

【讨论】:

  • 谢谢...我会试一试并告诉你。
  • 如果您不使用标准布局文件夹,请在下面添加一个小说明。 HTH
  • 只是一个注释,以防它帮助其他人......我不确定名称是否应该在末尾有一个冒号 - 即我认为 LogicApp_RemoveFileFromADLSURL: 应该是 LogicApp_RemoveFileFromADLSURL 冒号使我的自动化崩溃了部署脚本。
【解决方案2】:

只是为了澄清西蒙的好答案。如果您有非标准的 git 层次结构(即,您将根移动到一个子文件夹,就像我在下面使用“Source”所做的那样),当文档引用“repo root”时可能会造成混淆。希望这张图有所帮助。

【讨论】:

    【解决方案3】:

    您的想法是对的,但是 arm-template-parameters-definition.json 文件需要遵循您要参数化的元素的层次结构。

    这是我想要参数化的管道活动。 “url”应该根据它部署的环境而改变

    {
        "name": "[concat(parameters('factoryName'), '/ExecuteSPForNetPriceExpiringContractsReport')]",
        "type": "Microsoft.DataFactory/factories/pipelines",
        "apiVersion": "2018-06-01",
        "properties": {
            "description": "",
            "activities": [
                {
                    "name": "NetPriceExpiringContractsReport",
                    "description": "Passing values to the Logic App to generate the CSV file.",
                    "type": "WebActivity",
                    "typeProperties": {
                        "url": "[parameters('ExecuteSPForNetPriceExpiringContractsReport_properties_1_typeProperties')]",
                        "method": "POST",
                        "headers": {
                            "Content-Type": "application/json"
                        },
                        "body": {
                            "resultSet": "@activity('NetPriceExpiringContractsReportLookup').output"
                        }
                    }
                }
            ]
        }
    }
    

    这里是将 URL 转换为参数的 arm-template-parameters-definition.json 文件。

    {
       "Microsoft.DataFactory/factories/pipelines": {
            "properties": {
                "activities": [{
                    "typeProperties": {
                        "url": "-::string"
                    }
                }]
            }
        },
        "Microsoft.DataFactory/factories/integrationRuntimes": {},
        "Microsoft.DataFactory/factories/triggers": {},
        "Microsoft.DataFactory/factories/linkedServices": {
            "*": "="
        },
        "Microsoft.DataFactory/factories/datasets": {
            "*": "="
        }
    }
    

    所以基本上在 ARM 模板的管道中,它会在 JSON 中查找属性 -> 活动 -> typeProperties -> url 并对其进行参数化。

    【讨论】:

    • 我正在尝试返回没有参数化的 adf_publish 模板,但无论我做什么,它总是参数化我的所有linkedServices 连接字符串。你知道这是为什么吗?
    • OK 在文档中它说“默认情况下,所有安全字符串(例如 Key Vault 机密)和安全字符串(例如连接字符串、密钥和令牌)都是参数化的。”.. 这就是为什么我不能取消参数化它们。
    【解决方案4】:

    以下是消除混淆的必要步骤:

    1. 将 arm-template-parameters-definition.json 添加到您的 master 分支。
    2. 关闭并重新打开您的 Dev ADF 门户
    3. 重新发布

    然后您的 ARMTemplateParametersForFactory.json 将被更新。

    【讨论】:

      【解决方案5】:

      我遇到过类似的问题,ARMTemplateParametersForFactory.json 文件在我发布并更改了arm-template-parameters-definition.json 时没有更新。

      我想我可以通过执行以下操作来强制更新 Publish 分支:

      1. 根据需要更新自定义参数定义文件。
      2. 从 Publish 分支中删除 ARMTemplateParametersForFactory.json
      3. 刷新 (F5) 数据工厂门户。
      4. 发布。

      正如 Simon 提到的,验证自定义参数 .json 语法的最简单方法似乎是导出 ARM 模板。

      【讨论】:

        猜你喜欢
        • 2019-07-12
        • 1970-01-01
        • 1970-01-01
        • 2020-08-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多