Gallery › Monitoring › Azure built-in policies
Configure Windows Machines to be associated with a Data Collection Rule or a Data Collection Endpoint
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 4.8.0
Deploy Association to link Windows virtual machines, virtual machine scale sets, and Arc machines to the specified Data Collection Rule or the specified Data Collection Endpoint. The list of locations and OS images are updated over time as support is increased.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAzureMonitor_DCRA_Windows_DINE.json · 558 lines
{
"properties": {
"displayName": "Configure Windows Machines to be associated with a Data Collection Rule or a Data Collection Endpoint",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Deploy Association to link Windows virtual machines, virtual machine scale sets, and Arc machines to the specified Data Collection Rule or the specified Data Collection Endpoint. The list of locations and OS images are updated over time as support is increased.",
"metadata": {
"version": "4.8.0",
"category": "Monitoring"
},
"version": "4.8.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy."
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
},
"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 machines with AMA-supported operating systems. Otherwise, the policy will apply to all machines in the assignment scope. For supported operating systems, see https://aka.ms/AMAOverview."
},
"allowedValues": [
true,
false
],
"defaultValue": true
},
"listOfWindowsImageIdToInclude": {
"type": "Array",
"metadata": {
"displayName": "Additional Windows Machine Images",
"description": "List of machine images that have supported Windows OS to add to scope. Example values: '/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'"
},
"defaultValue": []
},
"dcrResourceId": {
"type": "String",
"metadata": {
"displayName": "Data Collection Rule Resource Id or Data Collection Endpoint Resource Id",
"description": "Resource Id of the Data Collection Rule or the Data Collection Endpoint to be applied on the Linux machines in scope.",
"portalReview": "true",
"assignPermissions": true
}
},
"resourceType": {
"type": "String",
"metadata": {
"displayName": "Resource Type",
"description": "Either a Data Collection Rule (DCR) or a Data Collection Endpoint (DCE)",
"portalReview": "true"
},
"allowedValues": [
"Microsoft.Insights/dataCollectionRules",
"Microsoft.Insights/dataCollectionEndpoints"
],
"defaultValue": "Microsoft.Insights/dataCollectionRules"
},
"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": "location",
"in": "[parameters('listOfApplicableLocations')]"
},
{
"anyOf": [
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.HybridCompute/machines"
},
{
"field": "Microsoft.HybridCompute/machines/osName",
"equals": "Windows"
}
]
},
{
"allOf": [
{
"anyOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachineScaleSets"
}
]
},
{
"anyOf": [
{
"allOf": [
{
"value": "[parameters('scopeToSupportedImages')]",
"equals": false
},
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
{
"field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType",
"like": "Windows*"
}
]
},
{
"allOf": [
{
"value": "[parameters('scopeToSupportedImages')]",
"equals": false
},
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachineScaleSets"
},
{
"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",
"Datacenter-Core-1809-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",
"like": "Windows-1*"
}
]
}
]
}
]
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/749f88d5-cbae-40b8-bcfc-e573ddc772fa",
"/providers/microsoft.authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
],
"evaluationDelay": "AfterProvisioning",
"existenceCondition": {
"anyOf": [
{
"field": "Microsoft.Insights/dataCollectionRuleAssociations/dataCollectionRuleId",
"equals": "[parameters('dcrResourceId')]"
},
{
"field": "Microsoft.Insights/dataCollectionRuleAssociations/dataCollectionEndpointId",
"equals": "[parameters('dcrResourceId')]"
}
]
},
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceName": {
"type": "string"
},
"location": {
"type": "string"
},
"dcrResourceId": {
"type": "string"
},
"type": {
"type": "string"
},
"resourceType": {
"type": "string"
}
},
"variables": {
"dcrAssociationName": "[concat('assoc-', uniqueString(concat(parameters('resourceName'), parameters('dcrResourceId'))))]",
"dceAssociationName": "configurationAccessEndpoint",
"dcrResourceType": "Microsoft.Insights/dataCollectionRules",
"dceResourceType": "Microsoft.Insights/dataCollectionEndpoints"
},
"resources": [
{
"condition": "[and(equals(toLower(parameters('type')), 'microsoft.compute/virtualmachines'), equals(parameters('resourceType'), variables('dcrResourceType')))]",
"name": "[variables('dcrAssociationName')]",
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-04-01",
"properties": {
"dataCollectionRuleId": "[parameters('dcrResourceId')]"
},
"scope": "[concat('Microsoft.Compute/virtualMachines/', parameters('resourceName'))]"
},
{
"condition": "[and(equals(toLower(parameters('type')), 'microsoft.compute/virtualmachines'), equals(parameters('resourceType'), variables('dceResourceType')))]",
"name": "[variables('dceAssociationName')]",
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-04-01",
"properties": {
"dataCollectionEndpointId": "[parameters('dcrResourceId')]"
},
"scope": "[concat('Microsoft.Compute/virtualMachines/', parameters('resourceName'))]"
},
{
"condition": "[and(equals(toLower(parameters('type')), 'microsoft.compute/virtualmachinescalesets'), equals(parameters('resourceType'), variables('dcrResourceType')))]",
"name": "[variables('dcrAssociationName')]",
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-04-01",
"properties": {
"dataCollectionRuleId": "[parameters('dcrResourceId')]"
},
"scope": "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('resourceName'))]"
},
{
"condition": "[and(equals(toLower(parameters('type')), 'microsoft.compute/virtualmachinescalesets'), equals(parameters('resourceType'), variables('dceResourceType')))]",
"name": "[variables('dceAssociationName')]",
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-04-01",
"properties": {
"dataCollectionEndpointId": "[parameters('dcrResourceId')]"
},
"scope": "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('resourceName'))]"
},
{
"condition": "[and(equals(toLower(parameters('type')), 'microsoft.hybridcompute/machines'), equals(parameters('resourceType'), variables('dcrResourceType')))]",
"name": "[variables('dcrAssociationName')]",
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-04-01",
"properties": {
"dataCollectionRuleId": "[parameters('dcrResourceId')]"
},
"scope": "[concat('Microsoft.HybridCompute/machines/', parameters('resourceName'))]"
},
{
"condition": "[and(equals(toLower(parameters('type')), 'microsoft.hybridcompute/machines'), equals(parameters('resourceType'), variables('dceResourceType')))]",
"name": "[variables('dceAssociationName')]",
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-04-01",
"properties": {
"dataCollectionEndpointId": "[parameters('dcrResourceId')]"
},
"scope": "[concat('Microsoft.HybridCompute/machines/', parameters('resourceName'))]"
}
]
},
"parameters": {
"resourceName": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
},
"dcrResourceId": {
"value": "[parameters('dcrResourceId')]"
},
"type": {
"value": "[field('type')]"
},
"resourceType": {
"value": "[parameters('resourceType')]"
}
}
}
}
}
}
},
"versions": [
"4.8.0",
"4.7.0",
"4.6.0",
"4.5.1",
"4.5.0",
"4.4.0",
"4.3.0",
"4.2.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/eab1f514-22e3-42e3-9a1f-e1dc9199355c",
"name": "eab1f514-22e3-42e3-9a1f-e1dc9199355c"
}Bylaweab1f514-22e3-42e3-9a1f-e1dc9199355c.bylaw.ps1 · 161 lines
# Converted from AzureMonitor_DCRA_Windows_DINE.json by ConvertTo-Bylaw.
Policy 'eab1f514-22e3-42e3-9a1f-e1dc9199355c' {
Properties @{
DisplayName = 'Configure Windows Machines to be associated with a Data Collection Rule or a Data Collection Endpoint'
Description = 'Deploy Association to link Windows virtual machines, virtual machine scale sets, and Arc machines to the specified Data Collection Rule or the specified Data Collection Endpoint. The list of locations and OS images are updated over time as support is increased.'
Version = '4.8.0'
Category = 'Monitoring'
PolicyVersion = '4.8.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
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 machines with AMA-supported operating systems. Otherwise, the policy will apply to all machines in the assignment scope. For supported operating systems, see https://aka.ms/AMAOverview.'
}
Parameter ListOfWindowsImageIdToInclude @{
Type = 'Array'
Default = @()
DisplayName = 'Additional Windows Machine Images'
Description = 'List of machine images that have supported Windows OS to add to scope. Example values: ''/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'''
}
Parameter DcrResourceId @{
Type = 'String'
DisplayName = 'Data Collection Rule Resource Id or Data Collection Endpoint Resource Id'
Description = 'Resource Id of the Data Collection Rule or the Data Collection Endpoint to be applied on the Linux machines in scope.'
Metadata = [ordered]@{ portalReview = 'true'; assignPermissions = $true }
}
Parameter ResourceType @{
AllowedValues = @('Microsoft.Insights/dataCollectionRules', 'Microsoft.Insights/dataCollectionEndpoints')
Default = 'Microsoft.Insights/dataCollectionRules'
DisplayName = 'Resource Type'
Description = 'Either a Data Collection Rule (DCR) or a Data Collection Endpoint (DCE)'
Metadata = [ordered]@{ portalReview = 'true' }
}
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 * {
When {
Field location | Must -BeIn (Param ListOfApplicableLocations)
}
Require 'type and osName are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.HybridCompute/machines' -IfPresent
Field 'Microsoft.HybridCompute/machines/osName' | Must -Not -Be 'Windows' -IfPresent
}
}
Require 'type, storageProfile.osDisk.osType, virtualMachineProfile.storageProfile.osDisk.osType and 4 more are as required' {
AnyOf {
AllOf {
Field type | Must -Not -Be 'Microsoft.Compute/virtualMachines' -IfPresent
Field type | Must -Not -Be 'Microsoft.Compute/virtualMachineScaleSets' -IfPresent
}
AllOf {
AnyOf {
Param ScopeToSupportedImages | Must -Not -Be $false
Field type | Must -Not -Be 'Microsoft.Compute/virtualMachines' -IfPresent
Field 'Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType' | Must -Not -BeLike 'Windows*' -IfPresent
}
AnyOf {
Param ScopeToSupportedImages | Must -Not -Be $false
Field type | Must -Not -Be 'Microsoft.Compute/virtualMachineScaleSets' -IfPresent
Field 'Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.osDisk.osType' | Must -Not -BeLike 'Windows*' -IfPresent
}
Field 'Microsoft.Compute/imageId' | Must -Not -BeIn (Param ListOfWindowsImageIdToInclude) -IfPresent
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
}
}
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', 'Datacenter-Core-1809-with-Containers-smalldisk') -IfPresent
}
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsServerHPCPack' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'WindowsServerHPCPack' -IfPresent
}
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
}
}
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftRServer' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'MLServer-WS2016' -IfPresent
}
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftVisualStudio' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('VisualStudio', 'Windows') -IfPresent
}
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
}
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'microsoft-ads' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'windows-data-science-vm' -IfPresent
}
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsDesktop' -IfPresent
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'Windows-1*' -IfPresent
}
}
}
}
}
DeployIfNotExists 'Microsoft.Insights/dataCollectionRuleAssociations' -Role 'Monitoring Contributor', 'Log Analytics Contributor' -EvaluationDelay AfterProvisioning -Effect (Param Effect) {
Require 'dataCollectionRuleId and dataCollectionEndpointId are as required' {
AnyOf {
Field dataCollectionRuleId | Must -Be (Param DcrResourceId)
Field dataCollectionEndpointId | Must -Be (Param DcrResourceId)
}
}
Deployment -TemplateFile './templates/eab1f514-22e3-42e3-9a1f-e1dc9199355c.json' -Parameters ([ordered]@{
resourceName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
dcrResourceId = (Param DcrResourceId)
type = (Arm '[field(''type'')]')
resourceType = (Param ResourceType)
})
}
}Its deployment templates are written beside it:
templates/eab1f514-22e3-42e3-9a1f-e1dc9199355c.json
Source: built-in-policies/policyDefinitions/Monitoring/AzureMonitor_DCRA_Windows_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw