To enable/disable Alert Rule add new Powershell CmdLet
We often have the need to enable or disable Alert Rules programatically with powershell. It seems there is no real cmdLet to set properties of Alert Rules.
In the powershell documentation of Alerts Rules I posted a script with a workarround to enable/disable/toggle alert rules.
Issue can be found here: https://github.com/MicrosoftDocs/azure-docs/issues/5284
The documentation team liked the feedback to create a new CmdLet for this.
Proposal: Set-AzureRmMetricAlertRule to change properties (ie. description, enabled etc.)
Official documentation can be found here:
For Log alerts, the option to enable/disable a rule via PowerShell already exists. For details, see: https://docs.microsoft.com/powershell/module/az.monitor/update-azscheduledqueryrule
Michael Kusmiy commented
Doubt it will ever be implemented in AzureRM as all new features development is frozen there, but in new Powershell Az module for v2 metric alerts now it is possible to do it in pipe which is way simplier than it was before and less prone to errors:
Get-AzMetricAlertRuleV2 -ResourceGroupName alertstest -Name TestAlertRule | Add-AzMetricAlertRuleV2 -DisableRule
Also for v2 alerts now it is possible to disable whole ActionGroup that sends emails for all connected to it Alerts, not a single alert only. It is especially useful when there are hundreds of e-mails on subscription, that is undergoing planned maintenance or product update.
Get-AzActionGroup -ResourceGroup "Default-activityLogAlerts" -Name "actionGroup1" | Set-AzActionGroup -DisableGroup
Also can be done from Azure Portal via new Action Rules
Can someone from the OMS team confirm if this is being considered ?
Be good to see this feature added
When I try to do the workaround I can only get the old "classic" alert rules, so we can't disable/enable the alerts during a deploy. Is there any plans to do a fix for this soon?
Patrick van Ek commented
@Aleksandar a workarround can be found here in the issue:
Aleksandar Dasic commented
Are there any updates on this issue? Plans when can we expect the feature? Or any workarounds until the problem is solved?