Gallery › Monitoring › Azure built-in policies
[Deprecated]: Virtual machines should be connected to a specified workspace
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.2.1-deprecated Deprecated
This policy definition is deprecated because OMS Agent was deprecated on August 31, 2024. While there is not a specific replacement policy, we have various policies available based on the VM setup that can be found under Azure Monitor Agent/DCRA Linux. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONLogAnalytics_WorkspaceMismatch_VM_Audit.json · 66 lines
{
"properties": {
"displayName": "[Deprecated]: Virtual machines should be connected to a specified workspace",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy definition is deprecated because OMS Agent was deprecated on August 31, 2024. While there is not a specific replacement policy, we have various policies available based on the VM setup that can be found under Azure Monitor Agent/DCRA Linux. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.",
"metadata": {
"version": "1.2.1-deprecated",
"category": "Monitoring",
"deprecated": true
},
"version": "1.2.1",
"parameters": {
"logAnalyticsWorkspaceId": {
"type": "String",
"metadata": {
"displayName": "Log Analytics Workspace Id that virtual machines should be configured for",
"description": "This is the Id (GUID) of the Log Analytics Workspace that the virtual machines should be configured for."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "Disabled"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Compute/virtualMachines/extensions",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Compute/virtualMachines/extensions/publisher",
"equals": "Microsoft.EnterpriseCloud.Monitoring"
},
{
"field": "Microsoft.Compute/virtualMachines/extensions/settings.workspaceId",
"equals": "[parameters('logAnalyticsWorkspaceId')]"
}
]
}
}
}
},
"versions": [
"1.2.1",
"1.2.0",
"1.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/f47b5582-33ec-4c5c-87c0-b010a6b2e917",
"name": "f47b5582-33ec-4c5c-87c0-b010a6b2e917"
}Bylawf47b5582-33ec-4c5c-87c0-b010a6b2e917.bylaw.ps1 · 34 lines
# Converted from LogAnalytics_WorkspaceMismatch_VM_Audit.json by ConvertTo-Bylaw.
Policy 'f47b5582-33ec-4c5c-87c0-b010a6b2e917' {
Properties @{
DisplayName = '[Deprecated]: Virtual machines should be connected to a specified workspace'
Description = 'This policy definition is deprecated because OMS Agent was deprecated on August 31, 2024. While there is not a specific replacement policy, we have various policies available based on the VM setup that can be found under Azure Monitor Agent/DCRA Linux. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.'
Version = '1.2.1-deprecated'
Category = 'Monitoring'
Deprecated = $true
PolicyVersion = '1.2.1'
Mode = 'Indexed'
}
Parameter LogAnalyticsWorkspaceId @{
Type = 'String'
DisplayName = 'Log Analytics Workspace Id that virtual machines should be configured for'
Description = 'This is the Id (GUID) of the Log Analytics Workspace that the virtual machines should be configured for.'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'Disabled'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Compute/virtualMachines'
AuditIfNotExists 'Microsoft.Compute/virtualMachines/extensions' -Effect (Param Effect) {
Require 'publisher and settings.workspaceId are as required' {
Field publisher | Must -Be 'Microsoft.EnterpriseCloud.Monitoring'
Field settings.workspaceId | Must -Be (Param LogAnalyticsWorkspaceId)
}
}
}Source: built-in-policies/policyDefinitions/Monitoring/LogAnalytics_WorkspaceMismatch_VM_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw