Gallery › Monitoring › Azure built-in policies
Deploy Windows Azure Monitor Agent with user-assigned managed identity-based auth and associate with Data Collection Rule
Converted Initiative Version 2.3.0
Monitor your Windows 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_WindowsPlatform_UAI_EnableDCR.json · 213 lines
{
"properties": {
"displayName": "Deploy Windows Azure Monitor Agent with user-assigned managed identity-based auth and associate with Data Collection Rule",
"policyType": "BuiltIn",
"description": "Monitor your Windows 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.3.0",
"category": "Monitoring"
},
"version": "2.3.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 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 Virtual Machine Images",
"description": "List of virtual 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",
"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
]
},
"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')]"
},
"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')]"
},
"userAssignedIdentityName": {
"value": "[parameters('userAssignedManagedIdentityName')]"
},
"identityResourceGroup": {
"value": "[parameters('userAssignedManagedIdentityResourceGroup')]"
},
"builtInIdentityResourceGroupLocation": {
"value": "[parameters('builtInIdentityResourceGroupLocation')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/637125fd-7c39-4b94-bb0a-d331faf333a9",
"definitionVersion": "1.*.*",
"policyDefinitionReferenceId": "deployAzureMonitoringAgentWindowsVMWithUAI",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"bringYourOwnUserAssignedManagedIdentity": {
"value": "[parameters('bringYourOwnUserAssignedManagedIdentity')]"
},
"userAssignedManagedIdentityName": {
"value": "[parameters('userAssignedManagedIdentityName')]"
},
"userAssignedManagedIdentityResourceGroup": {
"value": "[parameters('userAssignedManagedIdentityResourceGroup')]"
},
"scopeToSupportedImages": {
"value": "[parameters('scopeToSupportedImages')]"
},
"listOfWindowsImageIdToInclude": {
"value": "[parameters('listOfWindowsImageIdToInclude')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/98569e20-8f32-4f31-bf34-0e91590ae9d3",
"definitionVersion": "1.*.*",
"policyDefinitionReferenceId": "deployAzureMonitorAgentWindowsVMSSWithUAI",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"bringYourOwnUserAssignedManagedIdentity": {
"value": "[parameters('bringYourOwnUserAssignedManagedIdentity')]"
},
"userAssignedManagedIdentityName": {
"value": "[parameters('userAssignedManagedIdentityName')]"
},
"userAssignedManagedIdentityResourceGroup": {
"value": "[parameters('userAssignedManagedIdentityResourceGroup')]"
},
"scopeToSupportedImages": {
"value": "[parameters('scopeToSupportedImages')]"
},
"listOfWindowsImageIdToInclude": {
"value": "[parameters('listOfWindowsImageIdToInclude')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/eab1f514-22e3-42e3-9a1f-e1dc9199355c",
"definitionVersion": "4.*.*",
"policyDefinitionReferenceId": "associateDataCollectionRuleWindowsWithUAI",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"scopeToSupportedImages": {
"value": "[parameters('scopeToSupportedImages')]"
},
"listOfWindowsImageIdToInclude": {
"value": "[parameters('listOfWindowsImageIdToInclude')]"
},
"dcrResourceId": {
"value": "[parameters('dcrResourceId')]"
},
"resourceType": {
"value": "Microsoft.Insights/dataCollectionRules"
}
}
}
],
"versions": [
"2.3.0",
"2.2.0"
]
},
"id": "/providers/Microsoft.Authorization/policySetDefinitions/0d1b56c6-6d1f-4a5d-8695-b15efbea6b49",
"name": "0d1b56c6-6d1f-4a5d-8695-b15efbea6b49"
}Bylaw0d1b56c6-6d1f-4a5d-8695-b15efbea6b49.bylaw.ps1 · 125 lines
# Converted from AzureMonitor_WindowsPlatform_UAI_EnableDCR.json by ConvertTo-Bylaw.
Initiative '0d1b56c6-6d1f-4a5d-8695-b15efbea6b49' {
Properties @{
DisplayName = 'Deploy Windows Azure Monitor Agent with user-assigned managed identity-based auth and associate with Data Collection Rule'
Description = 'Monitor your Windows 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.3.0'
Category = 'Monitoring'
PolicyVersion = '2.3.0'
}
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 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 Virtual Machine Images'
Description = 'List of virtual 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'
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 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)
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)
userAssignedIdentityName = (Param UserAssignedManagedIdentityName)
identityResourceGroup = (Param UserAssignedManagedIdentityResourceGroup)
builtInIdentityResourceGroupLocation = (Param BuiltInIdentityResourceGroupLocation)
}
}
PolicyDefinition @{
Id = '637125fd-7c39-4b94-bb0a-d331faf333a9'
ReferenceId = 'deployAzureMonitoringAgentWindowsVMWithUAI'
Version = '1.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
bringYourOwnUserAssignedManagedIdentity = (Param BringYourOwnUserAssignedManagedIdentity)
userAssignedManagedIdentityName = (Param UserAssignedManagedIdentityName)
userAssignedManagedIdentityResourceGroup = (Param UserAssignedManagedIdentityResourceGroup)
scopeToSupportedImages = (Param ScopeToSupportedImages)
listOfWindowsImageIdToInclude = (Param ListOfWindowsImageIdToInclude)
}
}
PolicyDefinition @{
Id = '98569e20-8f32-4f31-bf34-0e91590ae9d3'
ReferenceId = 'deployAzureMonitorAgentWindowsVMSSWithUAI'
Version = '1.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
bringYourOwnUserAssignedManagedIdentity = (Param BringYourOwnUserAssignedManagedIdentity)
userAssignedManagedIdentityName = (Param UserAssignedManagedIdentityName)
userAssignedManagedIdentityResourceGroup = (Param UserAssignedManagedIdentityResourceGroup)
scopeToSupportedImages = (Param ScopeToSupportedImages)
listOfWindowsImageIdToInclude = (Param ListOfWindowsImageIdToInclude)
}
}
PolicyDefinition @{
Id = 'eab1f514-22e3-42e3-9a1f-e1dc9199355c'
ReferenceId = 'associateDataCollectionRuleWindowsWithUAI'
Version = '4.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
scopeToSupportedImages = (Param ScopeToSupportedImages)
listOfWindowsImageIdToInclude = (Param ListOfWindowsImageIdToInclude)
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 Windows virtual machines to run Azure Monitor Agent with user-assigned managed identity-based authentication
- Configure Windows virtual machine scale sets to run Azure Monitor Agent with user-assigned managed identity-based authentication
- Configure Windows Machines to be associated with a Data Collection Rule or a Data Collection Endpoint
Source: built-in-policies/policySetDefinitions/Monitoring/AzureMonitor_WindowsPlatform_UAI_EnableDCR.json in Azure/azure-policy, under the MIT licence.
Bylaw