Bylaw

Gallery › App Service › Azure built-in policies

Function app slots should provide an auto-generated domain name label scope

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.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 JSONFunctionApp_Slot_Audit_AutoGeneratedDomainNameLabelScope.json · 67 lines
{
  "properties": {
    "displayName": "Function app slots 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.1.0",
    "metadata": {
      "version": "1.1.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/slots"
          },
          {
            "field": "kind",
            "contains": "functionapp"
          },
          {
            "field": "kind",
            "notContains": "workflowapp"
          },
          {
            "field": "kind",
            "notContains": "azurecontainerapps"
          },
          {
            "field": "Microsoft.Web/sites/slots/sku",
            "notContains": "Isolated"
          },
          {
            "field": "Microsoft.Web/sites/slots/autoGeneratedDomainNameLabelScope",
            "exists": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/67da6a60-29e0-471d-b856-4cd2dee72fc0",
  "name": "67da6a60-29e0-471d-b856-4cd2dee72fc0"
}
Bylaw67da6a60-29e0-471d-b856-4cd2dee72fc0.bylaw.ps1 · 35 lines
# Converted from FunctionApp_Slot_Audit_AutoGeneratedDomainNameLabelScope.json by ConvertTo-Bylaw.
Policy '67da6a60-29e0-471d-b856-4cd2dee72fc0' {

    Properties @{
        DisplayName   = 'Function app slots 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.1.0'
        Category      = 'App Service'
        PolicyVersion = '1.1.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/slots' {

        When {
            Field kind | Must -ContainText 'functionapp'
            Field kind | Must -Not -ContainText 'workflowapp'
            Field kind | Must -Not -ContainText 'azurecontainerapps'
            Field sku | Must -Not -ContainText 'Isolated'
        }

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

    Effect (Param Effect)
}

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