Gallery › Monitoring › Azure built-in policies
Configure Linux Arc Machines to be associated with a Data Collection Rule or a Data Collection Endpoint
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 2.2.1
Deploy Association to link Linux 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_Linux_DINE.json · 220 lines
{
"properties": {
"displayName": "Configure Linux Arc Machines to be associated with a Data Collection Rule or a Data Collection Endpoint",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Deploy Association to link Linux 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.2.1",
"category": "Monitoring"
},
"version": "2.2.1",
"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"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.HybridCompute/machines"
},
{
"field": "Microsoft.HybridCompute/machines/osName",
"equals": "linux"
},
{
"field": "location",
"in": [
"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"
]
}
]
},
"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.2.1",
"2.2.0",
"2.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/d5c37ce1-5f52-4523-b949-f19bf945b73a",
"name": "d5c37ce1-5f52-4523-b949-f19bf945b73a"
}Bylawd5c37ce1-5f52-4523-b949-f19bf945b73a.bylaw.ps1 · 58 lines
# Converted from AzureMonitor_DCRA_Arc_Linux_DINE.json by ConvertTo-Bylaw.
Policy 'd5c37ce1-5f52-4523-b949-f19bf945b73a' {
Properties @{
DisplayName = 'Configure Linux Arc Machines to be associated with a Data Collection Rule or a Data Collection Endpoint'
Description = 'Deploy Association to link Linux 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.2.1'
Category = 'Monitoring'
PolicyVersion = '2.2.1'
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' }
}
Resource 'Microsoft.HybridCompute/machines' {
When {
Field osName | Must -Be 'linux'
}
Require 'location is not one of 57 values' {
Field location | Must -Not -BeIn @('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') -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/d5c37ce1-5f52-4523-b949-f19bf945b73a.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/d5c37ce1-5f52-4523-b949-f19bf945b73a.json
Source: built-in-policies/policyDefinitions/Monitoring/AzureMonitor_DCRA_Arc_Linux_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw