Adding Azure WebApp Alert via Powershell Add-AzMetricAlertRuleV2 "Couldn't find a metric"

Erik Stach 96 Reputation points
2021-08-02T14:38:48.92+00:00

I am trying to create alerts for an Azure WebApp using Powershell and the Add-AzMetricAlertRuleV2 call.
While some alerts are created successfully (e.g. RequestsInApplicationQueue) all Metrics starting with "Http" cannot be found:
HttpResponseTime, Http5xx, Http4xx, Http401, Http403, Http404, Http406

I checked if they are available using Get-AzMetricDefinition -MetricNamespace "Microsoft.Web/sites", and the metrics are listed as available there.
However, when I execute Add-AzMetricAlertRuleV2, for all Http* metrics, I get
Exception type: ErrorResponseException, Message: Couldn't find a metric named Http5xx. Make sure the
| name is correct. Activity ID: 36cffdfc-2d44-4b02-9d2c-1dc07b97cae1., Code: BadRequest, Status
| code:BadRequest, Reason phrase: BadRequest

Is this a bug in the Powershell Az Module?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,820 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,387 questions
{count} votes

0 additional answers

Sort by: Most helpful