Gallery › ChangeTrackingAndInventory › Azure built-in policies
Configure Linux Arc-enabled machines to be associated with a Data Collection Rule for ChangeTracking and Inventory
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.1.0
Deploy Association to link Linux Arc-enabled machines to specified Data Collection Rule to enable ChangeTracking and Inventory. 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 JSONDCRA_Linux_HybridVM_DINE.json · 243 lines
{
"properties": {
"displayName": "Configure Linux Arc-enabled machines to be associated with a Data Collection Rule for ChangeTracking and Inventory",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Deploy Association to link Linux Arc-enabled machines to specified Data Collection Rule to enable ChangeTracking and Inventory. The list of locations are updated over time as support is increased.",
"metadata": {
"version": "1.1.0",
"category": "ChangeTrackingAndInventory"
},
"version": "1.1.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",
"description": "Resource Id of the Data Collection Rule to be applied on the Linux Arc machines in scope."
}
},
"listOfApplicableLocations": {
"type": "Array",
"metadata": {
"displayName": "Applicable Locations",
"description": "The list of locations where the policy should be applied.",
"strongType": "location"
},
"allowedValues": [
"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"
],
"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"
]
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.HybridCompute/machines"
},
{
"field": "location",
"in": "[parameters('listOfApplicableLocations')]"
},
{
"field": "Microsoft.HybridCompute/imageOffer",
"like": "linux*"
}
]
},
"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"
],
"existenceCondition": {
"field": "Microsoft.Insights/dataCollectionRuleAssociations/dataCollectionRuleId",
"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"
}
},
"variables": {
"associationName": "[concat('ct-', uniqueString(parameters('dcrResourceId')))]"
},
"resources": [
{
"name": "[variables('associationName')]",
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-04-01",
"properties": {
"dataCollectionRuleId": "[parameters('dcrResourceId')]"
},
"scope": "[concat('Microsoft.HybridCompute/machines/', parameters('resourceName'))]"
}
]
},
"parameters": {
"resourceName": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
},
"dcrResourceId": {
"value": "[parameters('dcrResourceId')]"
}
}
}
}
}
}
},
"versions": [
"1.1.0",
"1.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/09a1f130-7697-42bc-8d84-8a9ea17e5192",
"name": "09a1f130-7697-42bc-8d84-8a9ea17e5192"
}Bylaw09a1f130-7697-42bc-8d84-8a9ea17e5192.bylaw.ps1 · 54 lines
# Converted from DCRA_Linux_HybridVM_DINE.json by ConvertTo-Bylaw.
Policy '09a1f130-7697-42bc-8d84-8a9ea17e5192' {
Properties @{
DisplayName = 'Configure Linux Arc-enabled machines to be associated with a Data Collection Rule for ChangeTracking and Inventory'
Description = 'Deploy Association to link Linux Arc-enabled machines to specified Data Collection Rule to enable ChangeTracking and Inventory. The list of locations are updated over time as support is increased.'
Version = '1.1.0'
Category = 'ChangeTrackingAndInventory'
PolicyVersion = '1.1.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'
Description = 'Resource Id of the Data Collection Rule to be applied on the Linux Arc machines in scope.'
}
Parameter ListOfApplicableLocations @{
Type = 'Array'
AllowedValues = @('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')
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')
DisplayName = 'Applicable Locations'
Description = 'The list of locations where the policy should be applied.'
Metadata = [ordered]@{ strongType = 'location' }
}
Resource 'Microsoft.HybridCompute/machines' {
When {
Field location | Must -BeIn (Param ListOfApplicableLocations)
}
Require 'imageOffer is not like linux*' {
Field 'Microsoft.HybridCompute/imageOffer' | Must -Not -BeLike 'linux*' -IfPresent
}
}
DeployIfNotExists 'Microsoft.Insights/dataCollectionRuleAssociations' -Role 'Monitoring Contributor', 'Log Analytics Contributor' -Effect (Param Effect) {
Require 'dataCollectionRuleId is the DcrResourceId parameter' {
Field dataCollectionRuleId | Must -Be (Param DcrResourceId)
}
Deployment -TemplateFile './templates/09a1f130-7697-42bc-8d84-8a9ea17e5192.json' -Parameters ([ordered]@{
resourceName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
dcrResourceId = (Param DcrResourceId)
})
}
}Its deployment templates are written beside it:
templates/09a1f130-7697-42bc-8d84-8a9ea17e5192.json
Source: built-in-policies/policyDefinitions/ChangeTrackingAndInventory/DCRA_Linux_HybridVM_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw