{
   "properties": {
      "displayName": "Add or replace a tag on subscriptions",
      "policyType": "BuiltIn",
      "mode": "All",
      "description": "Adds or replaces the specified tag and value on subscriptions via a remediation task. Existing resource groups can be remediated by triggering a remediation task. See https://aka.ms/azurepolicyremediation for more information on policy remediation.",
      "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"
               },
               {
                  "field": "[concat('tags[', parameters('tagName'), ']')]",
                  "notEquals": "[parameters('tagValue')]"
               }
            ]
         },
         "then": {
            "effect": "modify",
            "details": {
               "roleDefinitionIds": [
                  "/providers/microsoft.authorization/roleDefinitions/4a9ae827-6dc8-4573-8ac7-8239d42aa03f"
               ],
               "operations": [
                  {
                     "operation": "addOrReplace",
                     "field": "[concat('tags[', parameters('tagName'), ']')]",
                     "value": "[parameters('tagValue')]"
                  }
               ]
            }
         }
      }
   },
   "id": "/providers/Microsoft.Authorization/policyDefinitions/61a4d60b-7326-440e-8051-9f94394d4dd1",
   "name": "61a4d60b-7326-440e-8051-9f94394d4dd1"
}