SOLVED

Update-AzScheduledQueryRule throws exception

Copper Contributor

HI,

 

I need to disable an alert using Update-AzScheduledQueryRule  but it throws AggregateException as below.

 

It works with below alerts which has aggregation

 

customMetrics | where timestamp > ago(15m) and name == 'Heap Memory Used (MB)' and and valueMax >= 35500 | summarize AggregatedValue = max(valueMax) by  bin(timestamp, 1h)

 

it doesn't work with the below alert

 

availabilityResults
| where name contains 'health'
| where success == 0  and message != "Passed"

 

--------------------------------------------------------------------------------------------------------------

Update-AzScheduledQueryRule : Exception type: Exception, Message: System.Exception: Error in updating Log Alert Rule ---> System.AggregateException: One or more errors occurred. ---> Microsoft.Azure.Management.Monit
or.Models.ErrorContractException: Operation returned an invalid status code 'BadRequest'
at Microsoft.Azure.Management.Monitor.ScheduledQueryRulesOperations.<UpdateWithHttpMessagesAsync>d__7.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.Azure.Commands.Insights.ScheduledQueryRules.UpdateScheduledQueryRuleCommand.ProcessRecordInternal()
--- End of inner exception stack trace ---
at Microsoft.Azure.Commands.Insights.ScheduledQueryRules.UpdateScheduledQueryRuleCommand.ProcessRecordInternal()
at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null
At line:1 char:5

Is there a way to disable alerts without modifying the query.

 

Thanks.

3 Replies
Any suggestions on this ?

@CliveWatson , could you help here ?

best response confirmed by Racheal2k (Copper Contributor)
Solution
I'm using Azure Cli to enable / disable alerts
1 best response

Accepted Solutions
best response confirmed by Racheal2k (Copper Contributor)
Solution
I'm using Azure Cli to enable / disable alerts

View solution in original post