Gallery › App Service › Azure built-in policies
App Service app slots should have authentication enabled
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0
Azure App Service Authentication is a feature that can prevent anonymous HTTP requests from reaching the app slot, or authenticate those that have tokens before they reach the app slot.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAuthentication_WebApp_Slot_Audit.json · 57 lines
{
"properties": {
"displayName": "App Service app slots should have authentication enabled",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Azure App Service Authentication is a feature that can prevent anonymous HTTP requests from reaching the app slot, or authenticate those that have tokens before they reach the app slot.",
"metadata": {
"version": "1.0.0",
"category": "App Service"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "AuditIfNotExists",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Web/sites/slots"
},
{
"field": "kind",
"notContains": "functionapp"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Web/sites/slots/config",
"name": "authsettingsV2",
"existenceCondition": {
"field": "Microsoft.Web/sites/slots/config/globalValidation.requireAuthentication",
"equals": "true"
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/ae4cd8c5-2387-41af-9c0b-52992fc37c83",
"name": "ae4cd8c5-2387-41af-9c0b-52992fc37c83"
}Bylawae4cd8c5-2387-41af-9c0b-52992fc37c83.bylaw.ps1 · 33 lines
# Converted from Authentication_WebApp_Slot_Audit.json by ConvertTo-Bylaw.
Policy 'ae4cd8c5-2387-41af-9c0b-52992fc37c83' {
Properties @{
DisplayName = 'App Service app slots should have authentication enabled'
Description = 'Azure App Service Authentication is a feature that can prevent anonymous HTTP requests from reaching the app slot, or authenticate those that have tokens before they reach the app slot.'
Version = '1.0.0'
Category = 'App Service'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Web/sites/slots' {
Require 'kind contains functionapp' {
Field kind | Must -ContainText 'functionapp'
}
}
AuditIfNotExists 'Microsoft.Web/sites/slots/config' -Name 'authsettingsV2' -Effect (Param Effect) {
Require 'globalValidation.requireAuthentication is true' {
Field globalValidation.requireAuthentication | Must -Be 'true'
}
}
}Source: built-in-policies/policyDefinitions/App Service/Authentication_WebApp_Slot_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw