Gallery › App Service › Azure built-in policies
App Service apps should have authentication enabled
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 2.0.1
Azure App Service Authentication is a feature that can prevent anonymous HTTP requests from reaching the web app, or authenticate those that have tokens before they reach the web app.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAuthentication_WebApp_Audit.json · 57 lines
{
"properties": {
"displayName": "App Service apps 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 web app, or authenticate those that have tokens before they reach the web app.",
"metadata": {
"version": "2.0.1",
"category": "App Service"
},
"version": "2.0.1",
"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"
},
{
"field": "kind",
"notContains": "functionapp"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Web/sites/config",
"name": "web",
"existenceCondition": {
"field": "Microsoft.Web/sites/config/siteAuthEnabled",
"equals": "true"
}
}
}
},
"versions": [
"2.0.1"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/95bccee9-a7f8-4bec-9ee9-62c3473701fc",
"name": "95bccee9-a7f8-4bec-9ee9-62c3473701fc"
}Bylaw95bccee9-a7f8-4bec-9ee9-62c3473701fc.bylaw.ps1 · 33 lines
# Converted from Authentication_WebApp_Audit.json by ConvertTo-Bylaw.
Policy '95bccee9-a7f8-4bec-9ee9-62c3473701fc' {
Properties @{
DisplayName = 'App Service apps should have authentication enabled'
Description = 'Azure App Service Authentication is a feature that can prevent anonymous HTTP requests from reaching the web app, or authenticate those that have tokens before they reach the web app.'
Version = '2.0.1'
Category = 'App Service'
PolicyVersion = '2.0.1'
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' {
Require 'kind contains functionapp' {
Field kind | Must -ContainText 'functionapp'
}
}
AuditIfNotExists 'Microsoft.Web/sites/config' -Name 'web' -Effect (Param Effect) {
Require 'siteAuthEnabled is true' {
Field siteAuthEnabled | Must -Be 'true'
}
}
}Source: built-in-policies/policyDefinitions/App Service/Authentication_WebApp_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw