Bylaw

Gallery › App Service › Azure Community Policy

Allowed App Services Plan SKUs

Converted Policy Audit Deny Disabled Mode all Version 1.1.0

This policy enables you to specify a set of App Services Plan 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": "27e36ba1-7f72-4a8e-b981-ef06d5c78c1a",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Allowed App Services Plan SKUs",
    "description": "This policy enables you to specify a set of App Services Plan SKUs that your organization can deploy.",
    "metadata": {
      "version": "1.1.0",
      "category": "App Service"
    },
    "mode": "all",
    "parameters": {
      "listOfAllowedSKUs": {
        "type": "Array",
        "metadata": {
          "description": "The list of SKUs that can be specified for App Services Plan.",
          "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.Web/serverfarms"
          },
          {
            "not": {
              "field": "Microsoft.Web/serverfarms/sku.name",
              "in": "[parameters('listOfAllowedSKUs')]"
            }
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw27e36ba1-7f72-4a8e-b981-ef06d5c78c1a.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '27e36ba1-7f72-4a8e-b981-ef06d5c78c1a' {

    Properties @{
        DisplayName = 'Allowed App Services Plan SKUs'
        Description = 'This policy enables you to specify a set of App Services Plan SKUs that your organization can deploy.'
        Version     = '1.1.0'
        Category    = 'App Service'
        Mode        = 'All'
    }

    Parameter ListOfAllowedSKUs @{
        Type        = 'Array'
        DisplayName = 'Allowed SKUs'
        Description = 'The list of SKUs that can be specified for App Services Plan.'
    }
    Parameter Effect @{
        AllowedValues = @('Deny', 'Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Deny, Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.Web/serverfarms' {

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

    Effect (Param Effect)
}

Source: policyDefinitions/App Service/allowed-app-services-plan-skus/azurepolicy.json in Azure/Community-Policy, under the MIT licence.