Gallery › Monitoring › Azure Community Policy
Audit Diagnostic Settings for WVD Application Groups to Log Analytics workspace
Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0
Audits the diagnostic settings for WVD Application Groups to stream to a regional Log Analytics workspace when any WVD Application Group which is missing these diagnostic settings is created or updated.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 59 lines
{
"name": "dfb59243-f127-4632-b14f-b1cf029a891a",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit Diagnostic Settings for WVD Application Groups to Log Analytics workspace",
"description": "Audits the diagnostic settings for WVD Application Groups to stream to a regional Log Analytics workspace when any WVD Application Group which is missing these diagnostic settings is created or updated.",
"metadata": {
"version": "1.0.0",
"category": "Monitoring"
},
"mode": "All",
"parameters": {
"logsEnabled": {
"type": "String",
"metadata": {
"displayName": "Enable logs",
"description": "Whether to enable logs stream to the Log Analytics workspace - True or False"
},
"allowedValues": [
"True",
"False"
],
"defaultValue": "True"
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.DesktopVirtualization/applicationgroups"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Insights/diagnosticSettings",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Insights/diagnosticSettings/logs.enabled",
"equals": "[parameters('logsEnabled')]"
}
]
}
}
}
}
}
}Bylawdfb59243-f127-4632-b14f-b1cf029a891a.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'dfb59243-f127-4632-b14f-b1cf029a891a' {
Properties @{
DisplayName = 'Audit Diagnostic Settings for WVD Application Groups to Log Analytics workspace'
Description = 'Audits the diagnostic settings for WVD Application Groups to stream to a regional Log Analytics workspace when any WVD Application Group which is missing these diagnostic settings is created or updated.'
Version = '1.0.0'
Category = 'Monitoring'
Mode = 'All'
}
Parameter LogsEnabled @{
AllowedValues = @('True', 'False')
Default = 'True'
DisplayName = 'Enable logs'
Description = 'Whether to enable logs stream to the Log Analytics workspace - True or False'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'AuditIfNotExists or Disabled the execution of the Policy'
}
Resource 'Microsoft.DesktopVirtualization/applicationgroups'
AuditIfNotExists 'Microsoft.Insights/diagnosticSettings' -Effect (Param Effect) {
Require 'logs.enabled is the LogsEnabled parameter' {
Field logs.enabled | Must -Be (Param LogsEnabled)
}
}
}Source: policyDefinitions/Monitoring/audit-diagnostic-settings-for-wvd-application-groups-to-log-analytics-workspace/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw