Bylaw

Gallery › Network › Azure Community Policy

Allowed Application Gateway SKUs

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

This policy enables you to specify a set of application Gateway 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": "fd64e3d1-23f3-493b-9a50-afedb82ca46f",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Allowed Application Gateway SKUs",
    "description": "This policy enables you to specify a set of application Gateway 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 application gateways.",
          "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/applicationGateways"
          },
          {
            "not": {
              "field": "Microsoft.Network/applicationGateways/sku.name",
              "in": "[parameters('listOfAllowedSKUs')]"
            }
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawfd64e3d1-23f3-493b-9a50-afedb82ca46f.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'fd64e3d1-23f3-493b-9a50-afedb82ca46f' {

    Properties @{
        DisplayName = 'Allowed Application Gateway SKUs'
        Description = 'This policy enables you to specify a set of application Gateway 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 application gateways.'
    }
    Parameter Effect @{
        AllowedValues = @('Deny', 'Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Deny, Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.Network/applicationGateways' {

        Require 'sku.name is one of the ListOfAllowedSKUs parameter' {
            Field sku.name | Must -BeIn (Param ListOfAllowedSKUs)
        }
    }

    Effect (Param Effect)
}

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