Bylaw

Gallery › App Service › Azure built-in policies

App Service apps should provide an auto-generated domain name label scope

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Providing an auto-generated domain name label scope for your app ensures that the app can be accessed via a unique URL. For more information, see https://aka.ms/app-service-autoGeneratedDomainNameLabelScope.

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

Azure Policy JSONWebApp_Audit_AutoGeneratedDomainNameLabelScope.json · 54 lines
{
  "properties": {
    "displayName": "App Service apps should provide an auto-generated domain name label scope",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Providing an auto-generated domain name label scope for your app ensures that the app can be accessed via a unique URL. For more information, see https://aka.ms/app-service-autoGeneratedDomainNameLabelScope.",
    "version": "1.0.0",
    "metadata": {
      "version": "1.0.0",
      "category": "App Service"
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled",
          "Deny"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites"
          },
          {
            "field": "Microsoft.Web/sites/sku",
            "notContains": "Isolated"
          },
          {
            "field": "Microsoft.Web/sites/autoGeneratedDomainNameLabelScope",
            "exists": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/80a53f01-1f9a-49af-a5d5-0248e947dc8e",
  "name": "80a53f01-1f9a-49af-a5d5-0248e947dc8e"
}
Bylaw80a53f01-1f9a-49af-a5d5-0248e947dc8e.bylaw.ps1 · 32 lines
# Converted from WebApp_Audit_AutoGeneratedDomainNameLabelScope.json by ConvertTo-Bylaw.
Policy '80a53f01-1f9a-49af-a5d5-0248e947dc8e' {

    Properties @{
        DisplayName   = 'App Service apps should provide an auto-generated domain name label scope'
        Description   = 'Providing an auto-generated domain name label scope for your app ensures that the app can be accessed via a unique URL. For more information, see https://aka.ms/app-service-autoGeneratedDomainNameLabelScope.'
        Version       = '1.0.0'
        Category      = 'App Service'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Web/sites' {

        When {
            Field sku | Must -Not -ContainText 'Isolated'
        }

        Require 'autoGeneratedDomainNameLabelScope exists' {
            Field autoGeneratedDomainNameLabelScope | Must -Exist
        }
    }

    Effect (Param Effect)
}

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