Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
If you’ve ever built Azure resources manually in the portal, you know it can be time-consuming and prone to human error. That’s where ARM templates (Azure Resource Manager templates) come in—they allow you to define your infrastructure as code, making deployments consistent, repeatable, and automated.
In this post, we’ll walk through creating an ARM template for an Azure Web App and deploying it using the Azure CLI. By the end, you’ll have a working web app and a solid understanding of how ARM templates streamline cloud automation.
ARM (Azure Resource Manager) templates are JSON-based files that define Azure resources. Instead of manually configuring services in the portal, you describe the desired state once in a template, then deploy it as many times as you want.
Benefits of ARM templates:
Before writing templates, we’ll set up a few tools:
To check if you have the Azure CLI installed, run:
az version
If not installed, you can install it with WinGet on Windows:
winget install -e --id Microsoft.AzureCLI
Once installed, restart your terminal and verify the az command is available.
Let’s create a file named web-app.json inside VS Code.
An ARM template follows a schema and contains several root properties:
The App Service Plan is required to host a web app.
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2022-03-01",
"name": "arm-web-app-plan",
"location": "[resourceGroup().location]",
"sku": {
"name": "F1",
"tier": "Free"
},
"properties": {
"name": "arm-web-app-plan"
}
}
💡 Note: The F1 (Free) tier only allows one free plan per region.
Next, add the web app itself:
{
"type": "Microsoft.Web/sites",
"apiVersion": "2022-03-01",
"name": "arm-web-app-demo",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', 'arm-web-app-plan')]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', 'arm-web-app-plan')]"
}
}
This tells Azure:
Now that the template is ready, let’s deploy it.
az login
Create a Resource Group (if you don’t have one already):
az group create --name myResourceGroup --location eastus
Deploy the Template:
az deployment group create \
--resource-group myResourceGroup \
--template-file web-app.json
If successful, Azure returns a JSON output with details of the deployment.
Head over to the Azure Portal, open your Resource Group, and hit refresh. You should see:
arm-web-app-planarm-web-app-demoBoth resources are live, and the web app is ready to be configured or deployed with your code.
Here’s the full ready-to-use ARM template combining both the App Service Plan and the Web App:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2022-03-01",
"name": "arm-web-app-plan",
"location": "[resourceGroup().location]",
"sku": {
"name": "F1",
"tier": "Free"
},
"properties": {
"name": "arm-web-app-plan"
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2022-03-01",
"name": "arm-web-app-demo",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', 'arm-web-app-plan')]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', 'arm-web-app-plan')]"
}
}
]
}
Save this JSON as web-app.json, and run the deployment command to spin up your web app. 🚀
By defining infrastructure in an ARM template and deploying it with the Azure CLI, you’ve automated what would otherwise be several manual steps in the portal. This approach ensures consistency, saves time, and sets you on the path toward full Infrastructure as Code (IaC).
In upcoming posts, we’ll explore Bicep ARM’s modern successor—for an even smoother developer experience.
In the next section we will add the parameterized version of this template