Bylaw

Gallery › Monitoring › Azure built-in policies

[Deprecated]: Configure Dependency agent on Azure Arc enabled Linux servers

Converted Policy DeployIfNotExists Disabled Mode Indexed Version 2.2.0-deprecated Deprecated

This policy definition is deprecated following the planned retirement of the Dependency Agent on June 30, 2028. The Dependency Agent does not have a replacement, thus no replacement policy is available. For more information, see https://aka.ms/dependencyagentretirement.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONDependencyAgentExtension_Linux_HybridVM_Disabled.json · 127 lines
{
  "properties": {
    "displayName": "[Deprecated]: Configure Dependency agent on Azure Arc enabled Linux servers",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy definition is deprecated following the planned retirement of the Dependency Agent on June 30, 2028. The Dependency Agent does not have a replacement, thus no replacement policy is available. For more information, see https://aka.ms/dependencyagentretirement.",
    "metadata": {
      "version": "2.2.0-deprecated",
      "category": "Monitoring",
      "deprecated": true
    },
    "version": "2.2.0",
    "parameters": {
      "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": "linux"
          }
        ]
      },
      "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": "DependencyAgentLinux"
              },
              {
                "field": "Microsoft.HybridCompute/machines/extensions/publisher",
                "equals": "Microsoft.Azure.Monitoring.DependencyAgent"
              },
              {
                "field": "Microsoft.HybridCompute/machines/extensions/provisioningState",
                "equals": "Succeeded"
              }
            ]
          },
          "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"
                  }
                },
                "variables": {
                  "vmExtensionName": "DependencyAgentLinux",
                  "vmExtensionPublisher": "Microsoft.Azure.Monitoring.DependencyAgent",
                  "vmExtensionType": "DependencyAgentLinux",
                  "vmExtensionTypeHandlerVersion": "9.10"
                },
                "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')]",
                      "typeHandlerVersion": "[variables('vmExtensionTypeHandlerVersion')]",
                      "enableAutomaticUpgrade": true,
                      "autoUpgradeMinorVersion": true,
                      "settings": {}
                    }
                  }
                ],
                "outputs": {
                  "policy": {
                    "type": "string",
                    "value": "[concat('Enabled DA extension for VM', ': ', parameters('vmName'))]"
                  }
                }
              },
              "parameters": {
                "vmName": {
                  "value": "[field('name')]"
                },
                "location": {
                  "value": "[field('location')]"
                }
              }
            }
          }
        }
      }
    },
    "versions": [
      "2.2.0",
      "2.1.0",
      "2.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/deacecc0-9f84-44d2-bb82-46f32d766d43",
  "name": "deacecc0-9f84-44d2-bb82-46f32d766d43"
}
Bylawdeacecc0-9f84-44d2-bb82-46f32d766d43.bylaw.ps1 · 40 lines
# Converted from DependencyAgentExtension_Linux_HybridVM_Disabled.json by ConvertTo-Bylaw.
Policy 'deacecc0-9f84-44d2-bb82-46f32d766d43' {

    Properties @{
        DisplayName   = '[Deprecated]: Configure Dependency agent on Azure Arc enabled Linux servers'
        Description   = 'This policy definition is deprecated following the planned retirement of the Dependency Agent on June 30, 2028. The Dependency Agent does not have a replacement, thus no replacement policy is available. For more information, see https://aka.ms/dependencyagentretirement.'
        Version       = '2.2.0-deprecated'
        Category      = 'Monitoring'
        Deprecated    = $true
        PolicyVersion = '2.2.0'
        Mode          = 'Indexed'
    }

    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 linux' {
            Field osName | Must -Not -Be 'linux' -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 'DependencyAgentLinux'
            Field publisher | Must -Be 'Microsoft.Azure.Monitoring.DependencyAgent'
            Field provisioningState | Must -Be 'Succeeded'
        }
        Deployment -TemplateFile './templates/deacecc0-9f84-44d2-bb82-46f32d766d43.json' -Parameters ([ordered]@{
                vmName   = (Arm '[field(''name'')]')
                location = (Arm '[field(''location'')]')
            })
    }
}

Its deployment templates are written beside it:

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