Gallery › Monitoring › Azure built-in policies
Azure Application Gateway should have Resource logs enabled
Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0
Enable Resource logs for Azure Application Gateway (plus WAF) and stream to a Log Analytics workspace. Get detailed visibility into inbound web traffic and actions taken to mitigate attacks.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAppGateway_DiagnosticLogEnabled_Audit.json · 60 lines
{
"properties": {
"displayName": "Azure Application Gateway should have Resource logs enabled",
"policyType": "BuiltIn",
"mode": "All",
"description": "Enable Resource logs for Azure Application Gateway (plus WAF) and stream to a Log Analytics workspace. Get detailed visibility into inbound web traffic and actions taken to mitigate attacks.",
"metadata": {
"version": "1.0.0",
"category": "Monitoring"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Network/applicationGateways"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Insights/diagnosticSettings",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Insights/diagnosticSettings/logs.enabled",
"equals": "true"
},
{
"field": "Microsoft.Insights/diagnosticSettings/metrics.enabled",
"equals": "true"
},
{
"field": "Microsoft.Insights/diagnosticSettings/workspaceId",
"exists": "true"
}
]
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/8a04f872-51e9-4313-97fb-fc1c3543011c",
"name": "8a04f872-51e9-4313-97fb-fc1c3543011c"
}Bylaw8a04f872-51e9-4313-97fb-fc1c3543011c.bylaw.ps1 · 29 lines
# Converted from AppGateway_DiagnosticLogEnabled_Audit.json by ConvertTo-Bylaw.
Policy '8a04f872-51e9-4313-97fb-fc1c3543011c' {
Properties @{
DisplayName = 'Azure Application Gateway should have Resource logs enabled'
Description = 'Enable Resource logs for Azure Application Gateway (plus WAF) and stream to a Log Analytics workspace. Get detailed visibility into inbound web traffic and actions taken to mitigate attacks.'
Version = '1.0.0'
Category = 'Monitoring'
PolicyVersion = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Network/applicationGateways'
AuditIfNotExists 'Microsoft.Insights/diagnosticSettings' -Effect (Param Effect) {
Require 'logs.enabled is true, metrics.enabled is true and workspaceId exists' {
Field logs.enabled | Must -Be 'true'
Field metrics.enabled | Must -Be 'true'
Field workspaceId | Must -Exist
}
}
}Source: built-in-policies/policyDefinitions/Monitoring/AppGateway_DiagnosticLogEnabled_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw