Bylaw

Gallery › Network › Azure Community Policy

Enforce load balancer standard SKU

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy enforces standard sku for load balancers.

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

Azure Policy JSONazurepolicy.json · 48 lines
{
  "name": "0c453dc9-e41b-4676-92ea-7a77e1796ea4",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Enforce load balancer standard SKU",
    "description": "This policy enforces standard sku for load balancers.",
    "metadata": {
      "category": "Network",
      "createdBy": "",
      "updatedBy": null,
      "updatedOn": null,
      "version": "1.0.0"
    },
    "mode": "Indexed",
    "parameters": {
      "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/loadBalancers",
            "field": "type"
          },
          {
            "field": "Microsoft.Network/loadBalancers/sku.name",
            "notEquals": "Standard"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw0c453dc9-e41b-4676-92ea-7a77e1796ea4.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '0c453dc9-e41b-4676-92ea-7a77e1796ea4' {

    Properties @{
        DisplayName = 'Enforce load balancer standard SKU'
        Description = 'This policy enforces standard sku for load balancers.'
        Category    = 'Network'
        Version     = '1.0.0'
        Mode        = 'Indexed'
    }

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

    Resource 'Microsoft.Network/loadBalancers' {

        Require 'sku.name is Standard' {
            Field sku.name | Must -Be 'Standard'
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Network/enforce-load-balancer-standard-sku/azurepolicy.json in Azure/Community-Policy, under the MIT licence.