Bylaw

Gallery › Mission › Azure built-in policies

Webapp Slots should use App Service Environment.

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. Require the use of App Service Environment for Webapp Slots.

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

Azure Policy JSONASERequiredForAppSlot_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Webapp Slots should use App Service Environment.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Require the use of App Service Environment for Webapp Slots.",
    "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"
          },
          {
            "exists": "false",
            "field": "Microsoft.Web/sites/slots/hostingEnvironmentProfile.id"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/028282f7-374f-43c4-ac82-334b82c1ad80",
  "name": "028282f7-374f-43c4-ac82-334b82c1ad80"
}
Bylaw028282f7-374f-43c4-ac82-334b82c1ad80.bylaw.ps1 · 28 lines
# Converted from ASERequiredForAppSlot_Audit.json by ConvertTo-Bylaw.
Policy '028282f7-374f-43c4-ac82-334b82c1ad80' {

    Properties @{
        DisplayName   = 'Webapp Slots should use App Service Environment.'
        Description   = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Require the use of App Service Environment for Webapp Slots.'
        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' {

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

    Effect (Param Effect)
}

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