Azure 资源管理器 : loop dependency

标签 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: '

每次都遵循不同的规则

最佳答案

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

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

有关 ARM 的更多信息 functionsloops

关于Azure 资源管理器 : loop dependency,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34528350/

相关文章:

azure-resource-manager - 在 2019 年 12 月 1 日之前迁移到 Azure SQL 数据库的 Azure 资源管理器 REST API

azure - 如何使用 ARM 在自动化帐户中推送带有密码的 pfx 证书

azure - 使用 Azure PowerShell 同时停止多个 Azure VM

azure - azure资源管理器模板的资源部分(资源数组)中的 "apiVersion"属性有什么用?

azure - 从异步的 azure 函数返回什么

sql-server - 是否可以将 SQL Server Standard 2014 备份还原到 Azure SQL?

azure - 应用程序 channel 和机器人 channel 有什么区别?

c# - 无法将 MVC 项目发布到 Azure

azure - 如何在 Azure 上的南巴西创建 VM?

Azure APIM重写url以没有后缀url