Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Automating Azure Web App deployments with parameterized ARM templates allows you to create consistent and repeatable infrastructure. By using a single template file, you can deploy both an Azure App Service Plan and a Web App with custom names, locations, and pricing tiers. This eliminates manual configuration, reduces errors, and enables seamless integration into CI/CD pipelines.
A parameterized ARM template for a web app deployment typically contains these key sections:
webAppName, appServicePlanName, skuName (for the pricing tier), and location.Microsoft.Web/serverfarms. It represents the underlying infrastructure that hosts your web app.Microsoft.Web/sites. This is the application itself, which runs on the App Service Plan.dependsOn property is essential for ensuring the correct deployment order. You must ensure the App Service Plan is created before the Web App, as the Web App requires a host to run on. The Web App resource will have a dependsOn property that references the App Service Plan.Here’s a simple ARM template that creates:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2022-09-01",
"name": "myAppServicePlan",
"location": "eastus",
"sku": {
"name": "F1",
"tier": "Free"
},
"properties": {}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2022-09-01",
"name": "mywebappdemo123",
"location": "eastus",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', 'myAppServicePlan')]"
}
}
]
}
This works—but notice that both the plan name, app name, and location are hardcoded. Let’s fix that.
Here’s the same template, but now it accepts parameters:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServicePlanName": {
"type": "string",
"defaultValue": "myAppServicePlan",
"metadata": {
"description": "Name of the App Service Plan"
}
},
"webAppName": {
"type": "string",
"defaultValue": "myWebApp123",
"metadata": {
"description": "Name of the Web App"
}
},
"location": {
"type": "string",
"defaultValue": "eastus",
"allowedValues": [
"eastus",
"westus",
"centralus",
"uksouth"
],
"metadata": {
"description": "Location where resources will be deployed"
}
},
"skuName": {
"type": "string",
"defaultValue": "F1",
"allowedValues": [
"F1",
"B1",
"S1"
],
"metadata": {
"description": "Pricing tier for the App Service Plan"
}
}
},
"resources": [
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2022-09-01",
"name": "[parameters('appServicePlanName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('skuName')]",
"tier": "Free"
},
"properties": {}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2022-09-01",
"name": "[parameters('webAppName')]",
"location": "[parameters('location')]",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]"
}
}
]
}
appServicePlanName, webAppName, location, and skuName are parameters.You can deploy ARM templates using either Azure CLI or PowerShell.
az group create --name MyResourceGroup --location eastus
az deployment group create \
--resource-group MyResourceGroup \
--template-file template.json \
--parameters appServicePlanName=myPlan \
webAppName=myUniqueWebApp123 \
location=westus \
skuName=B1
New-AzResourceGroup -Name MyResourceGroup -Location eastus
New-AzResourceGroupDeployment `
-ResourceGroupName MyResourceGroup `
-TemplateFile template.json `
-appServicePlanName "myPlan" `
-webAppName "myUniqueWebApp123" `
-location "westus" `
-skuName "B1"
Now, you can use this template in:
F1, B1)S1, P1v2)eastus, uksouth, etc.)All without touching the JSON file just pass in parameters!
By parameterizing your ARM templates, you move from one-off deployments to scalable, reusable automation.
Instead of editing JSON each time, you pass in values when deploying making it perfect for CI/CD pipelines and enterprise-scale deployments.
Next time you need to spin up a new Web App in Azure, you’ll have a flexible template ready to go!