ARM 模板复制报告 Duplicates when there are not

ARM Template copy reporting Duplicates when there are not

我有一个 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]"
          }
        }
      }
    ]

错误信息:

[ERROR] New-AzureRmResourceGroupDeployment : 18:57:28 - Resource Microsoft.DataLakeStore/accounts 'myadlsname' failed with [ERROR] message '{ [ERROR] "error": { [ERROR] "code": "DuplicatedNestedResource", [ERROR] "message": "There're firewall rules with the same name in 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"
            }
          ]
        }

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

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

它应该看起来像:

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

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

您好, 柯克