Skip to content

Instantly share code, notes, and snippets.

@BernieWhite
Created March 29, 2019 05:51
Show Gist options
  • Save BernieWhite/107e6a0ca502607d8f0321bd6d6cff6f to your computer and use it in GitHub Desktop.
Save BernieWhite/107e6a0ca502607d8f0321bd6d6cff6f to your computer and use it in GitHub Desktop.
Azure policy to inherit tags from resource groups
{
"policyRule": {
"if": {
"allOf": [
{
"field": "[concat('tags[', parameters('tagName'), ']')]",
"exists": "false"
},
{
"not": {
"field": "type",
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
}
}
]
},
"then": {
"effect": "append",
"details": [
{
"field": "[concat('tags[', parameters('tagName'), ']')]",
"value": "[resourcegroup().tags[parameters('tagName')]]"
}
]
}
},
"parameters": {
"tagName": {
"type": "String",
"metadata": {
"description": "The name of the tag to inherit",
"displayName": "Tag name"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment