Bylaw

Gallery › Network › Azure Community Policy

Allowed Express Route bandwidth

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

This policy enables you to specify a set of express route bandwidths 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": "f52e242a-6605-4234-a71c-ddb88a9c746e",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Allowed Express Route bandwidth",
    "description": "This policy enables you to specify a set of express route bandwidths that your organization can deploy.",
    "metadata": {
      "version": "1.0.0",
      "category": "Network"
    },
    "mode": "All",
    "parameters": {
      "listOfBandwidthinMbps": {
        "type": "Array",
        "metadata": {
          "description": "The list of SKUs that can be specified for express route.",
          "displayName": "Allowed Bandwidth"
        }
      },
      "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/expressRouteCircuits"
          },
          {
            "not": {
              "field": "Microsoft.Network/expressRouteCircuits/serviceProvider.bandwidthInMbps",
              "in": "[parameters('listOfBandwidthinMbps')]"
            }
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawf52e242a-6605-4234-a71c-ddb88a9c746e.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'f52e242a-6605-4234-a71c-ddb88a9c746e' {

    Properties @{
        DisplayName = 'Allowed Express Route bandwidth'
        Description = 'This policy enables you to specify a set of express route bandwidths that your organization can deploy.'
        Version     = '1.0.0'
        Category    = 'Network'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.Network/expressRouteCircuits' {

        Require 'serviceProvider.bandwidthInMbps is one of the ListOfBandwidthinMbps parameter' {
            Field serviceProvider.bandwidthInMbps | Must -BeIn (Param ListOfBandwidthinMbps)
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Network/allowed-express-route-bandwidth/azurepolicy.json in Azure/Community-Policy, under the MIT licence.