Bylaw

Gallery › Monitoring › Azure built-in policies

[Deprecated]: Configure Dependency agent on Azure Arc enabled Windows servers with Azure Monitoring Agent settings

Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.3.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_Windows_HybridVM_Deploy_AMA_Disabled.json · 144 lines
{
  "properties": {
    "displayName": "[Deprecated]: Configure Dependency agent on Azure Arc enabled Windows servers with Azure Monitoring Agent settings",
    "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": "1.3.0-deprecated",
      "category": "Monitoring",
      "deprecated": true
    },
    "version": "1.3.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Deprecated. This parameter is no longer used due to the planned retirement of the Dependency Agent on June 30, 2028. There is no replacement for the Dependency Agent. For more information, see https://aka.ms/dependencyagentretirement."
        }
      },
      "enableProcessesAndDependencies": {
        "type": "Boolean",
        "metadata": {
          "displayName": "Enable Processes and Dependencies",
          "description": "Deprecated. This parameter is no longer used due to the planned retirement of the Dependency Agent on June 30, 2028. There is no replacement for the Dependency Agent. For more information, see https://aka.ms/dependencyagentretirement."
        },
        "allowedValues": [
          true,
          false
        ],
        "defaultValue": false
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.HybridCompute/machines"
          },
          {
            "value": "[parameters('enableProcessesAndDependencies')]",
            "equals": true
          },
          {
            "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": "DependencyAgentWindows"
              },
              {
                "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": {
                  "DaExtensionName": "DependencyAgentWindows",
                  "DaExtensionType": "DependencyAgentWindows",
                  "DaExtensionTypeHandlerVersion": "9.10"
                },
                "resources": [
                  {
                    "type": "Microsoft.HybridCompute/machines/extensions",
                    "apiVersion": "2020-03-11-preview",
                    "name": "[concat(parameters('vmName'), '/', variables('DaExtensionName'))]",
                    "location": "[parameters('location')]",
                    "properties": {
                      "publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
                      "type": "[variables('DaExtensionType')]",
                      "typeHandlerVersion": "[variables('DaExtensionTypeHandlerVersion')]",
                      "enableAutomaticUpgrade": true,
                      "autoUpgradeMinorVersion": true,
                      "settings": {
                        "enableAMA": "true"
                      }
                    }
                  }
                ],
                "outputs": {
                  "policy": {
                    "type": "string",
                    "value": "[concat('Enabled DA extension for VM', ': ', parameters('vmName'))]"
                  }
                }
              },
              "parameters": {
                "vmName": {
                  "value": "[field('name')]"
                },
                "location": {
                  "value": "[field('location')]"
                }
              }
            }
          }
        }
      }
    },
    "versions": [
      "1.3.0",
      "1.2.0",
      "1.1.2"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/84cfed75-dfd4-421b-93df-725b479d356a",
  "name": "84cfed75-dfd4-421b-93df-725b479d356a"
}
Bylaw84cfed75-dfd4-421b-93df-725b479d356a.bylaw.ps1 · 51 lines
# Converted from DependencyAgentExtension_Windows_HybridVM_Deploy_AMA_Disabled.json by ConvertTo-Bylaw.
Policy '84cfed75-dfd4-421b-93df-725b479d356a' {

    Properties @{
        DisplayName   = '[Deprecated]: Configure Dependency agent on Azure Arc enabled Windows servers with Azure Monitoring Agent settings'
        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       = '1.3.0-deprecated'
        Category      = 'Monitoring'
        Deprecated    = $true
        PolicyVersion = '1.3.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('DeployIfNotExists', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Effect'
        Description   = 'Deprecated. This parameter is no longer used due to the planned retirement of the Dependency Agent on June 30, 2028. There is no replacement for the Dependency Agent. For more information, see https://aka.ms/dependencyagentretirement.'
    }
    Parameter EnableProcessesAndDependencies @{
        Type          = 'Boolean'
        AllowedValues = @($true, $false)
        Default       = $false
        DisplayName   = 'Enable Processes and Dependencies'
        Description   = 'Deprecated. This parameter is no longer used due to the planned retirement of the Dependency Agent on June 30, 2028. There is no replacement for the Dependency Agent. For more information, see https://aka.ms/dependencyagentretirement.'
    }

    Resource 'Microsoft.HybridCompute/machines' {

        When {
            Param EnableProcessesAndDependencies | Must -Be $true
        }

        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 'DependencyAgentWindows'
            Field publisher | Must -Be 'Microsoft.Azure.Monitoring.DependencyAgent'
            Field provisioningState | Must -Be 'Succeeded'
        }
        Deployment -TemplateFile './templates/84cfed75-dfd4-421b-93df-725b479d356a.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_Windows_HybridVM_Deploy_AMA_Disabled.json in Azure/azure-policy, under the MIT licence.