Set-​Azure​Rm​Diagnostic​Setting

Sets the logs and metrics settings for the resource.

Syntax

Set-AzureRmDiagnosticSetting
   [-Categories <System.Collections.Generic.List`1[System.String]>]
   [-Enabled <Boolean>]
   -ResourceId <String>
   [-RetentionEnabled <Boolean>]
   [-RetentionInDays <Int32>]
   [-ServiceBusRuleId <String>]
   [-StorageAccountId <String>]
   [-Timegrains <System.Collections.Generic.List`1[System.String]>]
   [-WorkspaceId <String>]
   [<CommonParameters>]

Description

The Set-AzureRmDiagnosticSetting cmdlet enables or disables each time grain and log category for the particular resource.

The logs and metrics are stored in the specified storage account.

Examples

Example 1: Enable all metrics and logs for a resource

PS C:\>Set-AzureRmDiagnosticSetting -ResourceId "Resource01" -Enabled $True

This command enables all available metrics and logs for Resource01.

Example 2: Disable all metrics and logs

PS C:\>Set-AzureRmDiagnosticSetting -ResourceId "Resource01" -Enabled $False

This command disables all available metrics and logs for the resource Resource01.

Example 3: Enable multiple categories

PS C:\>Set-AzureRmDiagnosticSetting -ResourceId "Resource01" -Enabled $True -Categories Category1,Category2
StorageAccountId   : <storageAccountId>
StorageAccountName : <storageAccountName>
Metrics
Enabled   : True
Timegrain : PT1M
Enabled   : True
Timegrain : PT1H
Logs
Enabled  : True
Category : Category1
Enabled  : True
Category : Category2
Enabled  : True
Category : Category3
Enabled  : False
Category : Category4

This command enables Category1 and Category2. All timegrains and other categories remain the same.

Example 4: Enable a time grain and multiple categories

PS C:\>Set-AzureRmDiagnosticSetting -ResourceId "Resource01" -Enabled $True -Categories Category1,Category2 -Timegrains PT1M

This command enables only Category1, Category2, and time grain PT1M. All other time grains and categories are unchanged.

Required Parameters

-ResourceId

Specifies the ID of the resource.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-Categories

Specifies the list of log categories to enable or disable, according to the value of Enabled. If you do not specify a category, this command operates on all categories.

Type:System.Collections.Generic.List`1[System.String]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Enabled

Indicates whether to enable diagnostics. Specify $True to enable diagnostics, or $False to disable diagnostics.

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-RetentionEnabled

Indicates whether retention of diagnostic information is enabled.

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-RetentionInDays

Specifies the retention policy, in days.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ServiceBusRuleId
Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-StorageAccountId

Specifies the ID of the Storage account in which to save the data.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Timegrains

Specifies the time grains to enable or disable for metrics, according to the value of Enabled. If you do not specify a time grain, this command operates on all available time grains.

Type:System.Collections.Generic.List`1[System.String]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-WorkspaceId

The Id of the workspace

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False