【问题标题】:ARM Template copy reporting Duplicates when there are notARM 模板复制报告重复时没有
【发布时间】:2023-03-28 02:48:01
【问题描述】:

我有一个 ARM 模板,它尝试根据一组防火墙参数为 Azure Data Lake Store 设置防火墙规则。 IP 规则的参数列表是不同的,没有重复,但是当我尝试部署时模板报告重复。

知道哪里出了问题或如何进一步排除故障吗?

Azure Data Lake Store 的属性(在 ARM 模板中)

"copy": [
      {
        "name": "firewallRules",
        "count": "[length(parameters('firewallRules'))]",
        "input": {
          "name": "[parameters('firewallRules')[copyIndex('firewallRules')].name",
          "properties": {
            "startIpAddress": "[parameters('firewallRules')[copyIndex('firewallRules')].startIp]",
            "endIpAddress": "[parameters('firewallRules')[copyIndex('firewallRules')].endIp]"
          }
        }
      }
    ]

错误信息:

[错误] New-AzureRmResourceGroupDeployment:18:57:28 - 资源 Microsoft.DataLakeStore/accounts 'myadlsname' 失败并出现 [错误] 消息'{[错误]“错误”:{[错误]“代码”: "DuplicedNestedResource", [ERROR] "message": "有防火墙 Body 中具有相同名称的规则。” [ERROR] } [ERROR] }'

参数:

  "FirewallRules": {
          "value": [
            {
              "name": "Allow_1",
              "startIp": "1.1.1.1",
              "endIp": "1.1.1.1"
            },
            {
              "name": "Allow_2",
              "startIp": "2.2.2.2",
              "endIp": "2.2.2.2"
            },
            {
              "name": "Allow_3",
              "startIp": "3.3.3.3",
              "endIp": "3.3.3.3"
            }
          ]
        }

【问题讨论】:

    标签: azure azure-resource-manager arm-template


    【解决方案1】:

    我认为你搞砸了这一行中的括号:

    "name": "[parameters('firewallRules')[copyIndex('firewallRules')].name",

    应该是这样的:

    "name": "[parameters('firewallRules')[copyIndex('firewallRules')].name]",

    缺少最后一个右括号。如果括号不匹配,则不会处理完整的表达式。这将在第二个循环中产生相同的名称。

    您好, 柯克

    【讨论】:

    • 我已经知道了,但你是对的,这正是问题所在。我会将您的答案标记为正确,并希望其他人会发现它可以为他们节省几个小时的挫败感。 ??
    猜你喜欢
    • 2020-02-01
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    • 2018-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多