尝试使用ARM模板将其他路由添加到Azure中的路由表时,现有路由被移除/删除。为子网添加新服务终结点时,会观察到相同的行为。部署后,路由表和NSG将取消关联,并且现有服务端点关联将被删除。是否应在ARM模板中显式引用所有资源以避免此行为。有没有办法做到这一点,而不必列出/引用所有相关的资源。
以下模板格式----
{“$模式”:“https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#“,“内容版本”:“1.0.0.0“,“参数”:{ },“功能”:[],“变量”:{“测试路由表1”:“路由表1”、“测试路由表2”:“rtable 2”、“子网1”:“子网1”、“子网2”:“子网2”、“测试虚拟网络”:“虚拟网络1”
},
"resources": [
{
"name": "[concat(variables('testvnet'),'/',variables('Subnet1'))]",
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2018-10-01",
"location": "East US",
"properties": {
"addressPrefix": "10.0.0.0/24",
"routeTable": {
"id": "[resourceId('Microsoft.Network/routeTables',variables('testroutetable1'))]"
}
}
},
{
"name": "[variables('testroutetable1')]",
"type": "Microsoft.Network/routeTables",
"location": "West Europe",
"apiVersion": "2019-11-01",
"properties": {
"routes": [
{
"name": "rtable1-to-xxx01",
"properties": {
"addressPrefix": "xxxxx",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "xxxxx"
}
},
{
"name": "rtable1-to-xxx02",
"properties": {
"addressPrefix": "xxxxx",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "xxxx"
}
}
]
}
},
{
"name": "[concat(variables('testvnet'),'/',variables('Subnet2'))]",
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2018-10-01",
"location": "West Europe",
"properties": {
"addressPrefix": "10.0.2.0/24",
"routeTable": {
"id": "[resourceId('Microsoft.Network/routeTables',variables('testroutetable2'))]"
}
}
},
{
"name": "[variables('testroutetable2')]",
"type": "Microsoft.Network/routeTables",
"location": "east us",
"apiVersion": "2019-11-01",
"properties": {
"routes": [
{
"name": "rtable2-to-yyy01",
"properties": {
"addressPrefix": "xxxxxx",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "xxxxx"
}
},
{
"name": "rtable2-to-yyy02",
"properties": {
"addressPrefix": "xxxxx",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "xxxxxx"
}
}
]
}
}
],
"outputs": {}
}
3条答案
按热度按时间sycxhyv71#
如果对象的属性为数组类型,则必须提供其所有目标值。这适用于NSG上的安全性规则、路由表上的路由等。
x4shl7ld2#
对于虚拟网络中的某些资源,如果您将其声明为虚拟网络的子资源或独立资源,则在部署ARM模板时,将删除所有现有资源,然后重新创建资源。
但是ARM template for virtual networks也支持将这些资源部署为属性,使用此方法部署时,不会在每次部署时删除任何现有资源。
不幸的是,这是一个长期存在的问题,没有迹象表明在不久的将来会得到解决。
js81xvg63#
您可以在现有路由表中添加/删除路由,而不必参考其他路由。只需将路由表名称添加到路由路径中,如下例所示: