When trying to add additional routes to route table in Azure using ARM template, the existing routes are getting removed/deleted. The same behavior is observed when adding new service endpoints for a subnet, post deployment the Route table and NSG are disassociated and the existing serviceend point association is removed. Should all the resources be explicitly reference in ARM template to avoid this behavior. Is there a way this can achieve without listing/referring all the resources associated.
Below template format ----
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { }, "functions": [], "variables": { "testroutetable1": "rtable1", "testroutetable2": "rtable2", "Subnet1": "subnet1", "Subnet2": "subnet2", "testvnet": "vnet1"
},
"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": {}
}