Bylaw

Gallery › Resilience › Azure built-in policies

[Preview]: Load Balancers should be Zone Resilient

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0-preview Preview

Load Balancers with a sku other than Basic inherit the resilience of the Public IP addresses in their frontend. When combined with the 'Public IP addresses should be Zone Resilient' policy, this approach ensures the necessary redundancy to withstand a zone outage.

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

Azure Policy JSONNetwork_loadBalancers_ZoneResilient_Audit.json · 51 lines
{
  "properties": {
    "displayName": "[Preview]: Load Balancers should be Zone Resilient",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Load Balancers with a sku other than Basic inherit the resilience of the Public IP addresses in their frontend. When combined with the 'Public IP addresses should be Zone Resilient' policy, this approach ensures the necessary redundancy to withstand a zone outage.",
    "metadata": {
      "category": "Resilience",
      "version": "1.0.0-preview",
      "preview": true
    },
    "version": "1.0.0-preview",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "This parameter lets you choose the effect of the policy. If you choose Audit (default), the policy will only audit resources for compliance. If you choose Deny, the policy will deny the creation of non-compliant resources. If you choose Disabled, the policy will not enforce compliance (useful, for example, as a second assignment to ignore a subset of non-compliant resources in a single resource group)."
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Network/loadBalancers"
          },
          {
            "field": "Microsoft.Network/loadBalancers/sku.name",
            "equals": "Basic"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/42daa901-5969-47ef-92cb-b75df946195a",
  "name": "42daa901-5969-47ef-92cb-b75df946195a"
}
Bylaw42daa901-5969-47ef-92cb-b75df946195a.bylaw.ps1 · 29 lines
# Converted from Network_loadBalancers_ZoneResilient_Audit.json by ConvertTo-Bylaw.
Policy '42daa901-5969-47ef-92cb-b75df946195a' {

    Properties @{
        DisplayName   = '[Preview]: Load Balancers should be Zone Resilient'
        Description   = 'Load Balancers with a sku other than Basic inherit the resilience of the Public IP addresses in their frontend. When combined with the ''Public IP addresses should be Zone Resilient'' policy, this approach ensures the necessary redundancy to withstand a zone outage.'
        Category      = 'Resilience'
        Version       = '1.0.0-preview'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'This parameter lets you choose the effect of the policy. If you choose Audit (default), the policy will only audit resources for compliance. If you choose Deny, the policy will deny the creation of non-compliant resources. If you choose Disabled, the policy will not enforce compliance (useful, for example, as a second assignment to ignore a subset of non-compliant resources in a single resource group).'
    }

    Resource 'Microsoft.Network/loadBalancers' {

        Require 'sku.name is not Basic' {
            Field sku.name | Must -Not -Be 'Basic' -IfPresent
        }
    }

    Effect (Param Effect)
}

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