Gallery › Network › Azure Community Policy
Allowed Private DNS Zones
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
This policy restricts the creation of private DNS zones to a specified list.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 54 lines
{
"name": "b4028c7f-dace-44be-b194-6501ba609343",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Allowed Private DNS Zones",
"description": "This policy restricts the creation of private DNS zones to a specified list.",
"mode": "Indexed",
"metadata": {
"version": "1.0.0",
"category": "Network"
},
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Deny"
},
"allowedPrivateDnsZones": {
"type": "Array",
"metadata": {
"displayName": "Allowed Private DNS Zones",
"description": "List of allowed private DNS zones. Any other zones will be denied."
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/privateDnsZones"
},
{
"not": {
"field": "name",
"in": "[parameters('allowedPrivateDnsZones')]"
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawb4028c7f-dace-44be-b194-6501ba609343.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'b4028c7f-dace-44be-b194-6501ba609343' {
Properties @{
DisplayName = 'Allowed Private DNS Zones'
Description = 'This policy restricts the creation of private DNS zones to a specified list.'
Version = '1.0.0'
Category = 'Network'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Deny'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter AllowedPrivateDnsZones @{
Type = 'Array'
DisplayName = 'Allowed Private DNS Zones'
Description = 'List of allowed private DNS zones. Any other zones will be denied.'
}
Resource 'Microsoft.Network/privateDnsZones' {
Require 'name is one of the AllowedPrivateDnsZones parameter' {
Field name | Must -BeIn (Param AllowedPrivateDnsZones)
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/allowed-pdns-zones/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw