我正在尝试在创建路由表时将Rout表分配给子网/ Vnet。我找不到要添加到脚本中的脚本/属性。有人可以帮我这个忙。 我在创建路由表时试图将Rout表分配给子网/ Vnet。我找不到要添加到脚本中的脚本/属性。有人可以帮我吗?
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"disableBgpRoutePropagation": {
"type": "string"
},
"Spoke2AddressPrefix" :{
"type": "string"
},
"HopIpaddress" : {
"type": "string"
},
"VnetRGName" : {
"type": "string"
},
"VnetName" : {
"type": "string"
},
"SubnetName" : {
"type": "string"
}
},
"resources": [
{
"name": "[parameters('name')]",
"type": "Microsoft.Network/routeTables",
"apiVersion": "2018-08-01",
"location": "[parameters('location')]",
"dependsOn": [],
"properties": {
"disableBgpRoutePropagation": "[parameters('disableBgpRoutePropagation')]",
"routes": [
{
"name": "Spoke1-Hub",
"id" : "[concat(resourceId( parameters('VnetRGName'), 'Microsoft.Network/virtualNetworks', parameters('Vnetname')), 'Microsoft.Network/virtualNetworks/subnets', parameters('subnetname'))]",
"properties": {
"addressPrefix": "[parameters('Spoke2AddressPrefix')]",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "[parameters('HopIpaddress')]"
}
}
]
}
}
]
}
答案 0 :(得分:0)
我通常会转到https://github.com/Azure/azure-quickstart-templates,并在存储库中搜索要使用的提供程序类型的示例。我找到了Microsoft.Network/routeTables
的示例,该示例应提供您所寻求的指导。这是指向特定模板的链接:https://github.com/Azure/azure-quickstart-templates/blob/master/201-userdefined-routes-appliance/azuredeploy.json
在定义Microsoft.Network/virtualNetworks
资源和subnets
数组时,子网上有一个名为routeTable
的属性,它可以获取资源ID。
"routeTable": {
"id": "[resourceId('Microsoft.Network/routeTables', variables('routeTableName'))]"
}
带有两个特定资源的ARM模板的较长代码段:
...
{
"type": "Microsoft.Network/routeTables",
"name": "[variables('routeTableName')]",
"apiVersion": "2015-06-15",
"location": "[parameters('location')]",
"properties": {
"routes": [
{
"name": "VirtualApplianceRouteToSubnet3",
"properties": {
"addressPrefix": "[variables('subnet3Prefix')]",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "[variables('NvmPrivateIPAddress')]"
}
}
]
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('VNetName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/routeTables/', variables('routeTableName'))]",
"[concat('Microsoft.Network/networkSecurityGroups/', variables('nsgname'))]"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('VNetAddressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('Subnet1Name')]",
"properties": {
"addressPrefix": "[variables('Subnet1Prefix')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgname'))]"
},
"routeTable": {
"id": "[resourceId('Microsoft.Network/routeTables', variables('routeTableName'))]"
}
}
},
{
"name": "[variables('Subnet2Name')]",
"properties": {
"addressPrefix": "[variables('Subnet2Prefix')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgname'))]"
}
}
},
{
"name": "[variables('Subnet3Name')]",
"properties": {
"addressPrefix": "[variables('Subnet3Prefix')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgname'))]"
}
}
}
]
}
},
...
答案 1 :(得分:0)
您需要按如下所示将此配置放入Microsoft.Network/子网中:
{
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2019-09-01",
"name": "[parameters('name')",
"dependsOn": [
"[variables('routeId')]"
],
"properties": {
"routeTable": {
"id": "[variables('routeId')]"
},
routeId为:
"variables": {
"routeId": "[resourceId('Microsoft.Network/routeTables', variables('routeName'))]",
},