Gallery › Monitoring › Azure built-in policies
[Deprecated]: Configure Log Analytics extension on Azure Arc enabled Windows servers
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 2.2.0-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 Windows. 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.
{
"properties": {
"displayName": "[Deprecated]: Configure Log Analytics extension on Azure Arc enabled Windows servers",
"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 Windows. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.",
"metadata": {
"version": "2.2.0-deprecated",
"category": "Monitoring",
"deprecated": true
},
"version": "2.2.0",
"parameters": {
"logAnalytics": {
"type": "String",
"metadata": {
"displayName": "Log Analytics workspace",
"description": "Specify the Log Analytics workspace the agent should be connected to. If this workspace is outside of the scope of the assignment you must manually grant 'Log Analytics Contributor' permissions (or similar) to the policy assignment's principal ID.",
"strongType": "omsWorkspace",
"assignPermissions": true
}
},
"effect": {
"type": "string",
"defaultValue": "Disabled",
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.HybridCompute/machines"
},
{
"field": "Microsoft.HybridCompute/machines/osName",
"equals": "windows"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.HybridCompute/machines/extensions",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
],
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.HybridCompute/machines/extensions/type",
"equals": "MicrosoftMonitoringAgent"
},
{
"field": "Microsoft.HybridCompute/machines/extensions/publisher",
"equals": "Microsoft.EnterpriseCloud.Monitoring"
},
{
"field": "Microsoft.HybridCompute/machines/extensions/provisioningState",
"notEquals": "Failed"
}
]
},
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
},
"logAnalytics": {
"type": "string"
}
},
"variables": {
"vmExtensionName": "MicrosoftMonitoringAgent",
"vmExtensionPublisher": "Microsoft.EnterpriseCloud.Monitoring",
"vmExtensionType": "MicrosoftMonitoringAgent"
},
"resources": [
{
"name": "[concat(parameters('vmName'), '/', variables('vmExtensionName'))]",
"type": "Microsoft.HybridCompute/machines/extensions",
"location": "[parameters('location')]",
"apiVersion": "2019-12-12",
"properties": {
"publisher": "[variables('vmExtensionPublisher')]",
"type": "[variables('vmExtensionType')]",
"settings": {
"workspaceId": "[reference(parameters('logAnalytics'), '2015-03-20').customerId]",
"stopOnMultipleConnections": "true"
},
"protectedSettings": {
"workspaceKey": "[listKeys(parameters('logAnalytics'), '2015-03-20').primarySharedKey]"
}
}
}
],
"outputs": {
"policy": {
"type": "string",
"value": "[concat('Enabled extension for VM', ': ', parameters('vmName'))]"
}
}
},
"parameters": {
"vmName": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
},
"logAnalytics": {
"value": "[parameters('logAnalytics')]"
}
}
}
}
}
}
},
"versions": [
"2.2.0",
"2.1.1"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/69af7d4a-7b18-4044-93a9-2651498ef203",
"name": "69af7d4a-7b18-4044-93a9-2651498ef203"
}# Converted from LogAnalyticsExtension_Windows_HybridVM_DINE.json by ConvertTo-Bylaw.
Policy '69af7d4a-7b18-4044-93a9-2651498ef203' {
Properties @{
DisplayName = '[Deprecated]: Configure Log Analytics extension on Azure Arc enabled Windows servers'
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 Windows. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.'
Version = '2.2.0-deprecated'
Category = 'Monitoring'
Deprecated = $true
PolicyVersion = '2.2.0'
Mode = 'Indexed'
}
Parameter LogAnalytics @{
Type = 'String'
DisplayName = 'Log Analytics workspace'
Description = 'Specify the Log Analytics workspace the agent should be connected to. If this workspace is outside of the scope of the assignment you must manually grant ''Log Analytics Contributor'' permissions (or similar) to the policy assignment''s principal ID.'
Metadata = [ordered]@{ strongType = 'omsWorkspace'; assignPermissions = $true }
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'Disabled'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.HybridCompute/machines' {
Require 'osName is not windows' {
Field osName | Must -Not -Be 'windows' -IfPresent
}
}
DeployIfNotExists 'Microsoft.HybridCompute/machines/extensions' -Role 'Log Analytics Contributor' -Effect (Param Effect) {
Require 'type, publisher and provisioningState are as required' {
Field 'Microsoft.HybridCompute/machines/extensions/type' | Must -Be 'MicrosoftMonitoringAgent'
Field publisher | Must -Be 'Microsoft.EnterpriseCloud.Monitoring'
Field provisioningState | Must -Not -Be 'Failed' -IfPresent
}
Deployment -TemplateFile './templates/69af7d4a-7b18-4044-93a9-2651498ef203.json' -Parameters ([ordered]@{
vmName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
logAnalytics = (Param LogAnalytics)
})
}
}Its deployment templates are written beside it:
templates/69af7d4a-7b18-4044-93a9-2651498ef203.json
Source: built-in-policies/policyDefinitions/Monitoring/LogAnalyticsExtension_Windows_HybridVM_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw