Get-AzDataCollectionRuleAssociation

Gets data collection rule association(s).

Syntax

Get-AzDataCollectionRuleAssociation
      -TargetResourceId <string>
      [-DefaultProfile <IAzureContextContainer>]  
   [<CommonParameters>]
Get-AzDataCollectionRuleAssociation
      -TargetResourceId <string>
      -AssociationName <string>
      [-DefaultProfile <IAzureContextContainer>]   
   [<CommonParameters>]
Get-AzDataCollectionRuleAssociation
      -ResourceGroupName <string>
      -RuleName <string>
      [-DefaultProfile <IAzureContextContainer>]  
   [<CommonParameters>]
Get-AzDataCollectionRuleAssociation
      -InputObject <PSDataCollectionRuleResource>
      [-DefaultProfile <IAzureContextContainer>]  
   [<CommonParameters>]

Description

The Get-AzDataCollectionRuleAssociation cmdlet gets one or more data collection rules associations (DCRA).

To apply a DCR to a virtual machine, you create an association for the virtual machine. A virtual machine may have an association to multiple DCRs, and a DCR may have multiple virtual machines associated to it. This allows you to define a set of DCRs, each matching a particular requirement, and apply them to only the virtual machines where they apply. Here is the "Configure data collection for the Azure Monitor agent" using DCRA article.

Examples

Example 1: Get data collection rules associations by target resource ID (associated virtual machine)

PS C:\>$vm = Get-AzVM -ResourceGroupName $rg -Name $vmName
PS C:\>Get-AzDataCollectionRuleAssociation -TargetResourceId $vm.Id

Description          :
DataCollectionRuleId : /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.I
                       nsights/dataCollectionRules/{dcrName}
ProvisioningState    :
Etag                 : "{etag}"
Id                   : /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.C
                       ompute/virtualMachines/{vmName}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{assocName}
Name                 : {assocName}
Type                 : Microsoft.Insights/dataCollectionRuleAssociations

This command lists all the data collection rules for the given target resource ID (virtual machine).

Example 2: Get data collection rules associations by rule (DCR)

PS C:\>Get-AzDataCollectionRuleAssociation -ResourceGroup $rg -RuleName $dcrName

Description          :
DataCollectionRuleId : /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.I
                       nsights/dataCollectionRules/{dcrName}
ProvisioningState    :
Etag                 : "{etag}"
Id                   : /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.C
                       ompute/virtualMachines/{vmName}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{assocName}
Name                 : {assocName}
Type                 : Microsoft.Insights/dataCollectionRuleAssociations

This command lists data collection rules associations for the given resource group and rule (DCR).

Example 3: Get data collection rule associations by input object (PSDataCollectionRuleResource)

PS C:\>$dcr = Get-AzDataCollectionRule -ResourceGroupName $rg -RuleName $dcrName
PS C:\>$dcr | Get-AzDataCollectionRuleAssociation

Description          :
DataCollectionRuleId : /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.I
                       nsights/dataCollectionRules/{dcrName}
ProvisioningState    :
Etag                 : "{etag}"
Id                   : /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.C
                       ompute/virtualMachines/{vmName}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{assocName}
Name                 : {assocName}
Type                 : Microsoft.Insights/dataCollectionRuleAssociations

This command lists data collection rules associations for the given input object.

Example 4: Get a data collection rule association by target resource ID (associated virtual machine) and association name

PS C:\>Get-AzDataCollectionRuleAssociation -TargetResourceId $vm.Id -AssociationName $assocName

Description          :
DataCollectionRuleId : /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.I
                       nsights/dataCollectionRules/{dcrName}
ProvisioningState    :
Etag                 : "{etag}"
Id                   : /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.C
                       ompute/virtualMachines/{vmName}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{assocName}
Name                 : {assocName}
Type                 : Microsoft.Insights/dataCollectionRuleAssociations

This command lists one (a list with a single element) data collection rule association.

Parameters

-AssociationName

The name of the association.

Type:String
Aliases:Name
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InputObject

PSDataCollectionRuleResource Object

Type:Microsoft.Azure.Commands.Insights.OutputClasses.PSDataCollectionRuleResource
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-ResourceGroupName

The resource group name

Type:String
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-RuleName

The data collection rule name

Type:String
Aliases:DataCollectionRuleName
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TargetResourceId

The associated resource ID

Type:String
Aliases:ResourceUri
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Microsoft.Azure.Commands.Insights.OutputClasses.PSDataCollectionRuleResource

Outputs

Microsoft.Azure.Commands.Insights.OutputClasses.PSDataCollectionRuleAssociationProxyOnlyResource