Bylaw

Gallery › API Management › Azure built-in policies

API Management service should use a SKU that supports virtual networks

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

With supported SKUs of API Management, deploying service into a virtual network unlocks advanced API Management networking and security features which provides you greater control over your network security configuration. Learn more at: https://aka.ms/apimvnet.

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

Azure Policy JSONAllowedVNETSkus_AuditDeny.json · 72 lines
{
  "properties": {
    "displayName": "API Management service should use a SKU that supports virtual networks",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "With supported SKUs of API Management, deploying service into a virtual network unlocks advanced API Management networking and security features which provides you greater control over your network security configuration. Learn more at: https://aka.ms/apimvnet.",
    "metadata": {
      "version": "1.0.0",
      "category": "API Management"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      },
      "listOfAllowedSKUs": {
        "type": "Array",
        "metadata": {
          "description": "The list of SKUs that can be specified for Azure API Management service.",
          "displayName": "Allowed SKUs"
        },
        "allowedValues": [
          "Developer",
          "Basic",
          "Standard",
          "Premium",
          "Isolated",
          "Consumption"
        ],
        "defaultValue": [
          "Developer",
          "Premium",
          "Isolated"
        ]
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ApiManagement/service"
          },
          {
            "not": {
              "field": "Microsoft.ApiManagement/service/sku.name",
              "in": "[parameters('listOfAllowedSKUs')]"
            }
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/73ef9241-5d81-4cd4-b483-8443d1730fe5",
  "name": "73ef9241-5d81-4cd4-b483-8443d1730fe5"
}
Bylaw73ef9241-5d81-4cd4-b483-8443d1730fe5.bylaw.ps1 · 35 lines
# Converted from AllowedVNETSkus_AuditDeny.json by ConvertTo-Bylaw.
Policy '73ef9241-5d81-4cd4-b483-8443d1730fe5' {

    Properties @{
        DisplayName   = 'API Management service should use a SKU that supports virtual networks'
        Description   = 'With supported SKUs of API Management, deploying service into a virtual network unlocks advanced API Management networking and security features which provides you greater control over your network security configuration. Learn more at: https://aka.ms/apimvnet.'
        Version       = '1.0.0'
        Category      = 'API Management'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter ListOfAllowedSKUs @{
        Type          = 'Array'
        AllowedValues = @('Developer', 'Basic', 'Standard', 'Premium', 'Isolated', 'Consumption')
        Default       = @('Developer', 'Premium', 'Isolated')
        DisplayName   = 'Allowed SKUs'
        Description   = 'The list of SKUs that can be specified for Azure API Management service.'
    }

    Resource 'Microsoft.ApiManagement/service' {

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

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/API Management/AllowedVNETSkus_AuditDeny.json in Azure/azure-policy, under the MIT licence.