首页 > 解决方案 > 无法通过 Azure FrontDoor WAF 策略中的 powershell 获取 Get-AzDiagnosticSetting。这是否允许我们获取诊断设置?

问题描述

Get-AzDiagnosticSetting:异常类型:ErrorResponseException,消息:Microsoft.Azure.Management.Monitor.Models.ErrorResponseException:操作在 Microsoft.Azure.Management.Monitor.DiagnosticSettingsOperations.d__8.MoveNext() 处返回了无效状态代码“BadRequest”-- - 从先前引发异常的位置结束堆栈跟踪 --- 在 Microsoft.Azure.Management.Monitor 的 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 的 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()。 DiagnosticSettingsOperationsExtensions.d__7.MoveNext() --- 在 System.Runtime.CompilerServices.TaskAwaiter 的 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 处从先前引发异常的位置结束堆栈跟踪。在 Microsoft.Azure.Commands.Insights.Diagnostics.GetAzureRmDiagnosticSettingCommand.ProcessRecordInternal() 在 Microsoft.Azure.Commands.Insights.MonitorCmdletBase .ExecuteCmdlet(),代码:Null,状态码:Null,原因短语:Null At C:\Users\n1542975\Desktop\MigrationScripts\WAF_Policy.ps1:121 char:26原因短语:Null At C:\Users\n1542975\Desktop\MigrationScripts\WAF_Policy.ps1:121 char:26原因短语:Null At C:\Users\n1542975\Desktop\MigrationScripts\WAF_Policy.ps1:121 char:26

标签: azurepowershellazure-waf

解决方案


是的,使用“Get-AzDiagnosticSetting”cmdlet,您可以获取特定资源的诊断设置。我们使用远程 PowerShell 和 Azure CLI 运行以下命令来获取前门的诊断设置。AzureCLI Cmdlet:

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

以下是供参考的示例输出:

在此处输入图像描述

电源外壳 Cmdlet:

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

这是供参考的示例输出:

在此处输入图像描述

您可以参考以下 Azure 文档,了解有关PowerShellAzure CLI语法的更多信息。


推荐阅读