Course contentsShow
← Cloud and Infrastructure
Lesson 918 of 2,98917. Azure ARM Templates and BicepFree lesson

Resource Tags and Policy Assignment

Apply tags systematically across resources and assign Azure policies through ARM templates for governance.

Resource Tags and Policy Assignment

What You'll Learn

You'll learn how to systematically apply tags across Azure resources and assign Azure policies using ARM templates to enforce governance and organizational standards at scale.

Why Tags and Policies Matter

Think of resource tags as labels on moving boxes during a relocation—they help you identify ownership, purpose, and category at a glance. In Azure, tags are key-value pairs (like Environment: Production or CostCenter: Marketing) attached to resources for organization, cost tracking, and automation.

Azure Policies, meanwhile, are like building codes for construction—they enforce rules about what can be deployed and how resources must be configured. Policies ensure compliance automatically, rather than relying on manual reviews.

Applying Tags in ARM Templates

Within your resource declaration, add a tags property:

{
  "type": "Microsoft.Storage/storageAccounts",
  "apiVersion": "2021-04-01",
  "name": "[parameters('storageName')]",
  "location": "[resourceGroup().location]",
  "tags": {
    "Environment": "Production",
    "Department": "Finance",
    "CostCenter": "CC-1234"
  },
  "sku": { "name": "Standard_LRS" }
}

Assigning Policies Through Templates

You can deploy policy assignments as resources in your template:

{
  "type": "Microsoft.Authorization/policyAssignments",
  "apiVersion": "2021-06-01",
  "name": "enforce-tag-policy",
  "properties": {
    "policyDefinitionId": "[parameters('policyDefinitionId')]",
    "scope": "[resourceGroup().id]"
  }
}

This assigns a pre-existing policy (like "require specific tags") to your resource group, automatically enforcing governance rules on all contained resources.

Combining Both for Governance

By declaring both tags and policy assignments in your templates, you create infrastructure-as-code governance—your deployment automatically categorizes resources and enforces compliance rules, making audits and cost management effortless.

Key Takeaway:
ARM templates let you systematically tag resources for organization and assign Azure policies for automated compliance enforcement, embedding governance directly into your deployment code.