last sync: 2021-Sep-24 16:09:49 UTC

Azure Policy definition

Require a tag and its value on resources

Name Require a tag and its value on resources
Azure Portal
Id 1e30110a-5ceb-460c-a204-c1c3969c6d62
Version 1.0.1
details on versioning
Category Tags
Microsoft docs
Description Enforces a required tag and its value. Does not apply to resource groups.
Mode Indexed
Type BuiltIn
Preview FALSE
Deprecated FALSE
Effect Fixed: deny
Used RBAC Role none
History
Date/Time (UTC ymd) (i) Change type Change detail
2020-03-10 16:29:49 change Previous DisplayName: Require tag and its value
Used in Initiatives none
JSON
{
  "displayName": "Require a tag and its value on resources",
  "policyType": "BuiltIn",
  "mode": "Indexed",
  "description": "Enforces a required tag and its value. Does not apply to resource groups.",
  "metadata": {
    "version": "1.0.1",
    "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": {
      "not": {
        "field": "[concat('tags[', parameters('tagName'), ']')]",
        "equals": "[parameters('tagValue')]"
      }
    },
    "then": {
      "effect": "deny"
    }
  }
}