NSG and Route Table ARM Templates

%3CLINGO-SUB%20id%3D%22lingo-sub-1970051%22%20slang%3D%22en-US%22%3ENSG%20and%20Route%20Table%20ARM%20Templates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1970051%22%20slang%3D%22en-US%22%3E%3CP%3EHI%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20script%20which%20creates%20Both%20NSG%20and%20Route%20Tables(With%20Routes)%20in%20single%20Paramater%20and%20Tenplate%20file.%3C%2FP%3E%3CP%3EBut%20in%20this%20script%20it%20is%20Mandate%20to%20create%20Route%20Table%20and%20Routes%20every%20time%20while%20running%20the%20Template.%3C%2FP%3E%3CP%3EIs%20it%20possible%20to%20ignore%20creating%20Route%20Table%20each%20time%20while%20creating%20NSG's.%20Or%20we%20need%20to%20give%20option%20like%20we%20need%20to%20add%20or%20avoid%20creating%20Route%20Tables.%20Help%20me%20on%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETemplate%20i%20am%20following%20is%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%7B%3CBR%20%2F%3E%22%24schema%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fschema.management.azure.com%2Fschemas%2F2019-04-01%2FdeploymentTemplate.json%23%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fschema.management.azure.com%2Fschemas%2F2019-04-01%2FdeploymentTemplate.json%23%3C%2FA%3E%22%2C%3CBR%20%2F%3E%22contentVersion%22%3A%20%221.0.0.0%22%2C%3CBR%20%2F%3E%22parameters%22%3A%20%7B%3CBR%20%2F%3E%22location%22%3A%20%7B%3CBR%20%2F%3E%22type%22%3A%20%22string%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22VNetName%22%3A%20%7B%3CBR%20%2F%3E%22type%22%3A%20%22string%22%2C%3CBR%20%2F%3E%22metadata%22%3A%20%7B%3CBR%20%2F%3E%22description%22%3A%20%22description%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22SubnetInfo%22%3A%20%7B%3CBR%20%2F%3E%22type%22%3A%20%22array%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22resources%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22type%22%3A%20%22Microsoft.Network%2FnetworkSecurityGroups%22%2C%3CBR%20%2F%3E%22apiVersion%22%3A%20%222020-05-01%22%2C%3CBR%20%2F%3E%22name%22%3A%20%22%5Bconcat(parameters('SubnetInfo')%5BcopyIndex()%5D.properties.NSGName)%5D%22%2C%3CBR%20%2F%3E%22location%22%3A%20%22%5Bparameters('Location')%5D%22%2C%3CBR%20%2F%3E%22copy%22%3A%20%7B%3CBR%20%2F%3E%22name%22%3A%20%22NSGs%22%2C%3CBR%20%2F%3E%22count%22%3A%20%22%5Blength(parameters('SubnetInfo'))%5D%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22securityRules%22%3A%20%22%5Bparameters('SubnetInfo')%5BcopyIndex()%5D.properties.SecurityRules%5D%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22type%22%3A%20%22Microsoft.Network%2FrouteTables%22%2C%3CBR%20%2F%3E%22apiVersion%22%3A%20%222020-05-01%22%2C%3CBR%20%2F%3E%22name%22%3A%20%22%5Bconcat(parameters('SubnetInfo')%5BcopyIndex()%5D.properties.RouteName)%5D%22%2C%3CBR%20%2F%3E%22location%22%3A%20%22%5Bparameters('Location')%5D%22%2C%3CBR%20%2F%3E%22copy%22%3A%20%7B%3CBR%20%2F%3E%22name%22%3A%20%22Routes%22%2C%3CBR%20%2F%3E%22count%22%3A%20%22%5Blength(parameters('SubnetInfo'))%5D%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22routes%22%3A%20%22%5Bparameters('SubnetInfo')%5BcopyIndex()%5D.properties.Routes%5D%22%2C%3CBR%20%2F%3E%22disableBgpRoutePropagation%22%3A%20%22%5Bparameters('SubnetInfo')%5BcopyIndex()%5D.properties.disableBgpRoutePropagation%5D%22%3C%2FP%3E%3CP%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22type%22%3A%20%22Microsoft.Resources%2Fdeployments%22%2C%3CBR%20%2F%3E%22apiVersion%22%3A%20%222020-06-01%22%2C%3CBR%20%2F%3E%22name%22%3A%20%22%5Bconcat('update-'%2Cparameters('SubnetInfo')%5BcopyIndex()%5D.properties.SubnetName)%5D%22%2C%3CBR%20%2F%3E%22dependsOn%22%3A%20%5B%3CBR%20%2F%3E%22NSGs%22%2C%3CBR%20%2F%3E%22Routes%22%3CBR%20%2F%3E%5D%2C%3CBR%20%2F%3E%22copy%22%3A%20%7B%3CBR%20%2F%3E%22name%22%3A%20%22association%22%2C%3CBR%20%2F%3E%22count%22%3A%20%22%5Blength(parameters('SubnetInfo'))%5D%22%2C%3CBR%20%2F%3E%22mode%22%3A%20%22Serial%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22mode%22%3A%20%22Incremental%22%2C%3CBR%20%2F%3E%22template%22%3A%20%7B%3CBR%20%2F%3E%22%24schema%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fschema.management.azure.com%2Fschemas%2F2019-04-01%2FdeploymentTemplate.json%23%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fschema.management.azure.com%2Fschemas%2F2019-04-01%2FdeploymentTemplate.json%23%3C%2FA%3E%22%2C%3CBR%20%2F%3E%22contentVersion%22%3A%20%221.0.0.0%22%2C%3CBR%20%2F%3E%22resources%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22apiVersion%22%3A%20%222020-05-01%22%2C%3CBR%20%2F%3E%22type%22%3A%20%22Microsoft.Network%2FvirtualNetworks%2Fsubnets%22%2C%3CBR%20%2F%3E%22name%22%3A%20%22%5Bconcat(parameters('VNetName')%2C%20'%2F'%2C%20parameters('SubnetInfo')%5BcopyIndex()%5D.properties.SubnetName)%5D%22%2C%3CBR%20%2F%3E%22location%22%3A%20%22%5BresourceGroup().location%5D%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%22%5Breference(resourceId(resourceGroup().name%2C%20'Microsoft.Network%2FvirtualNetworks%2Fsubnets'%2C%20parameters('VNetName')%2C%20parameters('SubnetInfo')%5BcopyIndex()%5D.properties.SubnetName)%2C%20'2018-03-01').addressPrefix%5D%22%2C%3CBR%20%2F%3E%22networkSecurityGroup%22%3A%20%7B%3CBR%20%2F%3E%22id%22%3A%20%22%5BresourceId('Microsoft.Network%2FnetworkSecurityGroups'%2C%20parameters('SubnetInfo')%5BcopyIndex()%5D.properties.NSGName)%5D%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22routeTable%22%3A%20%7B%3CBR%20%2F%3E%22id%22%3A%20%22%5BresourceId('Microsoft.Network%2FrouteTables'%2C%20parameters('SubnetInfo')%5BcopyIndex()%5D.properties.RouteName)%5D%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPramater%20File%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%7B%3CBR%20%2F%3E%22%24schema%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fschema.management.azure.com%2Fschemas%2F2015-01-01%2FdeploymentParameters.json%23%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fschema.management.azure.com%2Fschemas%2F2015-01-01%2FdeploymentParameters.json%23%3C%2FA%3E%22%2C%3CBR%20%2F%3E%22contentVersion%22%3A%20%221.0.0.0%22%2C%3CBR%20%2F%3E%22parameters%22%3A%20%7B%3CBR%20%2F%3E%22location%22%3A%20%7B%3CBR%20%2F%3E%22value%22%3A%20%22East%20US%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22VNetName%22%3A%20%7B%3CBR%20%2F%3E%22value%22%3A%20%22VN01%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22SubnetInfo%22%3A%20%7B%3CBR%20%2F%3E%22value%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22NSGName%22%3A%20%22NSG01%22%2C%3CBR%20%2F%3E%22SubnetName%22%3A%20%22sub01%22%2C%3CBR%20%2F%3E%22RouteName%22%3A%20%22RT01%22%2C%3CBR%20%2F%3E%22securityRules%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22Inbound_Deny_All%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22description%22%3A%20%22Deny%20all%20inbound%20traffic%22%2C%3CBR%20%2F%3E%22protocol%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22sourcePortRange%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22sourceAddressPrefix%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22destinationPortRange%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22destinationAddressPrefix%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22access%22%3A%20%22Deny%22%2C%3CBR%20%2F%3E%22priority%22%3A%204096%2C%3CBR%20%2F%3E%22direction%22%3A%20%22Inbound%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%2C%3CBR%20%2F%3E%22disableBgpRoutePropagation%22%3A%20true%2C%3CBR%20%2F%3E%22routes%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22route1%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%2210.0.0.0%2F24%22%2C%3CBR%20%2F%3E%22nextHopType%22%3A%20%22VirtualAppliance%22%2C%3CBR%20%2F%3E%22nextHopIpAddress%22%3A%20%2210.0.0.4%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22route2%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%2210.15.0.0%2F24%22%2C%3CBR%20%2F%3E%22nextHopType%22%3A%20%22VirtualAppliance%22%2C%3CBR%20%2F%3E%22nextHopIpAddress%22%3A%20%2210.10.0.68%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22route3%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%2210.11.0.0%2F24%22%2C%3CBR%20%2F%3E%22nextHopType%22%3A%20%22VirtualAppliance%22%2C%3CBR%20%2F%3E%22nextHopIpAddress%22%3A%20%2210.11.0.68%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22NSGName%22%3A%20%22NSG02%22%2C%3CBR%20%2F%3E%22SubnetName%22%3A%20%22sub02%22%2C%3CBR%20%2F%3E%22RouteName%22%3A%20%22RT02%22%2C%3CBR%20%2F%3E%22securityRules%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22Outbound_Deny_All%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22description%22%3A%20%22Deny%20all%20inbound%20traffic%22%2C%3CBR%20%2F%3E%22protocol%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22sourcePortRange%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22sourceAddressPrefix%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22destinationPortRange%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22destinationAddressPrefix%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22access%22%3A%20%22Deny%22%2C%3CBR%20%2F%3E%22priority%22%3A%204096%2C%3CBR%20%2F%3E%22direction%22%3A%20%22Outbound%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%2C%3CBR%20%2F%3E%22disableBgpRoutePropagation%22%3A%20true%2C%3CBR%20%2F%3E%22routes%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22route1%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%2210.10.0.0%2F24%22%2C%3CBR%20%2F%3E%22nextHopType%22%3A%20%22VirtualAppliance%22%2C%3CBR%20%2F%3E%22nextHopIpAddress%22%3A%20%2210.0.0.4%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22route2%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%2210.0.0.0%2F24%22%2C%3CBR%20%2F%3E%22nextHopType%22%3A%20%22VirtualAppliance%22%2C%3CBR%20%2F%3E%22nextHopIpAddress%22%3A%20%2210.10.0.68%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22route3%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%2210.12.0.0%2F24%22%2C%3CBR%20%2F%3E%22nextHopType%22%3A%20%22VirtualAppliance%22%2C%3CBR%20%2F%3E%22nextHopIpAddress%22%3A%20%2210.12.0.68%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22NSGName%22%3A%20%22NSG03%22%2C%3CBR%20%2F%3E%22SubnetName%22%3A%20%22sub03%22%2C%3CBR%20%2F%3E%22RouteName%22%3A%20%22RT03%22%2C%3CBR%20%2F%3E%22securityRules%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22Inbound_Allow_Http%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22description%22%3A%20%22Allow%20inbound%20http%20traffic%22%2C%3CBR%20%2F%3E%22protocol%22%3A%20%22TCP%22%2C%3CBR%20%2F%3E%22sourcePortRange%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22sourceAddressPrefix%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22destinationPortRange%22%3A%20%2280%22%2C%3CBR%20%2F%3E%22destinationAddressPrefix%22%3A%20%22*%22%2C%3CBR%20%2F%3E%22access%22%3A%20%22Allow%22%2C%3CBR%20%2F%3E%22priority%22%3A%204096%2C%3CBR%20%2F%3E%22direction%22%3A%20%22Inbound%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%2C%3CBR%20%2F%3E%22disableBgpRoutePropagation%22%3A%20false%2C%3CBR%20%2F%3E%22routes%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22route1%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%2210.0.0.0%2F24%22%2C%3CBR%20%2F%3E%22nextHopType%22%3A%20%22VirtualAppliance%22%2C%3CBR%20%2F%3E%22nextHopIpAddress%22%3A%20%2210.0.0.4%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22route2%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%2210.10.0.0%2F24%22%2C%3CBR%20%2F%3E%22nextHopType%22%3A%20%22VirtualAppliance%22%2C%3CBR%20%2F%3E%22nextHopIpAddress%22%3A%20%2210.10.0.68%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22name%22%3A%20%22route3%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22addressPrefix%22%3A%20%2210.13.0.0%2F24%22%2C%3CBR%20%2F%3E%22nextHopType%22%3A%20%22VirtualAppliance%22%2C%3CBR%20%2F%3E%22nextHopIpAddress%22%3A%20%2210.13.0.68%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EVignesh%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1970497%22%20slang%3D%22en-US%22%3ERe%3A%20NSG%20and%20Route%20Table%20ARM%20Templates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1970497%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3E%40StefanIvem%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHi%20Stefan%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ECan%20you%20pls%20help%20on%20this.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

