Bylaw

Gallery › Network › Azure built-in policies

Azure Firewall Policy should have DNS Proxy Enabled

Converted Policy Audit Disabled Mode Indexed Version 1.0.0

Enabling DNS Proxy will make the Azure Firewall associated with this policy to listen on port 53 and forward the DNS requests to specified DNS server

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONAzureFirewall_EnableDNSProxy_Audit.json · 49 lines
{
  "properties": {
    "displayName": "Azure Firewall Policy should have DNS Proxy Enabled",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Enabling DNS Proxy will make the Azure Firewall associated with this policy to listen on port 53 and forward the DNS requests to specified DNS server",
    "metadata": {
      "version": "1.0.0",
      "category": "Network"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Network/firewallPolicies"
          },
          {
            "field": "Microsoft.Network/firewallPolicies/dnsSettings.enableProxy",
            "exists": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/3f84c9b0-8b64-4208-98d4-6ada96bb49c3",
  "name": "3f84c9b0-8b64-4208-98d4-6ada96bb49c3"
}
Bylaw3f84c9b0-8b64-4208-98d4-6ada96bb49c3.bylaw.ps1 · 28 lines
# Converted from AzureFirewall_EnableDNSProxy_Audit.json by ConvertTo-Bylaw.
Policy '3f84c9b0-8b64-4208-98d4-6ada96bb49c3' {

    Properties @{
        DisplayName   = 'Azure Firewall Policy should have DNS Proxy Enabled'
        Description   = 'Enabling DNS Proxy will make the Azure Firewall associated with this policy to listen on port 53 and forward the DNS requests to specified DNS server'
        Version       = '1.0.0'
        Category      = 'Network'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Network/firewallPolicies' {

        Require 'dnsSettings.enableProxy exists' {
            Field dnsSettings.enableProxy | Must -Exist
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Network/AzureFirewall_EnableDNSProxy_Audit.json in Azure/azure-policy, under the MIT licence.