Bylaw

Gallery › Network › Azure built-in policies

Azure VPN gateways should not use 'basic' SKU

Converted Policy Audit Disabled Mode All Version 1.0.0

This policy ensures that VPN gateways do not use 'basic' SKU.

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

Azure Policy JSONVPNGateways_BasicSKU_Audit.json · 53 lines
{
  "properties": {
    "displayName": "Azure VPN gateways should not use 'basic' SKU",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "This policy ensures that VPN gateways do not use 'basic' SKU.",
    "metadata": {
      "version": "1.0.0",
      "category": "Network"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Network/virtualNetworkGateways"
          },
          {
            "field": "Microsoft.Network/virtualNetworkGateways/gatewayType",
            "equals": "Vpn"
          },
          {
            "field": "Microsoft.Network/virtualNetworkGateways/sku.tier",
            "equals": "Basic"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/e345b6c3-24bd-4c93-9bbb-7e5e49a17b78",
  "name": "e345b6c3-24bd-4c93-9bbb-7e5e49a17b78"
}
Bylawe345b6c3-24bd-4c93-9bbb-7e5e49a17b78.bylaw.ps1 · 33 lines
# Converted from VPNGateways_BasicSKU_Audit.json by ConvertTo-Bylaw.
Policy 'e345b6c3-24bd-4c93-9bbb-7e5e49a17b78' {

    Properties @{
        DisplayName   = 'Azure VPN gateways should not use ''basic'' SKU'
        Description   = 'This policy ensures that VPN gateways do not use ''basic'' SKU.'
        Version       = '1.0.0'
        Category      = 'Network'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Network/virtualNetworkGateways' {

        When {
            Field gatewayType | Must -Be 'Vpn'
        }

        Require 'sku.tier is not Basic' {
            Field sku.tier | Must -Not -Be 'Basic' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Network/VPNGateways_BasicSKU_Audit.json in Azure/azure-policy, under the MIT licence.