Gallery › BuiltInPolicyTest › Azure built-in policies
Requires resources to not have a specific tag. This is a versioning test built-in.
Converted Policy Audit Deny Disabled Mode Indexed Version 2.0.1
Denies the creation of a resource that contains the given tag. Does not apply to resource groups.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONDenyTag.json · 53 lines
{
"properties": {
"displayName": "Requires resources to not have a specific tag. This is a versioning test built-in.",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Denies the creation of a resource that contains the given tag. Does not apply to resource groups.",
"metadata": {
"version": "2.0.1",
"category": "BuiltInPolicyTest"
},
"version": "2.0.1",
"parameters": {
"tagName": {
"type": "String",
"metadata": {
"displayName": "Tag Name",
"description": "Name of the tag."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"field": "[concat('tags[', parameters('tagName'), ']')]",
"exists": "true"
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"2.0.1",
"2.0.0",
"1.1.1",
"1.0.1",
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/36fd7371-8eb7-4321-9c30-a7100022d048",
"name": "36fd7371-8eb7-4321-9c30-a7100022d048"
}Bylaw36fd7371-8eb7-4321-9c30-a7100022d048.bylaw.ps1 · 33 lines
# Converted from DenyTag.json by ConvertTo-Bylaw.
Policy '36fd7371-8eb7-4321-9c30-a7100022d048' {
Properties @{
DisplayName = 'Requires resources to not have a specific tag. This is a versioning test built-in.'
Description = 'Denies the creation of a resource that contains the given tag. Does not apply to resource groups.'
Version = '2.0.1'
Category = 'BuiltInPolicyTest'
PolicyVersion = '2.0.1'
Mode = 'Indexed'
}
Parameter TagName @{
Type = 'String'
DisplayName = 'Tag Name'
Description = 'Name of the tag.'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource * {
Require 'tag (Param TagName) does not exist' {
Tag (Param TagName) | Must -Not -Exist
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/BuiltInPolicyTest/DenyTag.json in Azure/azure-policy, under the MIT licence.
Bylaw