Manage Azure subscriptions and governance
📘Microsoft Certified: Azure Administrator Associate (AZ-104)
1. What Are Tags?
In Azure, a tag is a name-value pair that you can apply to resources, resource groups, or subscriptions. Think of it as a label you attach to a resource to describe it.
- Name: The key or category of the tag.
- Value: The description or detail for that tag.
Example:
- Name:
Environment - Value:
Production
Purpose: Tags help you organize, manage, and report on resources. They don’t affect how a resource works, but they are critical for governance and management.
2. Why Are Tags Important in an IT Environment?
Tags are widely used in IT for resource management, billing, and automation:
- Cost Management:
- You can group resources by tags like
DepartmentorProjectto track costs. - Example: Tag all resources used by the “HR Department” with
Department: HR.
- You can group resources by tags like
- Resource Organization:
- With thousands of resources, tags help categorize by environment (
Dev,Test,Prod) or application.
- With thousands of resources, tags help categorize by environment (
- Automation & Governance:
- Scripts or Azure Policies can automatically act on resources with specific tags.
- Example: Automatically back up all resources with
Backup: Daily.
- Compliance & Reporting:
- Tags help ensure resources meet organizational policies.
- Example: Tag all resources that store sensitive data with
Compliance: GDPR.
3. How to Apply Tags
a) Azure Portal
- Go to the resource or resource group.
- Click Tags in the left-hand menu.
- Add a Name and Value.
- Click Save.
Note: You can tag individual resources, or apply the same tags to an entire resource group for efficiency.
b) Azure CLI
# Add a tag to a resource
az tag create --name Environment --values Production
# Add a tag directly to a resource
az resource tag --tags Environment=Production --name MyVM --resource-group MyResourceGroup
c) Azure PowerShell
# Set a tag on a resource
Set-AzResource -ResourceGroupName "MyResourceGroup" -ResourceName "MyVM" -Tag @{Environment="Production"} -Force
4. Managing Tags
a) Update Tags
- You can modify existing tags to update values or change names.
- Example: Change
Environment: DevtoEnvironment: Test.
b) Delete Tags
- Remove a tag completely from a resource.
- Example: If a project ends, remove
Project: ProjectX.
c) Inheritance
- Tags do not automatically propagate to resources in a resource group, unless you explicitly apply them at the group level.
- Policies or scripts are used if you want automatic tagging for all resources.
5. Best Practices for Tags
- Use a Standard Naming Convention:
- Keep it consistent, e.g.,
Environment,Owner,CostCenter.
- Keep it consistent, e.g.,
- Limit Tag Count:
- Azure allows 50 tags per resource. Don’t overuse tags.
- Use for Cost and Management:
- Always use tags to track cost, ownership, and environment.
- Automate with Policies:
- Use Azure Policy to enforce tagging rules. Example: Every resource must have a
CostCentertag.
- Use Azure Policy to enforce tagging rules. Example: Every resource must have a
6. Tag Reporting
- Azure Cost Management + Billing allows you to filter and group costs by tags.
- Example: See total cost of resources for
Department: Finance. - This is exam-relevant because Microsoft tests your ability to use tags for management and governance.
✅ Key Exam Points to Remember
- Tags are name-value pairs for resources.
- Tags help with organization, cost tracking, and automation.
- Tags can be applied using:
- Azure Portal
- Azure CLI
- PowerShell
- Tags can be added, updated, or removed.
- Tags don’t automatically propagate unless policies or scripts are used.
- Best practice: use consistent naming, limit number, and enforce with Azure Policy.
- Cost Management and governance heavily rely on tagging.
