Gallery › Network › Azure Community Policy
Enforce Firewall Policy DNS servers
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
This policy prevent settings non authorized dns servers for firewall policies.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 69 lines
{
"name": "14b1d0d7-3e90-4989-bb8e-e52773fc6a8f",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Enforce Firewall Policy DNS servers",
"description": "This policy prevent settings non authorized dns servers for firewall policies.",
"metadata": {
"category": "Network",
"createdBy": "",
"updatedBy": null,
"updatedOn": null,
"version": "1.0.0"
},
"mode": "Indexed",
"parameters": {
"servers": {
"type": "Array",
"metadata": {
"description": "The list of DNS servers to enforce exclusive existance of.",
"displayName": "DNS Servers list"
}
},
"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": [
{
"equals": "Microsoft.Network/firewallPolicies",
"field": "type"
},
{
"anyOf": [
{
"exists": false,
"field": "Microsoft.Network/firewallPolicies/dnsSettings.servers"
},
{
"count": {
"field": "Microsoft.Network/firewallPolicies/dnsSettings.servers[*]",
"where": {
"field": "Microsoft.Network/firewallPolicies/dnsSettings.servers[*]",
"notIn": "[parameters('servers')]"
}
},
"greater": 0
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw14b1d0d7-3e90-4989-bb8e-e52773fc6a8f.bylaw.ps1 · 38 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '14b1d0d7-3e90-4989-bb8e-e52773fc6a8f' {
Properties @{
DisplayName = 'Enforce Firewall Policy DNS servers'
Description = 'This policy prevent settings non authorized dns servers for firewall policies.'
Category = 'Network'
Version = '1.0.0'
Mode = 'Indexed'
}
Parameter Servers @{
Type = 'Array'
DisplayName = 'DNS Servers list'
Description = 'The list of DNS servers to enforce exclusive existance of.'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Network/firewallPolicies' {
Require 'dnsSettings.servers exists' {
Field dnsSettings.servers | Must -Exist
}
Require 'dnsSettings.servers is as required' {
Each 'dnsSettings.servers[*]' {
Element | Must -BeIn (Param Servers)
}
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/enforce-firewall-policy-dns-servers/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw