Gallery › Monitoring › Azure Community Policy
Audit Diagnostic Settings for WVD Workspaces to Log Analytics workspace
Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0
Audits the diagnostic settings for WVD Workspaces to stream to a regional Log Analytics workspace when any WVD Workspace 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": "00de24fe-5733-4188-be47-9a09e5b1b77d",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit Diagnostic Settings for WVD Workspaces to Log Analytics workspace",
"description": "Audits the diagnostic settings for WVD Workspaces to stream to a regional Log Analytics workspace when any WVD Workspace 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/workspaces"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Insights/diagnosticSettings",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Insights/diagnosticSettings/logs.enabled",
"equals": "[parameters('logsEnabled')]"
}
]
}
}
}
}
}
}Bylaw00de24fe-5733-4188-be47-9a09e5b1b77d.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '00de24fe-5733-4188-be47-9a09e5b1b77d' {
Properties @{
DisplayName = 'Audit Diagnostic Settings for WVD Workspaces to Log Analytics workspace'
Description = 'Audits the diagnostic settings for WVD Workspaces to stream to a regional Log Analytics workspace when any WVD Workspace 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/workspaces'
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-workspaces-to-log-analytics-workspace/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw