How to Create an Azure Monitor Alert – Step-by-Step
We will create a simple CPU Usage Alert for an Azure Virtual Machine (VM) using the Azure Portal.
This practical example will help you understand how an alert works, how to configure an Action Group, and how to test the alert.
1. Example Scenario
Suppose you have an Azure Virtual Machine hosting an ASP.NET Core application.
You want Azure to automatically send an email whenever the VM's CPU usage exceeds 80%.
Our Alert Configuration
|
Setting |
Value |
|---|---|
|
Resource |
Azure Virtual Machine |
|
Signal |
Percentage CPU |
|
Condition |
Greater than 80% |
|
Aggregation |
Average |
|
Lookback period |
5 minutes |
|
Evaluation frequency |
1 minute |
|
Severity |
2 – Warning |
|
Notification |
|
|
Alert type |
Stateful |
Expected behavior: If average CPU usage exceeds 80% during the configured five-minute window, Azure Monitor evaluates the condition and fires an alert. The Action Group sends an email notification.
2. Prerequisites
Before starting, you need:
-
An active Azure subscription.
-
An existing Azure Virtual Machine (Windows or Linux).
-
Permission to create alert rules and Action Groups.
-
An email address to receive notifications.
Note: You do not need a Log Analytics Workspace or Data Collection Rule for this basic VM CPU metric alert. The VM publishes the Percentage CPU platform metric directly to Azure Monitor.
3. Step-by-Step: Create the Alert in Azure Portal
The screenshots below are from Microsoft's Azure Monitor documentation. The portal layout may vary slightly.
Step 1: Open Azure Monitor
-
Go to portal.azure.com.
-
Sign in with your Azure account.
-
In the search bar, type Monitor.
-
Select Monitor.
-
From the left navigation menu, select Alerts.
-
Click + Create → Alert rule.
Alternatively, open your virtual machine and select Monitoring → Alerts → Create → Alert rule. This automatically selects the VM as the resource to monitor.
Step 2: Select the Resource (Scope)
The Scope determines which Azure resource you want to monitor.
-
Open the Scope tab.
-
Click Select scope, if no resource is already selected.
-
Select your subscription.
-
Filter by resource type Virtual machines.
-
Select your VM, for example
vm-demo-01. -
Click Apply.
The alert rule will now monitor the selected virtual machine.
Step 3: Configure the Alert Condition
This is the most important step because it determines when Azure fires an alert.
-
Select the Condition tab.
-
Click Signal name.
-
Search for
Percentage CPU. -
Select the Percentage CPU metric.
Configure the following values:
|
Field |
Select |
|---|---|
|
Threshold |
Static |
|
Aggregation type |
Average |
|
Operator |
Greater than |
|
Threshold value |
80 |
|
Check every |
1 minute |
|
Lookback period |
5 minutes |
How does this work?
10:00 AM
CPU = 45%
|
v
10:01 AM
CPU = 60%
|
v
10:02 AM
CPU = 85%
|
v
10:03 AM
CPU = 90%
|
v
10:04 AM
CPU = 95%
|
v
Average CPU = 75%
|
v
75% > 80% ?
|
v
NO ALERT
Although CPU usage exceeded 80% at some points, the average across this illustrative five-minute window is only 75%.
If the average exceeds 80%, the condition becomes true and Azure can fire the alert.
Step 4: Create an Action Group
An Action Group defines what Azure should do when the alert fires.
For our example, we want to receive an email.
-
Select the Actions tab.
-
Click Select action groups.
-
Click Create action group.
Enter the following details:
|
Field |
Example |
|---|---|
|
Subscription |
Your subscription |
|
Resource group |
Your resource group |
|
Action group name |
|
|
Display name |
|
Next, open the Notifications tab.
-
Click Add notification.
-
Choose Email/SMS message/Push/Voice.
-
Select Email.
-
Enter your email address.
-
Give the notification a name, such as
AdminEmail. -
Confirm the notification settings.
Select Review + create, then Create.
Return to the alert rule wizard and make sure ag-cpu-alert is selected.
Step 5: Configure Alert Details
Open the Details tab.
Enter these values:
|
Field |
Example |
|---|---|
|
Alert rule name |
|
|
Description |
Alert when average CPU exceeds 80% |
|
Severity |
2 – Warning |
|
Enable upon creation |
Checked |
|
Automatically resolve alerts |
Checked |
The last option controls whether this metric alert is stateful.
-
Checked: Stateful alert.
-
Unchecked: Stateless alert.
For this example, keep Automatically resolve alerts checked.
Step 6: Review and Create
-
Select Review + create.
-
Verify the selected resource, condition, and Action Group.
-
Wait for validation to complete.
-
Click Create.
Your alert rule is now created.
4. How to Test the Azure Alert
You can test the rule without deliberately overloading your VM.
Method 1: Temporarily Lower the CPU Threshold
-
Open Azure Monitor → Alerts → Alert rules.
-
Select
High-CPU-Alert. -
Click Edit.
-
Open the Condition tab.
-
Change the threshold from
80to1(or another value below your VM's observed CPU average). -
Save the changes.
-
Wait for the next metric evaluations.
If the VM's average CPU usage exceeds the temporary threshold, the alert should fire.
Example Test Result
4.5%
1%
Condition met — alert expected to fire
After testing, change the threshold back to 80%.
Method 2: Verify the Email Notification
When the alert fires, the Action Group sends an email to the configured recipient.
The email typically contains information such as:
Azure Monitor Alert
Alert Name : High-CPU-Alert
Severity : Sev 2
Resource : vm-demo-01
Metric : Percentage CPU
Threshold : Greater than 80%
Condition : Fired
The exact email format depends on the notification configuration.
Method 3: Verify in Azure Monitor
-
Open Azure Portal → Monitor.
-
Select Alerts.
-
Filter by your subscription and VM.
-
Select the fired alert.
-
Inspect its condition, severity, resource, and history.
5. Test Stateful vs Stateless Alerts
After creating the alert, you can compare both behaviors by editing the same rule.
Interactive alert behavior example
CPU stays above 80% during four successive evaluations.
Fired
Active
Active
Active
One firing for the ongoing incident
The alert remains active and does not repeatedly fire for the same condition.
6. Common Issues
|
Issue |
Possible reason |
|---|---|
|
Alert not firing |
Threshold not met, insufficient metric data, or rule disabled |
|
Email not received |
Incorrect Action Group or notification configuration |
|
CPU metric not available |
VM recently created; metrics may take time to appear |
|
Alert keeps firing |
Stateless mode enabled |
|
Alert not resolving |
Recovery criteria not yet met |
|
Unable to create alert |
Insufficient Azure RBAC permissions |
7. Cleanup After Testing
Azure Monitor metric alert rules can incur charges. When you finish the exercise, delete the test alert if it is no longer needed.
Navigate to Monitor → Alerts → Alert rules, select High-CPU-Alert, and delete it. You can also delete the test Action Group if it is not used elsewhere.
For the official portal screenshots and detailed Microsoft instructions, refer to:
Final result: You have configured a stateful Azure Monitor metric alert that checks VM CPU usage every minute, evaluates the previous five minutes of data, and sends an email through an Action Group when the average exceeds 80%.