ARM Templates contd
- When we apply the template developed so far
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2022-09-01",
"name": "ntier",
"location": "East US",
"tags": {
"env": "dev"
},
"properties": {
"addressSpace": {
"addressPrefixes": [ "10.10.0.0/16" ]
},
"subnets": [
{
"name": "web",
"properties": {
"addressPrefix": "10.10.0.0/24"
}
},
{
"name": "app",
"properties": {
"addressPrefix": "10.10.1.0/24"
}
},
{
"name": "db",
"properties": {
"addressPrefix": "10.10.2.0/24"
}
}
]
}
}
]
}
- This will always create network in east us region with address space 10.10.0.0/16 and it creates 3 subnets
Change 1: I want to make a change which will create this network in the resource group’s location rather than east us always
Change 2: I want to give an option to the user to set address space for network and subnets
- To acheive this i should be using parameters Refer Here
- ARM Templates support the following types Refer Here
- Array
- bool
- int
- object
- secureObject
- secureString
- string
- Refer Here for the changes
- Now lets apply latest changes




Change 3: Create subnets depending on the variable passed
- Subnets are childs to vnets and Refer Here for better understanding of parent child
- Refer Here for the changes done to add subnets as outside resources rather than with in network resource
- Refer Here for fixing order of creation
- Now lets implement resource iteration using copy Refer Here
- Refer Here for the changeset containing subnet creation depending on the subnet cidr ranges passed