Nested Resources
- Resource with in a resource is called a nested resource.
- VNET is resource and subnet is a child resource
- When Creating child/nested resources the following should be considered
-
Name of the nested resource: Refer Here
-
Order of Execution: Order of execution can be controlled by using dependsOn function Refer Here
-
Exercise 3: Create a Virtual Network with 4 subnets experimenting Child resource and order of execution
- Sample:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "0.0.0.1",
"resources": [
{
"name": "ntier",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-11-01",
"location":"Central US",
"properties": {
"addressSpace": {
"addressPrefixes":["10.100.0.0/16"]
},
"subnets":[
{
"name": "web",
"properties":{
"addressPrefix": "10.100.0.0/24"
}
},
{
"name": "app",
"properties":{
"addressPrefix": "10.100.1.0/24"
}
},
{
"name": "db",
"properties":{
"addressPrefix": "10.100.2.0/24"
}
}
]
}
},
{
"name": "ntier/management",
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2019-11-01",
"properties": {
"addressPrefix": "10.100.3.0/24"
},
"dependsOn": [
"ntier"
]
}
]
}