Gallery › Monitoring › Azure built-in policies
Configure Windows Arc Machines to be associated with a Data Collection Rule or a Data Collection Endpoint
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 2.4.0
Deploy Association to link Windows Arc machines to the specified Data Collection Rule or the specified Data Collection Endpoint. The list of locations 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_Arc_Windows_DINE.json · 233 lines
{
"properties": {
"displayName": "Configure Windows Arc Machines to be associated with a Data Collection Rule or a Data Collection Endpoint",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Deploy Association to link Windows Arc machines to the specified Data Collection Rule or the specified Data Collection Endpoint. The list of locations are updated over time as support is increased.",
"metadata": {
"version": "2.4.0",
"category": "Monitoring"
},
"version": "2.4.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy."
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
},
"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": "type",
"equals": "Microsoft.HybridCompute/machines"
},
{
"field": "Microsoft.HybridCompute/machines/osName",
"equals": "Windows"
},
{
"field": "location",
"in": "[parameters('listOfApplicableLocations')]"
}
]
},
"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"
},
"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": "[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": "[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')]"
},
"resourceType": {
"value": "[parameters('resourceType')]"
}
}
}
}
}
}
},
"versions": [
"2.4.0",
"2.3.0",
"2.2.1",
"2.2.0",
"2.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/c24c537f-2516-4c2f-aac5-2cd26baa3d26",
"name": "c24c537f-2516-4c2f-aac5-2cd26baa3d26"
}Bylawc24c537f-2516-4c2f-aac5-2cd26baa3d26.bylaw.ps1 · 65 lines
# Converted from AzureMonitor_DCRA_Arc_Windows_DINE.json by ConvertTo-Bylaw.
Policy 'c24c537f-2516-4c2f-aac5-2cd26baa3d26' {
Properties @{
DisplayName = 'Configure Windows Arc Machines to be associated with a Data Collection Rule or a Data Collection Endpoint'
Description = 'Deploy Association to link Windows Arc machines to the specified Data Collection Rule or the specified Data Collection Endpoint. The list of locations are updated over time as support is increased.'
Version = '2.4.0'
Category = 'Monitoring'
PolicyVersion = '2.4.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy.'
}
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 'Microsoft.HybridCompute/machines' {
When {
Field osName | Must -Be 'Windows'
}
Require 'location is not one of the ListOfApplicableLocations parameter' {
Field location | Must -Not -BeIn (Param ListOfApplicableLocations) -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/c24c537f-2516-4c2f-aac5-2cd26baa3d26.json' -Parameters ([ordered]@{
resourceName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
dcrResourceId = (Param DcrResourceId)
resourceType = (Param ResourceType)
})
}
}Its deployment templates are written beside it:
templates/c24c537f-2516-4c2f-aac5-2cd26baa3d26.json
Source: built-in-policies/policyDefinitions/Monitoring/AzureMonitor_DCRA_Arc_Windows_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw