Bylaw

Gallery › Monitoring › Azure built-in policies

[Deprecated]: Log Analytics extension should be installed on your Linux Azure Arc machines

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.1.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 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 JSONArc_Linux_LogAnalytics_Audit.json · 70 lines
{
  "properties": {
    "displayName": "[Deprecated]: Log Analytics extension should be installed on your Linux Azure Arc machines",
    "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.1.0-deprecated",
      "category": "Monitoring",
      "deprecated": true
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "AuditIfNotExists",
          "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/imageOffer",
            "like": "linux*"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.HybridCompute/machines/extensions",
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.HybridCompute/machines/extensions/type",
                "equals": "OmsAgentForLinux"
              },
              {
                "field": "Microsoft.HybridCompute/machines/extensions/publisher",
                "equals": "Microsoft.EnterpriseCloud.Monitoring"
              },
              {
                "field": "Microsoft.HybridCompute/machines/extensions/provisioningState",
                "equals": "Succeeded"
              }
            ]
          }
        }
      }
    },
    "versions": [
      "1.1.0",
      "1.0.1-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/842c54e8-c2f9-4d79-ae8d-38d8b8019373",
  "name": "842c54e8-c2f9-4d79-ae8d-38d8b8019373"
}
Bylaw842c54e8-c2f9-4d79-ae8d-38d8b8019373.bylaw.ps1 · 36 lines
# Converted from Arc_Linux_LogAnalytics_Audit.json by ConvertTo-Bylaw.
Policy '842c54e8-c2f9-4d79-ae8d-38d8b8019373' {

    Properties @{
        DisplayName   = '[Deprecated]: Log Analytics extension should be installed on your Linux Azure Arc machines'
        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.1.0-deprecated'
        Category      = 'Monitoring'
        Deprecated    = $true
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.HybridCompute/machines' {

        Require 'imageOffer is not like linux*' {
            Field 'Microsoft.HybridCompute/imageOffer' | Must -Not -BeLike 'linux*' -IfPresent
        }
    }

    AuditIfNotExists 'Microsoft.HybridCompute/machines/extensions' -Effect (Param Effect) {
        Require 'type, publisher and provisioningState are as required' {
            Field 'Microsoft.HybridCompute/machines/extensions/type' | Must -Be 'OmsAgentForLinux'
            Field publisher | Must -Be 'Microsoft.EnterpriseCloud.Monitoring'
            Field provisioningState | Must -Be 'Succeeded'
        }
    }
}

Source: built-in-policies/policyDefinitions/Monitoring/Arc_Linux_LogAnalytics_Audit.json in Azure/azure-policy, under the MIT licence.