5 Indispensable Azure Policies for every environment
1. Require tags on resources
Enforcing tags on resources ensures that specific tags (e.g. environment owner or department) are applied to all resources during deployment. It’s one of those things that makes a big difference when managing large environments. Tags are invaluable for cost tracking, resource ownership, and environment segregation.
For example, enforcing an environment tag (dev, test, prod) keeps reports and dashboards organised.
Let’s look at a simple example:
You can set this policy to either deny deployment if tags are missing or automatically add default values.
Configuration:
az policy definition create --name "require-tags-on-resources" --display-name "Require Tags on Resources" --description "This policy requires that specific tags are assigned to all resources." --rules '{
"if": {
"field": "tags",
"exists": "false"
},
"then": {
"effect": "deny"
}
}' --mode All
Assigning the policy
You can assign this policy at any scope (management group, subscription, or resource group).
For example, apply it to a specific resource group named SpecificResource:
az policy assignment create \
--name "allowed-resource-types" \
--policy "allowed-resource-types" \
--scope "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}"
If a user tries to deploy a resource that isn’t on the allowed list, the policy will immediately block it.
2. Inherit tags
The Inherit tags policy helps you keep tags consistent across your Azure environment by automatically applying tags from parent resources (e.g. subscriptions or resource groups) to their underlying resources.
This is especially useful if you’ve split your subscriptions into environments such as dev, test, and prod, and want every resource to inherit a predefined tag like Environment.
If you already have existing resources that were deployed before you started using Azure policy, then these will inherit whatever you set at the subscription level.
Benefits:
- Keep tag values consistent across environments.
- Reduces manual tagging and the risk of human error.
- Simplifies ongoing resource management and reporting.
After defining the policy, assign it to your subscription or resource group. Existing resources missing that tag will automatically inherit it from the parent scope.
Configuration:
This policy definition uses the parameter tagName to determine which tag’s value to inherit from the parent resource group.
{
"properties": {
"displayName": "Inherit a tag from the resource group",
"mode": "Indexed",
"description": "Adds or replaces the specified tag and value from the parent resource group when any resource is created or updated. Existing resources can be remediated by triggering a remediation task.",
"metadata": {
"category": "Tags"
},
"parameters": {
"tagName": {
"type": "String",
"metadata": {
"displayName": "Tag Name",
"description": "Name of the tag, such as 'environment'"
}
}
},
"policyRule": {
"if": {
"allOf": [{
"field": "[concat('tags[', parameters('tagName'), ']')]",
"notEquals": "[resourceGroup().tags[parameters('tagName')]]"
},
{
"value": "[resourceGroup().tags[parameters('tagName')]]",
"notEquals": ""
}
]
},
"then": {
"effect": "modify",
"details": {
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"operations": [{
"operation": "addOrReplace",
"field": "[concat('tags[', parameters('tagName'), ']')]",
"value": "[resourceGroup().tags[parameters('tagName')]]"
}]
}
}
}
}
}
Assign the policy to your subscription or management group, specify the tag name (like environment), and any resource without that tag will automatically inherit it from its parent resource group.