Gallery › App Service › Azure built-in policies
App Service app slots should use managed identity
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0
Use a managed identity for enhanced authentication security
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONUseManagedIdentity_WebApp_Slot_Audit.json · 65 lines
{
"properties": {
"displayName": "App Service app slots should use managed identity",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Use a managed identity for enhanced authentication security",
"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": "web",
"existenceCondition": {
"anyOf": [
{
"field": "Microsoft.Web/sites/slots/config/managedServiceIdentityId",
"exists": "true"
},
{
"field": "Microsoft.Web/sites/slots/config/xmanagedServiceIdentityId",
"exists": "true"
}
]
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/4a15c15f-90d5-4a1f-8b63-2903944963fd",
"name": "4a15c15f-90d5-4a1f-8b63-2903944963fd"
}Bylaw4a15c15f-90d5-4a1f-8b63-2903944963fd.bylaw.ps1 · 36 lines
# Converted from UseManagedIdentity_WebApp_Slot_Audit.json by ConvertTo-Bylaw.
Policy '4a15c15f-90d5-4a1f-8b63-2903944963fd' {
Properties @{
DisplayName = 'App Service app slots should use managed identity'
Description = 'Use a managed identity for enhanced authentication security'
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 'web' -Effect (Param Effect) {
Require 'managedServiceIdentityId and xManagedServiceIdentityId are as required' {
AnyOf {
Field managedServiceIdentityId | Must -Exist
Field xManagedServiceIdentityId | Must -Exist
}
}
}
}Source: built-in-policies/policyDefinitions/App Service/UseManagedIdentity_WebApp_Slot_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw