• 主页
  • 使用ARM模板有条件地部署包含子网的路由表

使用ARM模板有条件地部署包含子网的路由表

在使用ARM模板部署子网资源时,我尝试有条件地部署路由模板,但无法使用if条件执行此操作。有人知道正确的语法吗?或者我做错了什么?

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "routeTableConfigurationObject": {
        "type": "object",
        "defaultValue": null
    },
    "vnetConfigurationObject": {
        "type": "object"
    },
    "Tags": {
        "type": "object"
    }
},
"resources": [
    {
        "type": "Microsoft.Network/virtualNetworks/Subnets",
        "name": "[concat(parameters('vnetConfigurationObject').name,'/',parameters('vnetConfigurationObject').subnets[copyIndex()].name)]",
        "location": "[parameters('vnetConfigurationObject').location]",
        "apiVersion": "2018-08-01",
        "copy": {
            "name": "vnet",
            "count": "[length(parameters('vnetConfigurationObject').subnets)]",
            "mode": "serial"
        },
        "properties": {
            "addressPrefix": "[parameters('vnetConfigurationObject').subnets[copyIndex()].addressPrefix]",
            "routeTable": "[if(empty('routeTableConfigurationObject'), json('null'), json(concat('{\"id\": \"', '/subscriptions/', parameters('routeTableConfigurationObject').subscriptionId, '/resourceGroups/', parameters('routeTableConfigurationObject').resourceGroupName, '/providers/Microsoft.Network/routeTables/', parameters('vnetConfigurationObject').subnets[copyIndex()].routeTable,'\"}')))]"
        }
    }
]

}

转载请注明出处:http://www.jubohx.com/article/20230510/1328231.html