Azure Alert Rule Creation with PowerShell Azure CLI
Budget: $10 – $30 USD
I have a small very simple project where I need a PowerShell script that creates an Azure Alert rule (azure appinsights) that monitors the CPU for a Azure web app in my resource group group. The alert rule will trigger if CPU goes above 90%. Here are the Azure portal alert rule details for automating this via a PowerShell script using the Azure CLI syntax. Here the settings and how they are configured in the Azure Portal.
Scope:
"webappname-insights" I will replace my web app name in this variable.
I will also replace my subscription and resource group in these two variables.
Condition:
signal name - process CPU
Alert logic
Threshold - static
Aggregation type - Average
operator - Greater Than
Threshold - 95%
When to evaluate
check every - 5 minutes
Loop back period - 5 minutes
Actions:
Use action group that already exists. I will provide the name in this variable.
Details:
Subscription name - this would be the same that is set in the Scope section on top.
Resource group - this would be the same that is set in the Scope section on top.
Alert details
Severity - informational (3)
Alert rule name - I will replace this variable with my alert rule name.
Alert rule description - I will replace this variable with my alert rule description.
Tags:
None, this can be skipped in the script.
Scope:
"webappname-insights" I will replace my web app name in this variable.
I will also replace my subscription and resource group in these two variables.
Condition:
signal name - process CPU
Alert logic
Threshold - static
Aggregation type - Average
operator - Greater Than
Threshold - 95%
When to evaluate
check every - 5 minutes
Loop back period - 5 minutes
Actions:
Use action group that already exists. I will provide the name in this variable.
Details:
Subscription name - this would be the same that is set in the Scope section on top.
Resource group - this would be the same that is set in the Scope section on top.
Alert details
Severity - informational (3)
Alert rule name - I will replace this variable with my alert rule name.
Alert rule description - I will replace this variable with my alert rule description.
Tags:
None, this can be skipped in the script.