Bylaw

Gallery › Mission › Azure built-in policies

App Service apps should enable outbound non-RFC 1918 traffic to Azure Virtual Network.

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. App Service apps should enable outbound non-RFC 1918 traffic to Azure Virtual Network.

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

Azure Policy JSONAppRFC1918Routing_Audit.json · 70 lines
{
  "properties": {
    "displayName": "App Service apps should enable outbound non-RFC 1918 traffic to Azure Virtual Network.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. App Service apps should enable outbound non-RFC 1918 traffic to Azure Virtual Network.",
    "metadata": {
      "version": "1.0.0",
      "category": "Mission"
    },
    "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"
      }
    },
    "policyRule": {
      "if": {
        "anyOf": [
          {
            "allOf": [
              {
                "field": "type",
                "equals": "Microsoft.Web/sites"
              },
              {
                "exists": "false",
                "field": "Microsoft.Web/sites/hostingEnvironmentProfile.id"
              },
              {
                "field": "Microsoft.Web/sites/vnetRouteAllEnabled",
                "equals": "false"
              }
            ]
          },
          {
            "allOf": [
              {
                "field": "type",
                "equals": "Microsoft.Web/sites/config"
              },
              {
                "field": "Microsoft.Web/sites/config/vnetRouteAllEnabled",
                "equals": "false"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/73aa9838-1906-4490-aa32-f7b89a8f4554",
  "name": "73aa9838-1906-4490-aa32-f7b89a8f4554"
}
Bylaw73aa9838-1906-4490-aa32-f7b89a8f4554.bylaw.ps1 · 39 lines
# Converted from AppRFC1918Routing_Audit.json by ConvertTo-Bylaw.
Policy '73aa9838-1906-4490-aa32-f7b89a8f4554' {

    Properties @{
        DisplayName   = 'App Service apps should enable outbound non-RFC 1918 traffic to Azure Virtual Network.'
        Description   = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. App Service apps should enable outbound non-RFC 1918 traffic to Azure Virtual Network.'
        Version       = '1.0.0'
        Category      = 'Mission'
        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'
    }

    Resource * {

        Require 'type, hostingEnvironmentProfile.id and vnetRouteAllEnabled are as required' {
            AnyOf {
                Field type | Must -Not -Be 'Microsoft.Web/sites' -IfPresent
                Field 'Microsoft.Web/sites/hostingEnvironmentProfile.id' | Must -Exist
                Field 'Microsoft.Web/sites/vnetRouteAllEnabled' | Must -Not -Be 'false' -IfPresent
            }
        }

        Require 'type and vnetRouteAllEnabled are as required' {
            AnyOf {
                Field type | Must -Not -Be 'Microsoft.Web/sites/config' -IfPresent
                Field 'Microsoft.Web/sites/config/vnetRouteAllEnabled' | Must -Not -Be 'false' -IfPresent
            }
        }
    }

    Effect (Param Effect)
}

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