🧠 Question: Why Bother With Tags and Parameter Files?

Imagine you're packing a suitcase. Tags = labels on your stuff ("Work Clothes", "Gadgets").

Parameter files = a checklist you reuse every trip so you don’t forget anything. 🧳

In the world of Azure, this helps you:

  • Organize and categorize resources (hello, billing & audit trails 👋)
  • Avoid hardcoding things into your templates
  • Easily switch between environments (Dev, Test, Prod)

✅ Prerequisites Check

Before we jump in, make sure you’ve already got these in place:

  • ✔️ Azure CLI installed
  • ✔️ Logged in to your Azure account (az login)
  • ✔️ A resource group created:
az group create --name RG1 --location "East US"

🧪 Task 1: Add Tags as Parameters in Your Template

Open your existing azuredeploy.json in VS Code (or start fresh).

Let’s define a new parameter called resourceTags:

"resourceTags": {
  "type": "object",
  "defaultValue": {
    "Environment": "Dev",
    "Project": "Tutorial"
  }
}

Now here's a complete example template with that parameter in action:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storagePrefix": {
      "type": "string",
      "minLength": 3,
      "maxLength": 11
    },
    "storageSKU": {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "allowedValues": [
        "Standard_LRS", "Standard_GRS", "Standard_RAGRS",
        "Standard_ZRS", "Premium_LRS", "Premium_ZRS",
        "Standard_GZRS", "Standard_RAGZRS"
      ]
    },
    "resourceTags": {
      "type": "object",
      "defaultValue": {
        "Environment": "Dev",
        "Project": "Tutorial"
      }
    }
  },
  "functions": [],
  "variables": {
    "uniqueStorageName": "[toLower(concat(parameters('storagePrefix'), uniqueString(resourceGroup().id)))]"
  },
  "resources": [
    {
      "name": "[variables('uniqueStorageName')]",
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2021-04-01",
      "location": "[resourceGroup().location]",
      "kind": "StorageV2",
      "sku": {
        "name": "[parameters('storageSKU')]"
      },
      "tags": "[parameters('resourceTags')]"
    }
  ],
  "outputs": {}
}

🚀 Task 2: Quick Test with Inline Parameters

Let’s test it fast without a parameter file:

templateFile="azuredeploy.json"
DeploymentName="updateTags-$(date +'%d-%b-%Y')"

az deployment group create \
  --resource-group RG1 \
  --name $DeploymentName \
  --template-file $templateFile \
  --parameters storagePrefix=mybob129 storageSKU=Standard_LRS

🧪 Task 3: Create a Parameter File (Reusability For the win!)

Instead of typing parameters each time, you can save them in a file.

📁 Create a file named: azuredeploy.parameters.dev.json

Paste this into it:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storagePrefix": {
      "value": "mydevev"
    },
    "storageSKU": {
      "value": "Standard_LRS"
    },
    "resourceTags": {
      "value": {
        "Environment": "Dev",
        "Project": "Learn"
      }
    }
  }
}

🚀 Task 4: Deploy Using Your Parameter File

Now let’s put that file to use:

templateFile="azuredeploy.json"
devParameterFile="azuredeploy.parameters.dev.json"
DeploymentName="addParameterFile-$(date +'%d-%b-%Y')"

az deployment group create \
  --resource-group RG1 \
  --name $DeploymentName \
  --template-file $templateFile \
  --parameters @$devParameterFile

✅ Check It Out in the Azure Portal

Go to the Azure Portal

  • Head to Resource groups > RG1
  • Click into your deployed Storage Account
  • Open the Tags tab
  • You should see:
    • Environment: Dev
    • Project: Learn

🎉 Boom — dynamic, tagged, and reusable ARM deployment!


🧠 In Short

Adding tags and using parameter files:

  • Keeps your templates clean and environment-agnostic
  • Makes your deployments flexible across dev/test/prod
  • Helps with organizing, billing, and searching resources

It's like making your code bilingual — easy to reuse and read, no matter the environment or who's running it 🛠️


Next Up

Wanna follow my Azure learning journey?

Stick around — I’m sharing it all, wins and stumbles included 😄

You can find me on LinkedIn

Drop me a message and just say hi 👋. Would love to hear what you're working on or learning!