Gallery › Network › Azure Community Policy
Prevent Deletion of Private DNS Zone
Converted Policy DenyAction Disabled Mode Indexed Version 1.0.0
This policy prevents the deletion of private DNS zones while still allowing the child record sets and records to be deleted.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 48 lines
{
"name": "3f83c643-7c61-47f0-9717-47fa562d9fa3",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Prevent Deletion of Private DNS Zone",
"description": "This policy prevents the deletion of private DNS zones while still allowing the child record sets and records to be deleted.",
"metadata": {
"version": "1.0.0",
"category": "Network"
},
"mode": "Indexed",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "DenyAction or Disabled the execution of the Policy"
},
"allowedValues": [
"DenyAction",
"Disabled"
],
"defaultValue": "DenyAction"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/privateDnsZones"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"actionNames": [
"delete"
],
"cascadeBehaviors": {
"resourceGroup": "deny"
}
}
}
}
}
}Bylaw3f83c643-7c61-47f0-9717-47fa562d9fa3.bylaw.ps1 · 22 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '3f83c643-7c61-47f0-9717-47fa562d9fa3' {
Properties @{
DisplayName = 'Prevent Deletion of Private DNS Zone'
Description = 'This policy prevents the deletion of private DNS zones while still allowing the child record sets and records to be deleted.'
Version = '1.0.0'
Category = 'Network'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('DenyAction', 'Disabled')
Default = 'DenyAction'
DisplayName = 'Effect'
Description = 'DenyAction or Disabled the execution of the Policy'
}
Resource 'Microsoft.Network/privateDnsZones'
DenyAction Delete -CascadeBehavior Deny -Effect (Param Effect)
}Source: policyDefinitions/Network/prevent-deletion-of-private-dns-zone/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw