[Insights] Set-AzureRMDiagnosticSetting requires explicit specification of categories during creation of setting
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.
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.
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.