我正在尝试创建一个 arm 模板,该模板在现有 Vnet 上创建一个额外的子网,同时还创建 NSG,然后将其附加到子网。我已经到了创建 NSG 的地步,但是当我尝试将 NSG 连接到多个子网时,它无法创建子网和 NSG。下面的错误
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subnetname1": {
"type": "string",
"defaultValue":"front-end"
},
"subnetprefix1": {
"type": "string",
"defaultValue": "10.12.4.0/24"
},
"nsgsubnet1": {
"type": "string",
"defaultValue": "nsg-frontend"
},
"subnetname2": {
"type": "string",
"defaultValue": "back-end"
},
"subnetprefix2": {
"type": "string",
"defaultValue": "10.12.5.0/24"
},
"nsgsubnet2": {
"type": "string",
"defaultValue": "nsg-backend"
},
"subnetname3": {
"type": "string",
"defaultValue": "database"
},
"subnetprefix3": {
"type": "string",
"defaultValue": "10.12.6.0/24"
},
"nsgsubnet3": {
"type": "string",
"defaultValue": "nsg-database"
}
},
"variables": {
"vnetName":"vn-uks-Production"
},
"resources": [
{
"apiVersion": "2019-02-01",
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[parameters('nsgsubnet1')]",
"location": "[resourceGroup().location]",
"properties": {
}
},
{
"apiVersion": "2019-02-01",
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[parameters('nsgsubnet2')]",
"location": "[resourceGroup().location]",
"properties": {
}
},
{
"apiVersion": "2019-02-01",
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[parameters('nsgsubnet3')]",
"location": "[resourceGroup().location]",
"properties": {
}
},
{
"name": "vn-uks-production",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-11-01",
"location": "[resourceGroup().location]",
"dependsOn": [
"[parameters('nsgsubnet1')]"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.12.0.0/19"
]
}
},
"resources": [
{
"apiVersion": "2018-10-01",
"type": "subnets",
"name": "[parameters('subnetname1')]",
"dependsOn": [
"[variables('vnetName')]"
],
"properties": {
"mode": "Incremental",
"addressPrefix": "[parameters('subnetprefix1')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('nsgsubnet1'))]"
}
}
},
{
"apiVersion": "2018-10-01",
"type": "subnets",
"name": "[parameters('subnetname2')]",
"dependsOn": [
"[variables('vnetName')]"
],
"properties": {
"addressPrefix": "[parameters('subnetprefix2')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('nsgsubnet2'))]"
}
}
}
]
}
]
}
我得到的错误是
{
"status": "Failed",
"error": {
"code": "InvalidRequestFormat",
"message": "Cannot parse the request.",
"details": [
{
"code": "InvalidJson",
"message": "Could not find member 'mode' on object of type 'SubnetProperties'. Path 'properties.mode', line 1, position 22."
}
]
}
}