Bylaw

Gallery › App Service › Azure built-in policies

[Deprecated]: App Service Environment should be provisioned with latest versions

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0-deprecated Deprecated

Only allow App Service Environment version 2 or version 3 to be provisioned. This policy is deprecated because App Service Environment v1 and v2 are retired and no longer supported. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.

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

Azure Policy JSONHostingEnvironment_LatestVersions_Audit.json · 52 lines
{
  "properties": {
    "displayName": "[Deprecated]: App Service Environment should be provisioned with latest versions",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Only allow App Service Environment version 2 or version 3 to be provisioned. This policy is deprecated because App Service Environment v1 and v2 are retired and no longer supported. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.",
    "metadata": {
      "version": "1.1.0-deprecated",
      "category": "App Service",
      "deprecated": true
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/hostingEnvironments"
          },
          {
            "field": "kind",
            "equals": "ASEV1"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/eb4d34ab-0929-491c-bbf3-61e13da19f9a",
  "name": "eb4d34ab-0929-491c-bbf3-61e13da19f9a"
}
Bylaweb4d34ab-0929-491c-bbf3-61e13da19f9a.bylaw.ps1 · 30 lines
# Converted from HostingEnvironment_LatestVersions_Audit.json by ConvertTo-Bylaw.
Policy 'eb4d34ab-0929-491c-bbf3-61e13da19f9a' {

    Properties @{
        DisplayName   = '[Deprecated]: App Service Environment should be provisioned with latest versions'
        Description   = 'Only allow App Service Environment version 2 or version 3 to be provisioned. This policy is deprecated because App Service Environment v1 and v2 are retired and no longer supported. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.'
        Version       = '1.1.0-deprecated'
        Category      = 'App Service'
        Deprecated    = $true
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Web/hostingEnvironments' {

        Require 'kind is not ASEV1' {
            Field kind | Must -Not -Be 'ASEV1' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/App Service/HostingEnvironment_LatestVersions_Audit.json in Azure/azure-policy, under the MIT licence.