last sync: 2020-Sep-18 14:08:07 UTC

Azure Policy

Inherit a tag from the subscription if missing

Policy DisplayName Inherit a tag from the subscription if missing
Policy Id 40df99da-1232-49b1-a39a-6da8d878f469
Policy Category Tags
Policy Description Adds the specified tag with its value from the containing subscription when any resource missing this tag is created or updated. Existing resources can be remediated by triggering a remediation task. If the tag exists with a different value it will not be changed.
Policy Mode Indexed
Policy Type BuiltIn
Policy in Preview FALSE
Policy Deprecated FALSE
Policy Effect Fixed: modify
Roles used
Role Name Role Id
Contributor b24988ac-6180-42a0-ab88-20f7382dd24c
Policy Changes
Date/Time (UTC ymd) (i) Change Change detail
2020-02-20 08:25:18 add: Policy 40df99da-1232-49b1-a39a-6da8d878f469
Used in Policy Initiative(s) none
Policy Rule
{
  "properties": {
    "displayName": "Inherit a tag from the subscription if missing",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Adds the specified tag with its value from the containing subscription when any resource missing this tag is created or updated. Existing resources can be remediated by triggering a remediation task. If the tag exists with a different value it will not be changed.",
    "metadata": {
      "category": "Tags",
      "version": "1.0.0"
    },
    "parameters": {
      "tagName": {
        "type": "String",
        "metadata": {
          "displayName": "Tag Name",
          "description": "Name of the tag, such as 'environment'"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
          "field": "[concat('tags[', parameters('tagName'), ']')]",
            "exists": "false"
          },
          {
          "value": "[subscription().tags[parameters('tagName')]]",
            "notEquals": ""
          }
        ]
      },
      "then": {
        "effect": "modify",
        "details": {
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "operations": [
            {
              "operation": "add",
            "field": "[concat('tags[', parameters('tagName'), ']')]",
            "value": "[subscription().tags[parameters('tagName')]]"
            }
          ]
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/40df99da-1232-49b1-a39a-6da8d878f469",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "40df99da-1232-49b1-a39a-6da8d878f469"
}