In this lab, I dove into the fundamentals of Infrastructure as Code (IaC) using Azure Resource Manager (ARM) templates. The goal was simple but powerful: write, deploy, and modify an ARM template using VS Code and the Azure CLI — all within my own subscription.
💼 Scenario
As a cloud administrator, I needed to automate the deployment of infrastructure. In this lab, I:
- ✅ Created and deployed a blank ARM template
- ✅ Modified it to deploy a Storage Account
- ✅ Practiced real-world deployment from Visual Studio Code
- ✅ Troubleshot issues on macOS (and learned a ton!)
🛠️ Prerequisites I Used
To complete this lab, I had:
- ✅ My Azure subscription
- ✅ Visual Studio Code
- ✅ The Azure CLI (eventually 😅)
- ✅ The ARM Tools extension installed in VS Code
🧪 Task 1: Create and Deploy a Blank ARM Template
🔹 Step 1: Create the Template in VS Code
I opened VS Code and created a new file named azuredeploy.json. Then I typed arm! and selected the ARM Template snippet. That gave me this basic template:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"functions": [],
"variables": {},
"resources": [],
"outputs": {}
}💡 VS Code popped up a message about a missing parameters file — but no worries, I ignored it for now since I wasn’t using parameters yet.
🔹 Step 2: Fixing Azure CLI on macOS 😅
I hit a snag when trying to run az login:
bash: az: command not found🧰 How I Fixed It:
- ✅ Installed Homebrew first (since I didn’t have it):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"- ✅ Installed Azure CLI:
brew update && brew install azure-cli- ✅ Verified the installation:
az version- ✅ Fixed the PATH in both Zsh and Bash profiles:
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zprofile
source ~/.zprofileNow az was working!
🔹 Step 3: Log In and Create Resource Group
With the CLI working, I logged into Azure:
az loginI selected my subscription (my first ever subscription) and created a resource group:
az group create --name RG1 --location "East US"🔹 Step 4: Deploy the Blank Template
I deployed the blank ARM template like this:
templateFile="azuredeploy.json"
today=$(date +"%d-%b-%Y")
DeploymentName="blanktemplate-$today"
az deployment group create \
--resource-group RG1 \
--name $DeploymentName \
--template-file $templateFile✅ I went to the Azure Portal > Resource Groups > RG1 > Deployments — and saw the blank deployment succeed!
🧪 Task 2: Add a Storage Account to the Template
🔹 Step 1: Insert a Storage Resource
Inside the "resources": [] section of azuredeploy.json, I typed storage and selected the arm-storage snippet. It gave me:
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"name": "[concat('mystorage', uniqueString(resourceGroup().id))]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {}
}This snippet auto-generates a unique storage account name based on the resource group ID — a great trick for avoiding name collisions.
🔹 Step 2: Redeploy the Updated Template
With the storage account resource added, I saved the file and redeployed:
templateFile="azuredeploy.json"
today=$(date +"%d-%b-%Y")
DeploymentName="addstorage-$today"
az deployment group create \
--resource-group RG1 \
--name $DeploymentName \
--template-file $templateFile✅ Back in the portal, I saw:
- A second deployment listed
- A new Storage Account successfully created!
🧠 What I Learned
This lab was a perfect intro to ARM templates and IaC. I learned how to:
- 🔹 Write and structure a basic ARM template
- 🔹 Deploy infrastructure using the Azure CLI
- 🔹 Modify the template to include real Azure resources
- 🔹 Troubleshoot CLI issues on macOS like a pro 😎
🧹 Bonus Tip: Cleanup Resources
If you're practicing in your own subscription, you can remove everything quickly with:
az group delete --name RG1✅ Key Takeaways
- ARM templates give you full control over Azure resource deployments
- VS Code + ARM Tools extension = IaC superpowers 💪
- Even a simple JSON template can deploy real cloud infrastructure
- The Azure CLI is essential — and fixing it taught me more than the lab itself!
On to the next lab! 💻🔥