HI All,

 

I have a script which creates Both NSG and Route Tables(With Routes) in single Paramater and Tenplate file.

But in this script it is Mandate to create Route Table and Routes every time while running the Template.

Is it possible to ignore creating Route Table each time while creating NSG's. Or we need to give option like we need to add or avoid creating Route Tables. Help me on this.

 

Template i am following is:

 

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"VNetName": {
"type": "string",
"metadata": {
"description": "description"
}
},
"SubnetInfo": {
"type": "array"
}
},
"resources": [
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2020-05-01",
"name": "[concat(parameters('SubnetInfo')[copyIndex()].properties.NSGName)]",
"location": "[parameters('Location')]",
"copy": {
"name": "NSGs",
"count": "[length(parameters('SubnetInfo'))]"
},
"properties": {
"securityRules": "[parameters('SubnetInfo')[copyIndex()].properties.SecurityRules]"
}
},
{
"type": "Microsoft.Network/routeTables",
"apiVersion": "2020-05-01",
"name": "[concat(parameters('SubnetInfo')[copyIndex()].properties.RouteName)]",
"location": "[parameters('Location')]",
"copy": {
"name": "Routes",
"count": "[length(parameters('SubnetInfo'))]"
},
"properties": {
"routes": "[parameters('SubnetInfo')[copyIndex()].properties.Routes]",
"disableBgpRoutePropagation": "[parameters('SubnetInfo')[copyIndex()].properties.disableBgpRoutePropagation]"

}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-06-01",
"name": "[concat('update-',parameters('SubnetInfo')[copyIndex()].properties.SubnetName)]",
"dependsOn": [
"NSGs",
"Routes"
],
"copy": {
"name": "association",
"count": "[length(parameters('SubnetInfo'))]",
"mode": "Serial"
},
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"apiVersion": "2020-05-01",
"type": "Microsoft.Network/virtualNetworks/subnets",
"name": "[concat(parameters('VNetName'), '/', parameters('SubnetInfo')[copyIndex()].properties.SubnetName)]",
"location": "[resourceGroup().location]",
"properties": {
"addressPrefix": "[reference(resourceId(resourceGroup().name, 'Microsoft.Network/virtualNetworks/subnets', parameters('VNetName'), parameters('SubnetInfo')[copyIndex()].properties.SubnetName), '2018-03-01').addressPrefix]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('SubnetInfo')[copyIndex()].properties.NSGName)]"
},
"routeTable": {
"id": "[resourceId('Microsoft.Network/routeTables', parameters('SubnetInfo')[copyIndex()].properties.RouteName)]"
}
}
}
]
}
}
}
]
}

 

