Azure资源管理器:循环依赖

时间:2015-12-30 11:10:06

标签: azure azure-resource-manager

有没有办法在循环中添加依赖项? 我试图通过循环添加几个允许所有规则到NSG,它失败。 我正在使用这样的模板:

    {
            "copy": { 
                    "name": "allowCopy", 
                    "count": "[length(parameters('allowedCIDRs'))]" 
                    },  
            "apiVersion": "[variables('apiVersionString')]",
            "type": "Microsoft.Network/networkSecurityGroups/securityRules",
            "name": "[concat(parameters('networkSecurityGroupName'), '/', parameters('allowedCIDRsNames')[copyIndex()])]",
            "location": "[resourceGroup().location]",
              "dependsOn": [
                "[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]"
              ],
                "properties": {                     
                    "description": "[concat('Allow everything from ', parameters('allowedCIDRsNames')[copyIndex()])]",
                    "protocol": "*",
                    "sourcePortRange": "*",
                    "destinationPortRange": "*",
                    "sourceAddressPrefix": "[parameters('allowedCIDRs')[copyIndex()]]",
                    "destinationAddressPrefix": "*",
                    "access": "Allow",
                    "priority": "[copyIndex(100)]",
                    "direction": "Inbound"
                }

    }

其中allowedCIDRs和allowedCIDRsNames是每个包含9个元素的数组。

它失败并出现以下错误:

New-AzureResourceGroupDeployment : 13:55:12 PM - Resource Microsoft.Network/networkSecurityGroups/securityRules 'NSGName/RuleName' failed with message 'Another operation on this or dependent resource is in progress. Toretrieve status of the operation use uri: '

每次都有不同的规则

1 个答案:

答案 0 :(得分:-1)

我假设您想要连接参数'allowedCIDRs'的值和复制索引值。在这种情况下,您应该使用以下语法:

“sourceAddressPrefix”:“[concat(parameters('allowedCIDRs'),copyIndex())]”

有关ARM functionsloops

的详细信息