Bylaw

Gallery › Network › Azure Community Policy

Allowed Load Balancer SKUs

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

This policy enables you to specify a set of load balancer SKUs that your organization can deploy.

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

Azure Policy JSONazurepolicy.json · 54 lines
{
  "name": "1efe6195-1ac8-4751-9cd7-b956fcdd5be3",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Allowed Load Balancer SKUs",
    "description": "This policy enables you to specify a set of load balancer SKUs that your organization can deploy.",
    "metadata": {
      "version": "1.0.0",
      "category": "Network"
    },
    "mode": "All",
    "parameters": {
      "listOfAllowedSKUs": {
        "type": "Array",
        "metadata": {
          "description": "The list of SKUs that can be specified for load balancer.",
          "displayName": "Allowed SKUs"
        }
      },
      "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": [
          {
            "field": "type",
            "equals": "Microsoft.Network/loadbalancers"
          },
          {
            "not": {
              "field": "Microsoft.Network/loadbalancers/sku.name",
              "in": "[parameters('listOfAllowedSKUs')]"
            }
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw1efe6195-1ac8-4751-9cd7-b956fcdd5be3.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '1efe6195-1ac8-4751-9cd7-b956fcdd5be3' {

    Properties @{
        DisplayName = 'Allowed Load Balancer SKUs'
        Description = 'This policy enables you to specify a set of load balancer SKUs that your organization can deploy.'
        Version     = '1.0.0'
        Category    = 'Network'
        Mode        = 'All'
    }

    Parameter ListOfAllowedSKUs @{
        Type        = 'Array'
        DisplayName = 'Allowed SKUs'
        Description = 'The list of SKUs that can be specified for load balancer.'
    }
    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 one of the ListOfAllowedSKUs parameter' {
            Field sku.name | Must -BeIn (Param ListOfAllowedSKUs)
        }
    }

    Effect (Param Effect)
}

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