Gallery › Monitoring › Azure built-in policies
Windows virtual machine scale sets should have Azure Monitor Agent installed
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 3.5.0
Windows virtual machine scale sets should be monitored and secured through the deployed Azure Monitor Agent. The Azure Monitor Agent collects telemetry data from the guest OS. Virtual machine scale sets with supported OS and in supported regions are monitored for Azure Monitor Agent deployment. Learn more: https://aka.ms/AMAOverview.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAzureMonitor_Agent_Windows_VMSS_Audit.json · 372 lines
{
"properties": {
"displayName": "Windows virtual machine scale sets should have Azure Monitor Agent installed",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Windows virtual machine scale sets should be monitored and secured through the deployed Azure Monitor Agent. The Azure Monitor Agent collects telemetry data from the guest OS. Virtual machine scale sets with supported OS and in supported regions are monitored for Azure Monitor Agent deployment. Learn more: https://aka.ms/AMAOverview.",
"metadata": {
"version": "3.5.0",
"category": "Monitoring"
},
"version": "3.5.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy."
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
},
"scopeToSupportedImages": {
"type": "Boolean",
"metadata": {
"displayName": "Scope Policy to Azure Monitor Agent-Supported Operating Systems",
"description": "If set to true, the policy will apply only to virtual machine scale sets with supported operating systems. Otherwise, the policy will apply to all virtual machine scale set resources in the assignment scope. For supported operating systems, see https://aka.ms/AMAOverview."
},
"allowedValues": [
true,
false
],
"defaultValue": true
},
"listOfWindowsImageIdToInclude": {
"type": "Array",
"metadata": {
"displayName": "Additional Virtual Machine Images",
"description": "List of virtual machine images that have supported Windows OS to add to scope. Example values: '/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'"
},
"defaultValue": []
},
"listOfApplicableLocations": {
"type": "Array",
"metadata": {
"displayName": "Applicable Locations",
"description": "List of locations where the policy should apply.",
"strongType": "location"
},
"defaultValue": [
"australiacentral",
"australiacentral2",
"australiaeast",
"australiasoutheast",
"brazilsouth",
"brazilsoutheast",
"canadacentral",
"canadaeast",
"centralindia",
"centralus",
"centraluseuap",
"eastasia",
"eastus",
"eastus2",
"eastus2euap",
"francecentral",
"francesouth",
"germanynorth",
"germanywestcentral",
"israelcentral",
"italynorth",
"japaneast",
"japanwest",
"jioindiacentral",
"jioindiawest",
"koreacentral",
"koreasouth",
"malaysiasouth",
"mexicocentral",
"northcentralus",
"northeurope",
"norwayeast",
"norwaywest",
"polandcentral",
"qatarcentral",
"southafricanorth",
"southafricawest",
"southcentralus",
"southeastasia",
"southindia",
"spaincentral",
"swedencentral",
"swedensouth",
"switzerlandnorth",
"switzerlandwest",
"taiwannorth",
"taiwannorthwest",
"uaecentral",
"uaenorth",
"uksouth",
"ukwest",
"westcentralus",
"westeurope",
"westindia",
"westus",
"westus2",
"westus3",
"chilecentral",
"newzealandnorth"
]
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachineScaleSets"
},
{
"field": "location",
"in": "[parameters('listOfApplicableLocations')]"
},
{
"anyOf": [
{
"allOf": [
{
"value": "[parameters('scopeToSupportedImages')]",
"equals": false
},
{
"field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.osDisk.osType",
"like": "Windows*"
}
]
},
{
"field": "Microsoft.Compute/imageId",
"in": "[parameters('listOfWindowsImageIdToInclude')]"
},
{
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftWindowsServer"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "WindowsServer"
},
{
"anyOf": [
{
"field": "Microsoft.Compute/imageSku",
"like": "2008-R2-SP1*"
},
{
"field": "Microsoft.Compute/imageSku",
"like": "2012-*"
},
{
"field": "Microsoft.Compute/imageSku",
"like": "2016-*"
},
{
"field": "Microsoft.Compute/imageSku",
"like": "2019-*"
},
{
"field": "Microsoft.Compute/imageSku",
"like": "2022-*"
},
{
"field": "Microsoft.Compute/imageSku",
"like": "2025-*"
}
]
}
]
},
{
"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": "*-WS2025"
},
{
"field": "Microsoft.Compute/imageOffer",
"like": "*-WS2025-BYOL"
},
{
"field": "Microsoft.Compute/imageOffer",
"like": "*-WS2022"
},
{
"field": "Microsoft.Compute/imageOffer",
"like": "*-WS2022-BYOL"
},
{
"field": "Microsoft.Compute/imageOffer",
"like": "*-WS2019"
},
{
"field": "Microsoft.Compute/imageOffer",
"like": "*-WS2019-BYOL"
},
{
"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": "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/virtualMachineScaleSets/extensions",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Compute/virtualMachineScaleSets/extensions/type",
"equals": "AzureMonitorWindowsAgent"
},
{
"field": "Microsoft.Compute/virtualMachineScaleSets/extensions/publisher",
"equals": "Microsoft.Azure.Monitor"
},
{
"field": "Microsoft.Compute/virtualMachineScaleSets/extensions/provisioningState",
"equals": "Succeeded"
}
]
}
}
}
},
"versions": [
"3.5.0",
"3.4.0",
"3.3.0",
"3.2.0",
"3.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/3672e6f7-a74d-4763-b138-fcf332042f8f",
"name": "3672e6f7-a74d-4763-b138-fcf332042f8f"
}Bylaw3672e6f7-a74d-4763-b138-fcf332042f8f.bylaw.ps1 · 149 lines
# Converted from AzureMonitor_Agent_Windows_VMSS_Audit.json by ConvertTo-Bylaw.
Policy '3672e6f7-a74d-4763-b138-fcf332042f8f' {
Properties @{
DisplayName = 'Windows virtual machine scale sets should have Azure Monitor Agent installed'
Description = 'Windows virtual machine scale sets should be monitored and secured through the deployed Azure Monitor Agent. The Azure Monitor Agent collects telemetry data from the guest OS. Virtual machine scale sets with supported OS and in supported regions are monitored for Azure Monitor Agent deployment. Learn more: https://aka.ms/AMAOverview.'
Version = '3.5.0'
Category = 'Monitoring'
PolicyVersion = '3.5.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy.'
}
Parameter ScopeToSupportedImages @{
Type = 'Boolean'
AllowedValues = @($true, $false)
Default = $true
DisplayName = 'Scope Policy to Azure Monitor Agent-Supported Operating Systems'
Description = 'If set to true, the policy will apply only to virtual machine scale sets with supported operating systems. Otherwise, the policy will apply to all virtual machine scale set resources in the assignment scope. For supported operating systems, see https://aka.ms/AMAOverview.'
}
Parameter ListOfWindowsImageIdToInclude @{
Type = 'Array'
Default = @()
DisplayName = 'Additional Virtual Machine Images'
Description = 'List of virtual machine images that have supported Windows OS to add to scope. Example values: ''/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'''
}
Parameter ListOfApplicableLocations @{
Type = 'Array'
Default = @('australiacentral', 'australiacentral2', 'australiaeast', 'australiasoutheast', 'brazilsouth', 'brazilsoutheast', 'canadacentral', 'canadaeast', 'centralindia', 'centralus', 'centraluseuap', 'eastasia', 'eastus', 'eastus2', 'eastus2euap', 'francecentral', 'francesouth', 'germanynorth', 'germanywestcentral', 'israelcentral', 'italynorth', 'japaneast', 'japanwest', 'jioindiacentral', 'jioindiawest', 'koreacentral', 'koreasouth', 'malaysiasouth', 'mexicocentral', 'northcentralus', 'northeurope', 'norwayeast', 'norwaywest', 'polandcentral', 'qatarcentral', 'southafricanorth', 'southafricawest', 'southcentralus', 'southeastasia', 'southindia', 'spaincentral', 'swedencentral', 'swedensouth', 'switzerlandnorth', 'switzerlandwest', 'taiwannorth', 'taiwannorthwest', 'uaecentral', 'uaenorth', 'uksouth', 'ukwest', 'westcentralus', 'westeurope', 'westindia', 'westus', 'westus2', 'westus3', 'chilecentral', 'newzealandnorth')
DisplayName = 'Applicable Locations'
Description = 'List of locations where the policy should apply.'
Metadata = [ordered]@{ strongType = 'location' }
}
Resource 'Microsoft.Compute/virtualMachineScaleSets' {
When {
Field location | Must -BeIn (Param ListOfApplicableLocations)
}
Require 'virtualMachineProfile.storageProfile.osDisk.osType is as required' {
AnyOf {
Param ScopeToSupportedImages | Must -Not -Be $false
Field virtualMachineProfile.storageProfile.osDisk.osType | Must -Not -BeLike 'Windows*' -IfPresent
}
}
Require 'imageId is not one of the ListOfWindowsImageIdToInclude parameter' {
Field 'Microsoft.Compute/imageId' | Must -Not -BeIn (Param ListOfWindowsImageIdToInclude) -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
AllOf {
Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2008-R2-SP1*' -IfPresent
Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2012-*' -IfPresent
Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2016-*' -IfPresent
Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2019-*' -IfPresent
Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2022-*' -IfPresent
Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2025-*' -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 '*-WS2025' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2025-BYOL' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2022' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2022-BYOL' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2019' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2019-BYOL' -IfPresent
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 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
}
}
}
AuditIfNotExists 'Microsoft.Compute/virtualMachineScaleSets/extensions' -Effect (Param Effect) {
Require 'type, publisher and provisioningState are as required' {
Field 'Microsoft.Compute/virtualMachineScaleSets/extensions/type' | Must -Be 'AzureMonitorWindowsAgent'
Field publisher | Must -Be 'Microsoft.Azure.Monitor'
Field provisioningState | Must -Be 'Succeeded'
}
}
}Source: built-in-policies/policyDefinitions/Monitoring/AzureMonitor_Agent_Windows_VMSS_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw