Associating DCE, DCR and a VM

Itay Miron 20 Reputation points
2025-03-27T08:38:29.5866667+00:00

I'm trying to automate VM launching and their association to DCR and DCE.

I have used bicep 'Microsoft.Insights/dataCollectionRuleAssociations@2023-03-11', however I'm constantly getting error on data collection endpoint id.

resource dcrAssociation 'Microsoft.Insights/dataCollectionRuleAssociations@2023-03-11' = [for (instance, i) in instances: {
  name: 'configurationAccessEndpoint'
  scope: vm[i]
   properties: {
    dataCollectionRuleId: dataCollectionRule.id
    dataCollectionEndpointId: dataCollectionEndpoint.id
    description: 'DCR Association for VM'
  }
  dependsOn: [
    vm[i]
  ]
}]

Anyone manage to do so?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,561 questions
{count} votes

Accepted answer
  1. Alex Burlachenko 4,065 Reputation points
    2025-03-31T10:36:40.5966667+00:00

    Hi Itay Miron,

    Accordingcode, you're encountering issues with associating VMs to both a DCR and DCE? You cannot associate both DCR and DCE in the same association, a single association can reference either a DCR or DCE, but not both. Choose one based on your monitoring needs.

    My advice is deploy the DCE at first

    resource dce 'Microsoft.Insights/dataCollectionEndpoints@2022-06-01' = {
      name: 'my-dce'
      location: location
      properties: {
        networkAcls: {
          publicNetworkAccess: 'Enabled'
        }
      }
    }
    
    

    then deplot DCR

    resource dcr 'Microsoft.Insights/dataCollectionRules@2022-06-01' = {
      name: 'my-dcr'
      location: location
      properties: {
        dataCollectionEndpointId: dce.id
        // Your rule definitions here
      }
    }
    

    and at the end associate with VMs

    resource vmAssociation 'Microsoft.Insights/dataCollectionRuleAssociations@2022-06-01' = {
      name: 'vm-dcr-association'
      scope: virtualMachine
      properties: {
        dataCollectionRuleId: dcr.id
      }
    }
    
    

    Something like that...

    Verify your API version is current (2022-06-01 is recommended, but I'm not sure for 100%), check that all resources are in the same region, for private links, ensure network permissions are configured.

    Use Azure CLI to validate existing associations

    az monitor data-collection rule association list --resource-group YourRG
    
    

    Best regards,

    Alex

    P.S. If my answer help to you, please Accept my answer

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.