Gallery › Monitoring › Azure built-in policies
Deploy Linux Azure Monitor Agent with user-assigned managed identity-based auth and associate with Data Collection Rule
Converted Initiative Version 2.4.0
Monitor your Linux virtual machines and virtual machine scale sets by deploying the Azure Monitor Agent extension with user-assigned managed identity authentication and associating with specified Data Collection Rule. Azure Monitor Agent Deployment will occur on machines with supported OS images (or machines matching the provided list of images) in supported regions.
ConvertTo-Bylaw converted this initiative, and proved that the file compiles back to the same definition.
Azure Policy JSONAzureMonitor_LinuxPlatform_UAI_EnableDCR.json · 238 lines
{
"properties": {
"displayName": "Deploy Linux Azure Monitor Agent with user-assigned managed identity-based auth and associate with Data Collection Rule",
"policyType": "BuiltIn",
"description": "Monitor your Linux virtual machines and virtual machine scale sets by deploying the Azure Monitor Agent extension with user-assigned managed identity authentication and associating with specified Data Collection Rule. Azure Monitor Agent Deployment will occur on machines with supported OS images (or machines matching the provided list of images) in supported regions.",
"metadata": {
"version": "2.4.0",
"category": "Monitoring"
},
"version": "2.4.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect for all constituent policies",
"description": "Enable or disable the execution of each of the constituent policies in the initiative."
},
"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 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
},
"listOfLinuxImageIdToInclude": {
"type": "Array",
"metadata": {
"displayName": "Additional Virtual Machine Images",
"description": "List of virtual machine images that have supported Linux 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",
"description": "Resource Id of the Data Collection Rule that the virtual machines in scope should point to.",
"portalReview": "true"
}
},
"bringYourOwnUserAssignedManagedIdentity": {
"type": "Boolean",
"metadata": {
"displayName": "Bring Your Own User-Assigned Managed Identity",
"description": "If set to true, Azure Monitor Agent will use the user-assigned managed identity specified via the 'User-Assigned Managed Identity ...' parameters for authentication. Otherwise, Azure Monitor Agent will use the user-assigned managed identity /subscriptions/<subscription-id>/resourceGroups/built-in-identity-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/built-in-identity-<location> for authentication."
},
"allowedValues": [
false,
true
]
},
"restrictBringYourOwnUserAssignedIdentityToSubscription": {
"type": "Boolean",
"metadata": {
"displayName": "Restrict Bring Your Own User-Assigned Identity to Subscription",
"description": "Enable this to enforce the user assigned identity must exist in the same subscription as the virtual machine or the virtual machine scale set. When true, must provide User-Assigned Managed Identity Name and User-Assigned Managed Identity Resource Group Name parameters. When false, the parameter User Assigned Managed Identity Resource Id will be used instead."
},
"allowedValues": [
true,
false
],
"defaultValue": true
},
"userAssignedManagedIdentityName": {
"type": "String",
"metadata": {
"displayName": "User-Assigned Managed Identity Name",
"description": "The name of the user-assigned managed identity which Azure Monitor Agent will use for authentication when 'Bring Your Own User-Assigned Managed Identity' is set to true."
},
"defaultValue": ""
},
"userAssignedManagedIdentityResourceGroup": {
"type": "String",
"metadata": {
"displayName": "User-Assigned Managed Identity Resource Group",
"description": "The resource group of the user-assigned managed identity which Azure Monitor Agent will use for authentication when 'Bring Your Own User-Assigned Managed Identity' is set to true."
},
"defaultValue": ""
},
"builtInIdentityResourceGroupLocation": {
"type": "String",
"metadata": {
"displayName": "Built-In-Identity-RG Location",
"description": "The location of the resource group 'Built-In-Identity-RG' created by the initiative. This parameter is only used when 'Bring Your Own User-Assigned Managed Identity' parameter is false."
},
"defaultValue": "eastus"
}
},
"policyDefinitions": [
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/d367bd60-64ca-4364-98ea-276775bddd94",
"definitionVersion": "1.*.*-preview",
"policyDefinitionReferenceId": "addUserAssignedManagedIdentityVM",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"bringYourOwnUserAssignedManagedIdentity": {
"value": "[parameters('bringYourOwnUserAssignedManagedIdentity')]"
},
"restrictBringYourOwnUserAssignedIdentityToSubscription": {
"value": "[parameters('restrictBringYourOwnUserAssignedIdentityToSubscription')]"
},
"userAssignedIdentityName": {
"value": "[parameters('userAssignedManagedIdentityName')]"
},
"identityResourceGroup": {
"value": "[parameters('userAssignedManagedIdentityResourceGroup')]"
},
"builtInIdentityResourceGroupLocation": {
"value": "[parameters('builtInIdentityResourceGroupLocation')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/516187d4-ef64-4a1b-ad6b-a7348502976c",
"definitionVersion": "1.*.*-preview",
"policyDefinitionReferenceId": "addUserAssignedManagedIdentityVMSS",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"bringYourOwnUserAssignedManagedIdentity": {
"value": "[parameters('bringYourOwnUserAssignedManagedIdentity')]"
},
"restrictBringYourOwnUserAssignedIdentityToSubscription": {
"value": "[parameters('restrictBringYourOwnUserAssignedIdentityToSubscription')]"
},
"userAssignedIdentityName": {
"value": "[parameters('userAssignedManagedIdentityName')]"
},
"identityResourceGroup": {
"value": "[parameters('userAssignedManagedIdentityResourceGroup')]"
},
"builtInIdentityResourceGroupLocation": {
"value": "[parameters('builtInIdentityResourceGroupLocation')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/ae8a10e6-19d6-44a3-a02d-a2bdfc707742",
"definitionVersion": "3.*.*",
"policyDefinitionReferenceId": "deployAzureMonitoringAgentLinuxVMWithUAI",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"bringYourOwnUserAssignedManagedIdentity": {
"value": "[parameters('bringYourOwnUserAssignedManagedIdentity')]"
},
"restrictBringYourOwnUserAssignedIdentityToSubscription": {
"value": "[parameters('restrictBringYourOwnUserAssignedIdentityToSubscription')]"
},
"userAssignedManagedIdentityName": {
"value": "[parameters('userAssignedManagedIdentityName')]"
},
"userAssignedManagedIdentityResourceGroup": {
"value": "[parameters('userAssignedManagedIdentityResourceGroup')]"
},
"scopeToSupportedImages": {
"value": "[parameters('scopeToSupportedImages')]"
},
"listOfLinuxImageIdToInclude": {
"value": "[parameters('listOfLinuxImageIdToInclude')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/59c3d93f-900b-4827-a8bd-562e7b956e7c",
"definitionVersion": "3.*.*",
"policyDefinitionReferenceId": "deployAzureMonitorAgentLinuxVMSSWithUAI",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"bringYourOwnUserAssignedManagedIdentity": {
"value": "[parameters('bringYourOwnUserAssignedManagedIdentity')]"
},
"restrictBringYourOwnUserAssignedIdentityToSubscription": {
"value": "[parameters('restrictBringYourOwnUserAssignedIdentityToSubscription')]"
},
"userAssignedManagedIdentityName": {
"value": "[parameters('userAssignedManagedIdentityName')]"
},
"userAssignedManagedIdentityResourceGroup": {
"value": "[parameters('userAssignedManagedIdentityResourceGroup')]"
},
"scopeToSupportedImages": {
"value": "[parameters('scopeToSupportedImages')]"
},
"listOfLinuxImageIdToInclude": {
"value": "[parameters('listOfLinuxImageIdToInclude')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/2ea82cdd-f2e8-4500-af75-67a2e084ca74",
"definitionVersion": "6.*.*",
"policyDefinitionReferenceId": "associateDataCollectionRuleLinuxWithUAI",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"scopeToSupportedImages": {
"value": "[parameters('scopeToSupportedImages')]"
},
"listOfLinuxImageIdToInclude": {
"value": "[parameters('listOfLinuxImageIdToInclude')]"
},
"dcrResourceId": {
"value": "[parameters('dcrResourceId')]"
},
"resourceType": {
"value": "Microsoft.Insights/dataCollectionRules"
}
}
}
],
"versions": [
"2.4.0",
"2.3.0",
"2.2.0"
]
},
"id": "/providers/Microsoft.Authorization/policySetDefinitions/babf8e94-780b-4b4d-abaa-4830136a8725",
"name": "babf8e94-780b-4b4d-abaa-4830136a8725"
}Bylawbabf8e94-780b-4b4d-abaa-4830136a8725.bylaw.ps1 · 136 lines
# Converted from AzureMonitor_LinuxPlatform_UAI_EnableDCR.json by ConvertTo-Bylaw.
Initiative 'babf8e94-780b-4b4d-abaa-4830136a8725' {
Properties @{
DisplayName = 'Deploy Linux Azure Monitor Agent with user-assigned managed identity-based auth and associate with Data Collection Rule'
Description = 'Monitor your Linux virtual machines and virtual machine scale sets by deploying the Azure Monitor Agent extension with user-assigned managed identity authentication and associating with specified Data Collection Rule. Azure Monitor Agent Deployment will occur on machines with supported OS images (or machines matching the provided list of images) in supported regions.'
Version = '2.4.0'
Category = 'Monitoring'
PolicyVersion = '2.4.0'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect for all constituent policies'
Description = 'Enable or disable the execution of each of the constituent policies in the initiative.'
}
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 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 ListOfLinuxImageIdToInclude @{
Type = 'Array'
Default = @()
DisplayName = 'Additional Virtual Machine Images'
Description = 'List of virtual machine images that have supported Linux 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'
Description = 'Resource Id of the Data Collection Rule that the virtual machines in scope should point to.'
Metadata = [ordered]@{ portalReview = 'true' }
}
Parameter BringYourOwnUserAssignedManagedIdentity @{
Type = 'Boolean'
AllowedValues = @($false, $true)
DisplayName = 'Bring Your Own User-Assigned Managed Identity'
Description = 'If set to true, Azure Monitor Agent will use the user-assigned managed identity specified via the ''User-Assigned Managed Identity ...'' parameters for authentication. Otherwise, Azure Monitor Agent will use the user-assigned managed identity /subscriptions/<subscription-id>/resourceGroups/built-in-identity-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/built-in-identity-<location> for authentication.'
}
Parameter RestrictBringYourOwnUserAssignedIdentityToSubscription @{
Type = 'Boolean'
AllowedValues = @($true, $false)
Default = $true
DisplayName = 'Restrict Bring Your Own User-Assigned Identity to Subscription'
Description = 'Enable this to enforce the user assigned identity must exist in the same subscription as the virtual machine or the virtual machine scale set. When true, must provide User-Assigned Managed Identity Name and User-Assigned Managed Identity Resource Group Name parameters. When false, the parameter User Assigned Managed Identity Resource Id will be used instead.'
}
Parameter UserAssignedManagedIdentityName @{
Default = ''
DisplayName = 'User-Assigned Managed Identity Name'
Description = 'The name of the user-assigned managed identity which Azure Monitor Agent will use for authentication when ''Bring Your Own User-Assigned Managed Identity'' is set to true.'
}
Parameter UserAssignedManagedIdentityResourceGroup @{
Default = ''
DisplayName = 'User-Assigned Managed Identity Resource Group'
Description = 'The resource group of the user-assigned managed identity which Azure Monitor Agent will use for authentication when ''Bring Your Own User-Assigned Managed Identity'' is set to true.'
}
Parameter BuiltInIdentityResourceGroupLocation @{
Default = 'eastus'
DisplayName = 'Built-In-Identity-RG Location'
Description = 'The location of the resource group ''Built-In-Identity-RG'' created by the initiative. This parameter is only used when ''Bring Your Own User-Assigned Managed Identity'' parameter is false.'
}
PolicyDefinition @{
Id = 'd367bd60-64ca-4364-98ea-276775bddd94'
ReferenceId = 'addUserAssignedManagedIdentityVM'
Version = '1.*.*-preview'
Parameters = [ordered]@{
effect = (Param Effect)
bringYourOwnUserAssignedManagedIdentity = (Param BringYourOwnUserAssignedManagedIdentity)
restrictBringYourOwnUserAssignedIdentityToSubscription = (Param RestrictBringYourOwnUserAssignedIdentityToSubscription)
userAssignedIdentityName = (Param UserAssignedManagedIdentityName)
identityResourceGroup = (Param UserAssignedManagedIdentityResourceGroup)
builtInIdentityResourceGroupLocation = (Param BuiltInIdentityResourceGroupLocation)
}
}
PolicyDefinition @{
Id = '516187d4-ef64-4a1b-ad6b-a7348502976c'
ReferenceId = 'addUserAssignedManagedIdentityVMSS'
Version = '1.*.*-preview'
Parameters = [ordered]@{
effect = (Param Effect)
bringYourOwnUserAssignedManagedIdentity = (Param BringYourOwnUserAssignedManagedIdentity)
restrictBringYourOwnUserAssignedIdentityToSubscription = (Param RestrictBringYourOwnUserAssignedIdentityToSubscription)
userAssignedIdentityName = (Param UserAssignedManagedIdentityName)
identityResourceGroup = (Param UserAssignedManagedIdentityResourceGroup)
builtInIdentityResourceGroupLocation = (Param BuiltInIdentityResourceGroupLocation)
}
}
PolicyDefinition @{
Id = 'ae8a10e6-19d6-44a3-a02d-a2bdfc707742'
ReferenceId = 'deployAzureMonitoringAgentLinuxVMWithUAI'
Version = '3.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
bringYourOwnUserAssignedManagedIdentity = (Param BringYourOwnUserAssignedManagedIdentity)
restrictBringYourOwnUserAssignedIdentityToSubscription = (Param RestrictBringYourOwnUserAssignedIdentityToSubscription)
userAssignedManagedIdentityName = (Param UserAssignedManagedIdentityName)
userAssignedManagedIdentityResourceGroup = (Param UserAssignedManagedIdentityResourceGroup)
scopeToSupportedImages = (Param ScopeToSupportedImages)
listOfLinuxImageIdToInclude = (Param ListOfLinuxImageIdToInclude)
}
}
PolicyDefinition @{
Id = '59c3d93f-900b-4827-a8bd-562e7b956e7c'
ReferenceId = 'deployAzureMonitorAgentLinuxVMSSWithUAI'
Version = '3.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
bringYourOwnUserAssignedManagedIdentity = (Param BringYourOwnUserAssignedManagedIdentity)
restrictBringYourOwnUserAssignedIdentityToSubscription = (Param RestrictBringYourOwnUserAssignedIdentityToSubscription)
userAssignedManagedIdentityName = (Param UserAssignedManagedIdentityName)
userAssignedManagedIdentityResourceGroup = (Param UserAssignedManagedIdentityResourceGroup)
scopeToSupportedImages = (Param ScopeToSupportedImages)
listOfLinuxImageIdToInclude = (Param ListOfLinuxImageIdToInclude)
}
}
PolicyDefinition @{
Id = '2ea82cdd-f2e8-4500-af75-67a2e084ca74'
ReferenceId = 'associateDataCollectionRuleLinuxWithUAI'
Version = '6.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
scopeToSupportedImages = (Param ScopeToSupportedImages)
listOfLinuxImageIdToInclude = (Param ListOfLinuxImageIdToInclude)
dcrResourceId = (Param DcrResourceId)
resourceType = 'Microsoft.Insights/dataCollectionRules'
}
}
}Members (5)
- [Preview]: Configure Virtual Machines to use Built-In User-Assigned Managed Identity
- [Preview]: Assign Built-In User-Assigned Managed Identity to Virtual Machine Scale Sets
- Configure Linux virtual machines to run Azure Monitor Agent with user-assigned managed identity-based authentication
- Configure Linux virtual machine scale sets to run Azure Monitor Agent with user-assigned managed identity-based authentication
- Configure Linux Machines to be associated with a Data Collection Rule or a Data Collection Endpoint
Source: built-in-policies/policySetDefinitions/Monitoring/AzureMonitor_LinuxPlatform_UAI_EnableDCR.json in Azure/azure-policy, under the MIT licence.
Bylaw