Bylaw

Gallery › Network › Azure built-in policies

Virtual Hubs should be protected with Azure Firewall

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Deploy an Azure Firewall to your Virtual Hubs to protect and granularly control internet egress and ingress traffic.

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

Azure Policy JSONVirtualHubs_DeployedWithAzureFirewall_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Virtual Hubs should be protected with Azure Firewall",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Deploy an Azure Firewall to your Virtual Hubs to protect and granularly control internet egress and ingress traffic.",
    "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/virtualHubs"
          },
          {
            "field": "Microsoft.Network/virtualHubs/azureFirewall",
            "exists": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/72923a3a-e567-46d3-b3f9-ffb2462a1c3a",
  "name": "72923a3a-e567-46d3-b3f9-ffb2462a1c3a"
}
Bylaw72923a3a-e567-46d3-b3f9-ffb2462a1c3a.bylaw.ps1 · 28 lines
# Converted from VirtualHubs_DeployedWithAzureFirewall_Audit.json by ConvertTo-Bylaw.
Policy '72923a3a-e567-46d3-b3f9-ffb2462a1c3a' {

    Properties @{
        DisplayName   = 'Virtual Hubs should be protected with Azure Firewall'
        Description   = 'Deploy an Azure Firewall to your Virtual Hubs to protect and granularly control internet egress and ingress traffic.'
        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/virtualHubs' {

        Require 'azureFirewall exists' {
            Field azureFirewall | Must -Exist
        }
    }

    Effect (Param Effect)
}

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