Getting Started with ARM Templates
-
Prereq’s:
- JSON
- Visual Studio Code
- Manual Creation of Resources
-
ARM Template file Structure Refer Here
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "",
"apiProfile": "",
"parameters": { },
"variables": { },
"functions": [ ],
"resources": [ ],
"outputs": { }
}
- The minimal ARM Template will have the following structure
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "",
"resources": [ ]
}
- Install ARM Tools extension in visual studio code
- So lets start with minimal version of it
- $schema
- contentVersion
- resources
- The template as of now looks as
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "0.0.0.1",
"resources": [
]
}
- Now lets look at manual resource creation for the virtual network
- Now Lets try to write an arm template which creates
- ntier virtual network with 3 subnets Web, Business and Data
- Resource Schema Refer Here
- For resources selection, Follow the approach shown below
- The template written so far is
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "0.0.0.1",
"resources": [
{
"name": "ntier",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-05-01",
"location": "East US",
"properties": {
"addressSpace": {
"addressPrefixes": [ "192.168.0.0/16" ],
"subnets": [
{
"name": "WebSubnet",
"properties": {
"addressPrefix": "192.168.0.0/24"
}
},
{
"name": "AppSubnet",
"properties": {
"addressPrefix": "192.168.0.0/24"
}
},
{
"name": "DbSubnet",
"properties": {
"addressPrefix": "192.168.0.0/24"
}
}
]
}
}
}
]
}
- Next steps:
- Validating & executing template