Bylaw

Gallery › Mission › Azure built-in policies

App Service app slots should be injected into a 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 app slots should be injected into a virtual network.

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

Azure Policy JSONAppSlotVnetInject_Audit.json · 54 lines
{
  "properties": {
    "displayName": "App Service app slots should be injected into a 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 app slots should be injected into a 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": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites/slots"
          },
          {
            "field": "Microsoft.Web/sites/slots/virtualNetworkSubnetId",
            "equals": ""
          },
          {
            "field": "Microsoft.Web/sites/slots/hostingEnvironmentProfile.id",
            "exists": false
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/df42d971-b39b-43a4-a987-b29d1bfbffba",
  "name": "df42d971-b39b-43a4-a987-b29d1bfbffba"
}
Bylawdf42d971-b39b-43a4-a987-b29d1bfbffba.bylaw.ps1 · 32 lines
# Converted from AppSlotVnetInject_Audit.json by ConvertTo-Bylaw.
Policy 'df42d971-b39b-43a4-a987-b29d1bfbffba' {

    Properties @{
        DisplayName   = 'App Service app slots should be injected into a virtual network.'
        Description   = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. App Service app slots should be injected into a 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 'Microsoft.Web/sites/slots' {

        When {
            Field virtualNetworkSubnetId | Must -Be ''
        }

        Require 'hostingEnvironmentProfile.id exists' {
            Field hostingEnvironmentProfile.id | Must -Exist
        }
    }

    Effect (Param Effect)
}

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