DEV Community

1suleyman
1suleyman

Posted on

🚀 Exercise 01: Building Azure Infrastructure as Code (And Fixing My Subscription Along the Way)

Hey folks 👋

Just wrapped up a hands-on exercise in Azure using Bicep — Azure’s simpler, cleaner way to define infrastructure as code. If you’re like me and enjoy seeing your resources magically appear in the Azure portal (but without all the clicking around), you’ll probably enjoy this one.

Here’s how it went down — including what worked, what broke, and what I learned about quotas (and subscriptions that scream “please upgrade me”).


🎯 What I Set Out To Do

In this exercise, I wanted to:

  • Define a Storage Account, App Service Plan, and Web App using Bicep
  • Deploy it through Azure CLI
  • Use my own Azure subscription (yes, even on the free tier)
  • Learn how to debug when things go sideways 🙃

🧪 Step 1: Define the Storage Account in Bicep

I cracked open VS Code and created a file called main.bicep. Here’s the starter code:

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: 'toylaunchstoragebob' // 🔁 Must be globally unique, lowercase, no special chars
  location: 'westus'
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {
    accessTier: 'Hot'
  }
}
Enter fullscreen mode Exit fullscreen mode

Tip: Storage account names must be globally unique. I used 'toylaunchstoragebob' — feel free to copy or change it to match your vibe.


🛠️ Troubleshooting az login on macOS with PowerShell

I hit a bump when trying to run az login in PowerShell on my Mac. Turns out, PowerShell couldn’t find the Azure CLI path. If that’s you too, here’s how I fixed it:

  1. Run which az in Zsh/Bash → it gave me /opt/homebrew/bin/az
  2. Open your PowerShell profile: code $PROFILE
  3. Add this to the bottom:
   $env:PATH += ":/opt/homebrew/bin"
Enter fullscreen mode Exit fullscreen mode
  1. Restart PowerShell. Now az login works!

🧑‍💻 Log In and Set Up Your Resource Group

az login
az account set --subscription "Your Subscription Name"
az group create --name BicepRG --location westus
Enter fullscreen mode Exit fullscreen mode

🚀 Deploy the Storage Account

az deployment group create \
  --resource-group BicepRG \
  --template-file main.bicep \
  --name deploy-storage
Enter fullscreen mode Exit fullscreen mode

✅ Head over to Azure Portal → Resource Groups → BicepRG

Boom. One shiny new Storage Account 🎉


🧪 Step 2: Add an App Service Plan + Web App

I expanded my main.bicep file to look like this:

resource appServicePlan 'Microsoft.Web/serverfarms@2024-04-01' = {
  name: 'toylaunchappserviceplanbob'
  location: 'westus'
  sku: {
    name: 'F1'
  }
}

resource appServiceApp 'Microsoft.Web/sites@2024-04-01' = {
  name: 'toylaunchappbob'
  location: 'westus'
  properties: {
    serverFarmId: appServicePlan.id
    httpsOnly: true
  }
}
Enter fullscreen mode Exit fullscreen mode

Then I ran the deployment again:

az deployment group create \
  --resource-group BicepRG \
  --template-file main.bicep \
  --name deploy-app
Enter fullscreen mode Exit fullscreen mode

😩 And Then Azure Was Like: “Nah Bro”

I got this error:

The template deployment is not valid...
"SubscriptionIsOverQuotaForSku": "This region has quota of 0 instances for your subscription..."
Enter fullscreen mode Exit fullscreen mode

Translation? My free-tier subscription didn’t have enough quota in East US to deploy App Services.

Fix: I switched everything to westus and re-deployed.


✅ Final Results: Check the Portal

In the Azure Portal → Resource Groups → BicepRG, I saw:

  • 🗄️ A Storage Account
  • 🧱 An App Service Plan
  • 🌐 A Web App

It’s all there. And it was all built from a single Bicep template.


📦 What I Learned

Task What I Did
💾 Create Bicep Template Defined 3 Azure resources using clean Bicep syntax
💻 Use Azure CLI Deployed using az deployment group create
🤝 Work in My Own Subscription Hit some quota errors, but learned how to troubleshoot
🔍 Verified the Setup Used Azure CLI and Portal to double-check everything

🤝 Let’s Connect

If you’re learning Azure and Infrastructure as Code too, I’d love to connect with others on the same journey.

Drop me a message on LinkedIn and just say hi!

Top comments (0)