Gallery › General › Azure Community Policy
Match multiple name patterns.
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
Allows one of multiple naming patterns for resources.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 49 lines
{
"name": "c57d9f5d-39a7-4b98-a17a-d55df5b7b33d",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Match multiple name patterns.",
"description": "Allows one of multiple naming patterns for resources.",
"metadata": {
"version": "1.0.0",
"category": "General"
},
"mode": "Indexed",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"not": {
"field": "name",
"match": "contoso??????"
}
},
{
"not": {
"field": "name",
"match": "contoso-???-##"
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawc57d9f5d-39a7-4b98-a17a-d55df5b7b33d.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'c57d9f5d-39a7-4b98-a17a-d55df5b7b33d' {
Properties @{
DisplayName = 'Match multiple name patterns.'
Description = 'Allows one of multiple naming patterns for resources.'
Version = '1.0.0'
Category = 'General'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource * {
When {
Field name | Must -Not -MatchCase 'contoso??????'
}
Require 'name matches contoso-???-##' {
Field name | Must -MatchCase 'contoso-???-##'
}
}
Effect (Param Effect)
}Source: policyDefinitions/General/match-multiple-name-patterns/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw