【问题标题】:Azurepipeline runtime paramter for the ARM template Json fileARM 模板 Json 文件的 Azure Pipeline 运行时参数
【发布时间】:2021-12-21 18:00:46
【问题描述】:

是否有任何选项可以让 Azurepipeline 运行时参数传递 ARM 模板对象属性。例如,我需要使用 Azurepipeline 动态地将 ARM 模板“维度”值传递给 ARM 模板。因此,由于它是运行时参数,因此用户可以根据自己的要求相应地添加尺寸。

下面是我要传递给天蓝色运行时参数的参数“维度”,在后端这应该在 ARM 模板中工作

                        "dimensions": [
                            {
                                "name": "DatabaseName",
                                "operator": "Include",
                                "values": [
                                    "mydb"
                                ]
                            },
                            {
                                "name": "StatusCode",
                                "operator": "Include",
                                "values": [
                                    "429"
                                ]
                            }
                        ],

下面是我试图传递上述参数值的 ARM 模板部分

            "evaluationFrequency": "[parameters('evaluationFrequency')]",
            "windowSize": "[parameters('windowSize')]",                
            "criteria": {
                "allOf": [
                    {
                        "threshold": "[parameters('threshold')]",
                        "name": "Metric1",
                        "metricNamespace": "[parameters('metricNamespace')]",
                        "metricName": "[parameters('metricName')]",
                        "dimensions": "[parameters('dimensions')]",
                        "operator": "[parameters('operator')]",
                        "timeAggregation": "[parameters('timeAggregation')]",
                        "criterionType": "[parameters('criterionType')]"
                    }
                ],
                "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"

【问题讨论】:

    标签: azure-devops azure-resource-manager arm-template azure-pipelines-yaml


    【解决方案1】:

    我检查了许多来自 Microsoft 的文档,但没有找到将 Azure Pipeline 运行时参数传递给 ARM 模板对象属性的任何方法。

    如果您想将 Azure 资源管理器模板(ARM 模板)与 Azure Pipelines 集成以实现持续集成和持续部署,请使用 ARM template deployment task将 azure 管道变量传递给 ARM 模板

    创建一个变量组来存储您可能希望传递到 YAML 管道或跨多个管道使用的值和机密,然后尝试使用任务的 overrideParameters 参数来覆盖 ARM 模板的变量组中定义的变量的参数,如下所示。

    - task: AzureResourceManagerTemplateDeployment@3
       displayName: 'ARM Template deployment: Resource Group scope'
       inputs:
         azureResourceManagerConnection: <connection>
         ...
         overrideParameters: -storageAcctName azurerg -Username $(vmusername)
         ...
         ...
    

    我建议阅读来自 Microsoft 的 Integrate ARM templates with Azure Pipelines 文档以获取更多信息。

    【讨论】:

    • 是的.. 那里有 OverrideParamaters 选项。但我不确定如何在我的场景中将维度值的这个列表(对象)类型传递给 arm 模板。已经尝试了多种方法,结果出现json验证错误,
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-02
    • 2022-06-29
    • 1970-01-01
    • 1970-01-01
    • 2021-05-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多