Use resource tags#
Cost Optimization · All resources · Rule · 2020_06 · Awareness
Azure resources should be tagged using a standard convention.
Description#
Azure Resource Manager (ARM) supports a flexible tagging model that allows each resource to be tagged. Tags are additional metadata that improves identification of resources and aids lifecycle management.
Azure stores tags as name/ value pairs such as environment = production
or costCode = 349921
.
A well defined tagging approach improves the management, billing, and automation operations of resources. When planning tags, identify information that is meaningful to business and technical staff.
Azure provides several built-in policies to managed tags. Using these policies help enforce a tagging standard can reduce overall management Resource tags can be inherited from subscriptions or resource groups using Azure Policy.
Recommendation#
Consider tagging resources using a standard convention. Identify mandatory and optional tags then tag all resources and resource groups using this standard.
Also consider using Azure Policy to enforce mandatory tags.
Examples#
Configure with Azure template#
To deploy resource that pass this rule:
- Set the
tags
property tags that align to your tagging standard.
For example:
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2022-09-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"tags": {
"environment": "production",
"costCode": "349921"
}
}
Configure with Bicep#
To deploy resource that pass this rule:
- Set the
tags
property tags that align to your tagging standard.
For example:
resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: name
location: location
tags: {
environment: 'production'
costCode: '349921'
}
}
Notes#
Azure Policy includes several built-in policies to enforce tagging such as:
- Add a tag to resources
- Add a tag to resource groups
- Require a tag on resources
- Require a tag on resource groups
- Inherit a tag from the resource group
- Inherit a tag from the resource group if missing
- Inherit a tag from the subscription
If you find resources that incorrectly report they should be tagged, please let us know by opening an issue.
Links#
- CO:03 Cost data and reporting
- Design review checklist for Cost Optimization
- Tag support for Azure resources
- Develop your naming and tagging strategy for Azure resources
- Define your tagging strategy
- Resource naming and tagging decision guide
- Assign policy definitions for tag compliance
- Enforcing custom tags