azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

[Insights] Set-AzureRMDiagnosticSetting requires explicit specification of categories during creation of setting

Open gucalder opened this issue 8 years ago • 2 comments

Description

Set-AzureRMDiagnosticSetting requires explicit specification of categories during creation of setting. If the list of categories is not included, the cmdlet does not report any error, but the backend will ignore the request since it is enabling no category.

Script/Steps for Reproduction

Run the following command using the SDK version 6.9. For previous versions and exception could be thrown.

Set-AzureRmDiagnosticSetting -resource <resourceId> -storage <resourceId> -Enabled $true

Module Version

Get-Module -ListAvailable

Environment Data

$PSVersionTable

Debug Output

Wait for some minutes and check whether the setting was created. It is not created despite of the command not showing any error.

gucalder avatar Oct 11 '18 00:10 gucalder

As a workaround, add -Categories <System.Collections.Generic.List`1[System.String]> Example:

[Array]$Categories = "JobLogs", "JobStreams", "DscNodeStatus"

Set-AzureRmDiagnosticSetting -ResourceId $AutomationAccountResourceID -WorkspaceId $OMSWorkspaceResourceID -Enabled $true -RetentionEnabled $true -RetentionInDays $LogRetentionInDays -Categories $Categories -ErrorAction 'Stop'

I tested this with version 5.1.4 and it works for new settings as well as updating existing settings.

RichShillingtonMSFT avatar Oct 18 '18 17:10 RichShillingtonMSFT

The fix for this issue has been merged: https://github.com/Azure/azure-powershell/pull/7619 It will be available in the next release of AzureRM/Az.

MiYanni avatar Oct 23 '18 19:10 MiYanni