Pramater File:

 

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"value": "East US"
},
"VNetName": {
"value": "VN01"
},
"SubnetInfo": {
"value": [
{
"properties": {
"NSGName": "NSG01",
"SubnetName": "sub01",
"RouteName": "RT01",
"securityRules": [
{
"name": "Inbound_Deny_All",
"properties": {
"description": "Deny all inbound traffic",
"protocol": "*",
"sourcePortRange": "*",
"sourceAddressPrefix": "*",
"destinationPortRange": "*",
"destinationAddressPrefix": "*",
"access": "Deny",
"priority": 4096,
"direction": "Inbound"
}
}
],
"disableBgpRoutePropagation": true,
"routes": [
{
"name": "route1",
"properties": {
"addressPrefix": "10.0.0.0/24",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "10.0.0.4"
}
},
{
"name": "route2",
"properties": {
"addressPrefix": "10.15.0.0/24",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "10.10.0.68"
}
},
{
"name": "route3",
"properties": {
"addressPrefix": "10.11.0.0/24",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "10.11.0.68"
}
}
]
}
},
{
"properties": {
"NSGName": "NSG02",
"SubnetName": "sub02",
"RouteName": "RT02",
"securityRules": [
{
"name": "Outbound_Deny_All",
"properties": {
"description": "Deny all inbound traffic",
"protocol": "*",
"sourcePortRange": "*",
"sourceAddressPrefix": "*",
"destinationPortRange": "*",
"destinationAddressPrefix": "*",
"access": "Deny",
"priority": 4096,
"direction": "Outbound"
}
}
],
"disableBgpRoutePropagation": true,
"routes": [
{
"name": "route1",
"properties": {
"addressPrefix": "10.10.0.0/24",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "10.0.0.4"
}
},
{
"name": "route2",
"properties": {
"addressPrefix": "10.0.0.0/24",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "10.10.0.68"
}
},
{
"name": "route3",
"properties": {
"addressPrefix": "10.12.0.0/24",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "10.12.0.68"
}
}
]
}
},
{
"properties": {
"NSGName": "NSG03",
"SubnetName": "sub03",
"RouteName": "RT03",
"securityRules": [
{
"name": "Inbound_Allow_Http",
"properties": {
"description": "Allow inbound http traffic",
"protocol": "TCP",
"sourcePortRange": "*",
"sourceAddressPrefix": "*",
"destinationPortRange": "80",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 4096,
"direction": "Inbound"
}
}
],
"disableBgpRoutePropagation": false,
"routes": [
{
"name": "route1",
"properties": {
"addressPrefix": "10.0.0.0/24",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "10.0.0.4"
}
},
{
"name": "route2",
"properties": {
"addressPrefix": "10.10.0.0/24",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "10.10.0.68"
}
},
{
"name": "route3",
"properties": {
"addressPrefix": "10.13.0.0/24",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "10.13.0.68"
}
}
]
}
}
]
}
}
}

 

Regards,

Vignesh

 

 

1 Reply

@StefanIvem

 

Hi Stefan,

 

Can you pls help on this.