如何在发布后将Azure数据工厂参数放入ARM模板参数文件(ARMTemplateParametersForFactory.json)

问题描述 投票:0回答:4

我正在尝试为Azure Data Factory创建Azure DevOps版本管道。

我遵循了微软(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文件。当我发布时,ARMTemplateParametersForFactory.json分支中的adf_publish保持完全不变。我尝试了很多配置。

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

我错过了什么基本的东西?请帮忙!

JSON如下:

{
    "Microsoft.DataFactory/factories/pipelines": {
        "*": {
            "properties": {
                "parameters": {
                        "*": "="                
                }
            }
        }
    },
    "Microsoft.DataFactory/factories/integrationRuntimes": {
        "*": "="
    },
    "Microsoft.DataFactory/factories/triggers": {},
    "Microsoft.DataFactory/factories/linkedServices": {},
    "Microsoft.DataFactory/factories/datasets": {}
}
azure azure-devops azure-pipelines azure-data-factory arm-template
4个回答
2
投票

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

data factory git settings

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

arm-template-parameters-definition.json

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

如果您真的想要参数化所有管道中的所有参数,则以下内容应该有效:

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

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

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

0
投票

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

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

然后将更新您的ARMTemplateParametersForFactory.json。


0
投票

我遇到类似的问题,ARMTemplateParametersForFactory.json文件没有更新,每当我发布和更改arm-template-parameters-definition.json

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

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

验证自定义参数.json语法的最简单方法似乎是通过导出ARM模板,就像Simon提到的那样。


0
投票

您有正确的想法,但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"
                    }
                }
            }
        ]
    }
}

这是arm-template-parameters-definition.json文件,它将该URL转换为参数。

{
   "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中查找属性 - > activities - > typeProperties - > url并对其进行参数化。

© www.soinside.com 2019 - 2024. All rights reserved.