Gallery › Web PubSub › Azure built-in policies
Azure Web PubSub Service should enable diagnostic logs
Uses Condition Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0
Audit enabling of diagnostic logs. This enables you to recreate activity trails to use for investigation purposes; when a security incident occurs or when your network is compromised
ConvertTo-Bylaw converted this policy, and proved it compiles back to the same definition. Conditions the language can't express yet are written as raw JSON with Condition.
Azure Policy JSONDiagnosticLog_AINE.json · 54 lines
{
"properties": {
"displayName": "Azure Web PubSub Service should enable diagnostic logs",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Audit enabling of diagnostic logs. This enables you to recreate activity trails to use for investigation purposes; when a security incident occurs or when your network is compromised",
"metadata": {
"version": "1.0.0",
"category": "Web PubSub"
},
"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": {
"field": "type",
"equals": "Microsoft.SignalRService/webPubSub"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Insights/diagnosticSettings",
"existenceCondition": {
"count": {
"field": "Microsoft.Insights/diagnosticSettings/logs[*]",
"where": {
"field": "Microsoft.Insights/diagnosticSettings/logs.enabled",
"equals": "true"
}
},
"greaterOrEquals": 1
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/ee8a7be2-e9b5-47b9-9d37-d9b141ea78a4",
"name": "ee8a7be2-e9b5-47b9-9d37-d9b141ea78a4"
}Bylawee8a7be2-e9b5-47b9-9d37-d9b141ea78a4.bylaw.ps1 · 30 lines
# Converted from DiagnosticLog_AINE.json by ConvertTo-Bylaw.
Policy 'ee8a7be2-e9b5-47b9-9d37-d9b141ea78a4' {
Properties @{
DisplayName = 'Azure Web PubSub Service should enable diagnostic logs'
Description = 'Audit enabling of diagnostic logs. This enables you to recreate activity trails to use for investigation purposes; when a security incident occurs or when your network is compromised'
Version = '1.0.0'
Category = 'Web PubSub'
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.SignalRService/webPubSub'
AuditIfNotExists 'Microsoft.Insights/diagnosticSettings' -Effect (Param Effect) {
Require 'logs and logs.enabled are as required' {
Count 'logs[*]' -Where {
Condition '{ "field": "Microsoft.Insights/diagnosticSettings/logs.enabled", "equals": "true" }'
} | Must -BeGreaterOrEqual 1
}
}
}Source: built-in-policies/policyDefinitions/Web PubSub/DiagnosticLog_AINE.json in Azure/azure-policy, under the MIT licence.
Bylaw