Gallery › Monitoring › Azure built-in policies
[Deprecated]: Deploy Dependency agent to be enabled on Windows virtual machines with Azure Monitoring Agent settings
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.5.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_VM_Deploy_AMA_Disabled.json · 362 lines
{
"properties": {
"displayName": "[Deprecated]: Deploy Dependency agent to be enabled on Windows virtual machines 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.5.0-deprecated",
"category": "Monitoring",
"deprecated": true
},
"version": "1.5.0",
"parameters": {
"listOfImageIdToInclude": {
"type": "Array",
"defaultValue": [],
"metadata": {
"displayName": "Optional: List of virtual machine images that have supported Windows OS to add to scope",
"description": "Example value: '/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'"
}
},
"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
},
"scopeToSupportedImages": {
"type": "Boolean",
"metadata": {
"displayName": "Scope Policy to Dependency Agent-Supported Operating Systems",
"description": "If set to true, the policy will apply only to virtual machines with supported operating systems. Otherwise, the policy will apply to all virtual machine resources in the assignment scope. For supported operating systems, see https://learn.microsoft.com/azure/azure-monitor/vm/vminsights-dependency-agent-maintenance"
},
"allowedValues": [
true,
false
],
"defaultValue": true
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
{
"value": "[parameters('enableProcessesAndDependencies')]",
"equals": true
},
{
"anyOf": [
{
"allOf": [
{
"value": "[parameters('scopeToSupportedImages')]",
"equals": false
},
{
"field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType",
"like": "Windows*"
}
]
},
{
"field": "Microsoft.Compute/imageId",
"in": "[parameters('listOfImageIdToInclude')]"
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftWindowsServer"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "WindowsServer"
},
{
"field": "Microsoft.Compute/imageSKU",
"in": [
"2008-R2-SP1",
"2008-R2-SP1-smalldisk",
"2012-Datacenter",
"2012-Datacenter-smalldisk",
"2012-R2-Datacenter",
"2012-R2-Datacenter-smalldisk",
"2016-Datacenter",
"2016-Datacenter-smalldisk",
"2016-Datacenter-with-Containers",
"2016-Datacenter-with-RDSH",
"2016-datacenter-gensecond",
"2019-Datacenter",
"2019-Datacenter-smalldisk",
"2019-Datacenter-with-Containers",
"2019-Datacenter-with-Containers-smalldisk",
"2019-Datacenter-zhcn",
"2019-datacenter-gensecond",
"2022-datacenter",
"2022-datacenter-g2",
"2022-datacenter-smalldisk-g2"
]
}
]
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftWindowsServer"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "WindowsServerSemiAnnual"
},
{
"field": "Microsoft.Compute/imageSKU",
"in": [
"Datacenter-Core-1709-smalldisk",
"Datacenter-Core-1709-with-Containers-smalldisk",
"Datacenter-Core-1803-with-Containers-smalldisk"
]
}
]
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftWindowsServerHPCPack"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "WindowsServerHPCPack"
}
]
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftSQLServer"
},
{
"anyOf": [
{
"field": "Microsoft.Compute/imageOffer",
"like": "*-WS2016"
},
{
"field": "Microsoft.Compute/imageOffer",
"like": "*-WS2016-BYOL"
},
{
"field": "Microsoft.Compute/imageOffer",
"like": "*-WS2012R2"
},
{
"field": "Microsoft.Compute/imageOffer",
"like": "*-WS2012R2-BYOL"
}
]
}
]
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftRServer"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "MLServer-WS2016"
}
]
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftVisualStudio"
},
{
"field": "Microsoft.Compute/imageOffer",
"in": [
"VisualStudio",
"Windows"
]
}
]
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftDynamicsAX"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "Dynamics"
},
{
"field": "Microsoft.Compute/imageSKU",
"equals": "Pre-Req-AX7-Onebox-U8"
}
]
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftDynamicsAX"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "Dynamics"
},
{
"field": "Microsoft.Compute/imageSKU",
"equals": "Pre-Req-AX7-Onebox-V4"
}
]
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "microsoft-ads"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "windows-data-science-vm"
}
]
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftWindowsDesktop"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "Windows-10"
}
]
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Compute/virtualMachines/extensions",
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
],
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Compute/virtualMachines/extensions/type",
"equals": "DependencyAgentWindows"
},
{
"field": "Microsoft.Compute/virtualMachines/extensions/publisher",
"equals": "Microsoft.Azure.Monitoring.DependencyAgent"
},
{
"field": "Microsoft.Compute/virtualMachines/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": "DependencyAgentWindows",
"vmExtensionPublisher": "Microsoft.Azure.Monitoring.DependencyAgent",
"vmExtensionType": "DependencyAgentWindows",
"vmExtensionTypeHandlerVersion": "9.10"
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('vmName'), '/', variables('vmExtensionName'))]",
"apiVersion": "2021-04-01",
"location": "[parameters('location')]",
"properties": {
"publisher": "[variables('vmExtensionPublisher')]",
"type": "[variables('vmExtensionType')]",
"typeHandlerVersion": "[variables('vmExtensionTypeHandlerVersion')]",
"enableAutomaticUpgrade": true,
"autoUpgradeMinorVersion": true,
"settings": {
"enableAMA": "true"
}
}
}
],
"outputs": {
"policy": {
"type": "string",
"value": "[concat('Enabled extension for VM', ': ', parameters('vmName'))]"
}
}
},
"parameters": {
"vmName": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
}
}
}
}
}
}
},
"versions": [
"1.5.0",
"1.4.0",
"1.3.0",
"1.2.2"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/89ca9cc7-25cd-4d53-97ba-445ca7a1f222",
"name": "89ca9cc7-25cd-4d53-97ba-445ca7a1f222"
}Bylaw89ca9cc7-25cd-4d53-97ba-445ca7a1f222.bylaw.ps1 · 150 lines
# Converted from DependencyAgentExtension_Windows_VM_Deploy_AMA_Disabled.json by ConvertTo-Bylaw.
Policy '89ca9cc7-25cd-4d53-97ba-445ca7a1f222' {
Properties @{
DisplayName = '[Deprecated]: Deploy Dependency agent to be enabled on Windows virtual machines 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.5.0-deprecated'
Category = 'Monitoring'
Deprecated = $true
PolicyVersion = '1.5.0'
Mode = 'Indexed'
}
Parameter ListOfImageIdToInclude @{
Type = 'Array'
Default = @()
DisplayName = 'Optional: List of virtual machine images that have supported Windows OS to add to scope'
Description = 'Example value: ''/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'''
}
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.'
}
Parameter ScopeToSupportedImages @{
Type = 'Boolean'
AllowedValues = @($true, $false)
Default = $true
DisplayName = 'Scope Policy to Dependency Agent-Supported Operating Systems'
Description = 'If set to true, the policy will apply only to virtual machines with supported operating systems. Otherwise, the policy will apply to all virtual machine resources in the assignment scope. For supported operating systems, see https://learn.microsoft.com/azure/azure-monitor/vm/vminsights-dependency-agent-maintenance'
}
Resource 'Microsoft.Compute/virtualMachines' {
When {
Param EnableProcessesAndDependencies | Must -Be $true
}
Require 'storageProfile.osDisk.osType is as required' {
AnyOf {
Param ScopeToSupportedImages | Must -Not -Be $false
Field storageProfile.osDisk.osType | Must -Not -BeLike 'Windows*' -IfPresent
}
}
Require 'imageId is not one of the ListOfImageIdToInclude parameter' {
Field 'Microsoft.Compute/imageId' | Must -Not -BeIn (Param ListOfImageIdToInclude) -IfPresent
}
Require 'imagePublisher, imageOffer and imageSKU are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsServer' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'WindowsServer' -IfPresent
Field 'Microsoft.Compute/imageSKU' | Must -Not -BeIn @('2008-R2-SP1', '2008-R2-SP1-smalldisk', '2012-Datacenter', '2012-Datacenter-smalldisk', '2012-R2-Datacenter', '2012-R2-Datacenter-smalldisk', '2016-Datacenter', '2016-Datacenter-smalldisk', '2016-Datacenter-with-Containers', '2016-Datacenter-with-RDSH', '2016-datacenter-gensecond', '2019-Datacenter', '2019-Datacenter-smalldisk', '2019-Datacenter-with-Containers', '2019-Datacenter-with-Containers-smalldisk', '2019-Datacenter-zhcn', '2019-datacenter-gensecond', '2022-datacenter', '2022-datacenter-g2', '2022-datacenter-smalldisk-g2') -IfPresent
}
}
Require 'imagePublisher, imageOffer and imageSKU are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsServer' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'WindowsServerSemiAnnual' -IfPresent
Field 'Microsoft.Compute/imageSKU' | Must -Not -BeIn @('Datacenter-Core-1709-smalldisk', 'Datacenter-Core-1709-with-Containers-smalldisk', 'Datacenter-Core-1803-with-Containers-smalldisk') -IfPresent
}
}
Require 'imagePublisher and imageOffer are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsServerHPCPack' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'WindowsServerHPCPack' -IfPresent
}
}
Require 'imagePublisher and imageOffer are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftSQLServer' -IfPresent
AllOf {
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2016' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2016-BYOL' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2012R2' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2012R2-BYOL' -IfPresent
}
}
}
Require 'imagePublisher and imageOffer are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftRServer' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'MLServer-WS2016' -IfPresent
}
}
Require 'imagePublisher and imageOffer are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftVisualStudio' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('VisualStudio', 'Windows') -IfPresent
}
}
Require 'imagePublisher, imageOffer and imageSKU are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftDynamicsAX' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'Dynamics' -IfPresent
Field 'Microsoft.Compute/imageSKU' | Must -Not -Be 'Pre-Req-AX7-Onebox-U8' -IfPresent
}
}
Require 'imagePublisher, imageOffer and imageSKU are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftDynamicsAX' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'Dynamics' -IfPresent
Field 'Microsoft.Compute/imageSKU' | Must -Not -Be 'Pre-Req-AX7-Onebox-V4' -IfPresent
}
}
Require 'imagePublisher and imageOffer are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'microsoft-ads' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'windows-data-science-vm' -IfPresent
}
}
Require 'imagePublisher and imageOffer are as required' {
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsDesktop' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'Windows-10' -IfPresent
}
}
}
DeployIfNotExists 'Microsoft.Compute/virtualMachines/extensions' -Role 'Log Analytics Contributor' -Effect (Param Effect) {
Require 'type, publisher and provisioningState are as required' {
Field 'Microsoft.Compute/virtualMachines/extensions/type' | Must -Be 'DependencyAgentWindows'
Field publisher | Must -Be 'Microsoft.Azure.Monitoring.DependencyAgent'
Field provisioningState | Must -Be 'Succeeded'
}
Deployment -TemplateFile './templates/89ca9cc7-25cd-4d53-97ba-445ca7a1f222.json' -Parameters ([ordered]@{
vmName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/89ca9cc7-25cd-4d53-97ba-445ca7a1f222.json
Source: built-in-policies/policyDefinitions/Monitoring/DependencyAgentExtension_Windows_VM_Deploy_AMA_Disabled.json in Azure/azure-policy, under the MIT licence.
Bylaw