Bylaw

Gallery › Network › Azure built-in policies

Azure Firewall Classic Rules should be migrated to Firewall Policy

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Migrate from Azure Firewall Classic Rules to Firewall Policy to utilize central management tools such as Azure Firewall Manager.

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

Azure Policy JSONAzureFirewallClassicRules_MigrateToAzureFirewallPolicy_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Azure Firewall Classic Rules should be migrated to Firewall Policy",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Migrate from Azure Firewall Classic Rules to Firewall Policy to utilize central management tools such as Azure Firewall Manager.",
    "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",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Network/azureFirewalls"
          },
          {
            "field": "Microsoft.Network/azureFirewalls/firewallPolicy.id",
            "exists": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/794d77cc-fe65-4801-8514-230c0be387a8",
  "name": "794d77cc-fe65-4801-8514-230c0be387a8"
}
Bylaw794d77cc-fe65-4801-8514-230c0be387a8.bylaw.ps1 · 28 lines
# Converted from AzureFirewallClassicRules_MigrateToAzureFirewallPolicy_Audit.json by ConvertTo-Bylaw.
Policy '794d77cc-fe65-4801-8514-230c0be387a8' {

    Properties @{
        DisplayName   = 'Azure Firewall Classic Rules should be migrated to Firewall Policy'
        Description   = 'Migrate from Azure Firewall Classic Rules to Firewall Policy to utilize central management tools such as Azure Firewall Manager.'
        Version       = '1.0.0'
        Category      = 'Network'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Network/azureFirewalls' {

        Require 'firewallPolicy.id exists' {
            Field firewallPolicy.id | Must -Exist
        }
    }

    Effect (Param Effect)
}

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