0

Get-AzDiagnosticSetting : Exception type: ErrorResponseException, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseException: Operation returned an invalid status code 'BadRequest' at Microsoft.Azure.Management.Monitor.DiagnosticSettingsOperations.d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.Monitor.DiagnosticSettingsOperationsExtensions.d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.Monitor.DiagnosticSettingsOperationsExtensions.List(IDiagnosticSettingsOperations operations, String resourceUri) at Microsoft.Azure.Commands.Insights.Diagnostics.GetAzureRmDiagnosticSettingCommand.ProcessRecordInternal() at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null At C:\Users\n1542975\Desktop\MigrationScripts\WAF_Policy.ps1:121 char:26

  • ... gsettings = Get-AzDiagnosticSetting -ResourceID $FrontDoorWAFPolicyNa ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : CloseError: (:) [Get-AzDiagnosticSetting], PSInvalidOperationException
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.Insights.Diagnostics.GetAzureRmDiagnosticSettingCommand

1 Answers1

0

Yes using 'Get-AzDiagnosticSetting' cmdlet you can fetch the diagnostic setting of a particular resource. We have Ran the below commands to fetch the diagnostics settings for the front door using remote PowerShell & from Azure CLI. AzureCLI Cmdlet:

az monitor diagnostic-settings show --resource-group <resource-group> --resource <resource-name> --resource-type Microsoft.Network/frontdoors --name <diagnosticsettingname>

Here is the sample output for reference:

enter image description here

Power Shell Cmdlet :

Get-AzDiagnosticSetting -ResourceId <resourceId> -Name <diagnosticsettingName>

Here is the sample output for reference :

enter image description here

You can refer the below Azure documentation for more information about the syntaxes for PowerShell & Azure CLI.

VenkateshDodda
  • 4,723
  • 1
  • 3
  • 12
  • Encouraged by your post, I tried `Get-AzDiagnosticSetting` and `Set-AzDiagnosticSetting` on an Azure Automation account. Tried the CLI too. But, neither worked. MS has accepted this to be a bug. https://github.com/Azure/azure-powershell/issues/18334 – Sau001 May 30 '22 at 20:05