last sync: 2020-Oct-30 14:31:57 UTC

Azure Policy definition

Append a tag and its value to resource groups

Name Append a tag and its value to resource groups
Azure Portal
Id 49c88fc8-6fd1-46fd-a676-f12d1d3a4c71
Version 1.0.0
details on versioning
Category Tags
Microsoft docs
Description Appends the specified tag and value when any resource group which is missing this tag is created or updated. Does not modify the tags of resource groups created before this policy was applied until those resource groups are changed. New 'modify' effect policies are available that support remediation of tags on existing resources (see https://aka.ms/modifydoc).
Mode All
Type BuiltIn
Preview FALSE
Deprecated FALSE
Effect Fixed: append
Used RBAC Role none
History
Date/Time (UTC ymd) (i) Change type Change detail
2020-03-10 16:29:49 change Previous DisplayName: Append tag and its default value to resource groups
Used in Initiatives none
Json
{
  "properties": {
    "displayName": "Append a tag and its value to resource groups",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Appends the specified tag and value when any resource group which is missing this tag is created or updated. Does not modify the tags of resource groups created before this policy was applied until those resource groups are changed. New 'modify' effect policies are available that support remediation of tags on existing resources (see https://aka.ms/modifydoc).",
    "metadata": {
      "version": "1.0.0",
      "category": "Tags"
    },
    "parameters": {
      "tagName": {
        "type": "String",
        "metadata": {
          "displayName": "Tag Name",
          "description": "Name of the tag, such as 'environment'"
        }
      },
      "tagValue": {
        "type": "String",
        "metadata": {
          "displayName": "Tag Value",
          "description": "Value of the tag, such as 'production'"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Resources/subscriptions/resourceGroups"
          },
          {
          "field": "[concat('tags[', parameters('tagName'), ']')]",
            "exists": "false"
          }
        ]
      },
      "then": {
        "effect": "append",
        "details": [
          {
          "field": "[concat('tags[', parameters('tagName'), ']')]",
          "value": "[parameters('tagValue')]"
          }
        ]
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/49c88fc8-6fd1-46fd-a676-f12d1d3a4c71",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "49c88fc8-6fd1-46fd-a676-f12d1d3a4c71"
}