{
   "properties": {
      "displayName": "Add a tag to resources",
      "policyType": "BuiltIn",
      "mode": "Indexed",
      "description": "Adds the specified tag and value 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. Does not modify tags on resource groups.",
      "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": {
            "field": "[concat('tags[', parameters('tagName'), ']')]",
            "exists": "false"
         },
         "then": {
            "effect": "modify",
            "details": {
               "roleDefinitionIds": [
                  "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
               ],
               "operations": [
                  {
                     "operation": "add",
                     "field": "[concat('tags[', parameters('tagName'), ']')]",
                     "value": "[parameters('tagValue')]"
                  }
               ]
            }
         }
      }
   },
   "id": "/providers/Microsoft.Authorization/policyDefinitions/4f9dc7db-30c1-420c-b61a-e1d640128d26",
   "name": "4f9dc7db-30c1-420c-b61a-e1d640128d26"
}