L2.3 β Proactive Operations π΅
π Level 2 Β· Monitor Β· Chapter 3 of 4 Β Β·Β Previous: L2.2 β Operational Visibility Β Β·Β Next: L2.4 β Enterprise Monitoring Strategy
Goal: stop having to look. Six alert rules watch the estate β CPU, database, firewall, dead VMs, error spikes and Azure itself β and mail one inbox when something needs a human.
The IaC lesson: alert rules are resources. Thresholds, evaluation windows and inboxes all live in the template β reviewed, versioned and identical for every classroom β not in portal clicks nobody can audit.
| Who this is for | Time | You need first | Cost while it runs |
|---|---|---|---|
| Chapter 3 of Level 2 Β· everyone | ~20 min | L2.1 and L2.2 | π΅ ~$0.01/hr added Β· ~$1.93/hr running total |
[!IMPORTANT] This chapter creates its own action group. It does not edit the one L1.3 created β two templates owning one resource means whichever deployed last wins. Adding a resource is cheap; sharing ownership is not.
What youβre building
Three kinds of signal feed six rules, and every rule notifies the same action group. A processing rule silences the lot during the nightly maintenance window.
flowchart LR
MET["platform metrics<br/>free, already there"]
LOGS["log data<br/>from L2.1"]
SVC["Azure Service Health"]
RULES["6 alert rules<br/>3 metric Β· 2 log Β· 1 service health"]
AG["ag-iacdemo-oncall<br/>primary + secondary inbox"]
APR["processing rule<br/>02:00β03:00 UTC<br/>suppress everything"]
MET --> RULES
LOGS --> RULES
SVC --> RULES
RULES --> AG
APR -.->|"mutes during<br/>the window"| AG
classDef sig fill:#eef4ff,stroke:#4472c4,color:#1a1a1a
classDef rule fill:#fff9e6,stroke:#c9a227,color:#1a1a1a
classDef act fill:#eefaf0,stroke:#3a9d5d,color:#1a1a1a
class MET,LOGS,SVC sig
class RULES rule
class AG,APR act
Text description of this diagram</summary>
Three signal sources feed six rules, which all notify one action group.
Platform metrics β free, already collected β drive three metric alerts: CPU above 80% across every VM as one multi-resource rule, a dynamic-threshold rule on SQL DTU, and SNAT port utilisation on the firewall.
Log data from L2.1 drives two scheduled query rules. These catch what metrics structurally cannot: a VM that stopped reporting emits no metric to threshold, so only a query over Heartbeat can notice its absence.
Service Health drives a free activity-log alert β the only rule here that fires for something you cannot fix, which is exactly why you want it before you spend an hour debugging your own template.
Everything notifies ag-iacdemo-oncall. The dotted line is the alert processing rule: between 02:00 and 03:00 UTC it strips the action groups off every alert in the resource group, so maintenance does not page anyone.
</details>
Source: curriculum/L2.3-proactive-operations/main.bicep Β· main.bicepparam
π Going deeper β where is autoscale?</summary>
The learning objective is real, but this estate has nowhere honest to put it. Azure Monitor autoscale targets virtual machine scale sets and App Service plans; the only elastic thing here is the container app, and its scale rules live inside curriculum/L1.3-multi-service-application/main.bicep β the template that owns it. Adding them from this chapter would recreate exactly the shared-ownership problem the callout above warns about. Read the scale block in L1.3βs template instead, and change it there.
</details>
π Going deeper β the permissions this needs</summary>

Azure RBAC
Contributor, or Monitoring Contributor on the lab resource group.
Why: alert rules, action groups and processing rules are all ordinary resources. The Service Health alert is scoped to the subscription and needs read access there β with resource-group-only rights it will fail, which is the first place this lab's permission ceiling shows up. 
Microsoft Entra ID roles
None.
Email receivers are plain addresses, not directory objects.
For more info β Azure Monitor roles, permissions and security
</details>
[!NOTE] π« Classroom: use the GitHub Actions option. Your Azure account holds Reader, so local az deployment commands will be refused β deploys go through your forkβs workflow, which uses the workshop deploy identity automatically. Compiling locally (az bicep build) works for everyone.
π Deploy it β pick any one of three ways

1 Β· Bicep CLI
Copy-paste in the terminal 
2 Β· GitHub Actions
One button in the browser 
3 Β· GitHub Copilot
Ask AI in plain English
Β Option 1 Β· Bicep from the terminal
az deployment group what-if --resource-group $env:AZURE_RESOURCE_GROUP --parameters curriculum/L2.3-proactive-operations/main.bicepparam
az deployment group create --resource-group $env:AZURE_RESOURCE_GROUP --parameters curriculum/L2.3-proactive-operations/main.bicepparam
You should see: metricAlertCount 3, logAlertCount 2, and a monthlyAlertCostBasis string spelling out what you just signed up for.
Want a second inbox? Set it before deploying:
$env:ALERT_EMAIL_SECONDARY = "someone.else@example.com"
Β Option 2 Β· GitHub Actions (push-button)
Actions β βCurriculum L2 - Operations & Monitoringβ β Run workflow β L2.3 - Proactive Operations.
The addresses come from repository variables ALERT_EMAIL and ALERT_EMAIL_SECONDARY β the first is the same one the L1.3 lab already uses, so a class that set it once does not set it again.
Β Option 3 Β· GitHub Copilot (plain English)
Load your values first: ./scripts/Load-LabSettings.ps1. Then in Copilot Chat β Agent mode:
Deploy curriculum/L2.3-proactive-operations/main.bicep to my lab resource group ($env:AZURE_RESOURCE_GROUP) with az deployment group create.
Turn one of L2.2βs saved queries into a rule:
In curriculum/L2.3-proactive-operations/main.bicep, add a scheduled query rule that fires when the firewall denies more than 50 flows in 15 minutes, using the same query as the firewall-verdicts saved search in L2.2. Keep the evaluation frequency at PT15M. Run az bicep build, then show me a what-if.
Notice what you had to decide: a threshold, a window, and whether it is worth $0.50 a month. Every one of those is a judgement, not a lookup.
β
Verify it
-
The rules exist and are enabled:
az monitor metrics alert list -g $env:AZURE_RESOURCE_GROUP -o table
az monitor scheduled-query list -g $env:AZURE_RESOURCE_GROUP -o table
You should see: three metric rules (two if you skipped L1.2) and two scheduled query rules.
-
Make one fire β load a VM through Bastion and wait for the window:
sudo apt-get install -y stress-ng && stress-ng --cpu 2 --timeout 900s
You should see: the CPU rule move to Fired within about 15 minutes, and mail at your alert address. The rule averages over 15 minutes on purpose β a one-minute spike is not an incident.
-
Prove the log alert catches what metrics cannot β stop a VM entirely:
az vm deallocate -g $env:AZURE_RESOURCE_GROUP -n "vm-$env:AZURE_PREFIX-web2"
You should see: A VM stopped reporting fire within about 15 minutes. The CPU metric rule stays silent throughout β a VM that is gone emits no metric to threshold. That difference is the whole reason both rule types exist. Start it again with az vm start afterwards.
-
Check the suppression window is real:
az monitor alert-processing-rule list -g $env:AZURE_RESOURCE_GROUP -o table
You should see: apr-<prefix>-maintenance-window, enabled, 02:00β03:00 UTC. Worth saying out loud: during that hour, genuine alerts are swallowed too. Suppression is a governance decision, not a convenience.
-
What it costs: metric alerts bill $0.10 per monitored metric per month; log alerts are $0.50 each at 15-minute evaluation. The set above is about $2.30/month. Service Health and the processing rule are free.
GitHub feature spotlight Β· Repository variables as the notification path
You just used it: ALERT_EMAIL and ALERT_EMAIL_SECONDARY are repository variables, not values baked into a template. The same Bicep deploys to a class of thirty people and pages thirty different inboxes. Find it: Settings β Secrets and variables β Actions β Variables. Note which one is not a secret β an email address is configuration, and treating it as a secret would only make it harder to review. Beyond the lab: the boundary between βsecretβ and βvariableβ is the same boundary as βwho can see the audit logβ β get it wrong in either direction and something either leaks or becomes unreviewable. Docs β
β‘οΈ What carries forward
L2.4 asks the governing question: which of these rules would you keep if you ran a hundred of these environments, and what would you stop collecting? It is the first chapter in the curriculum designed to reduce the bill.
π§ Where next?
Your situation Go to Ready to keep going β make the bill smaller L2.4 β Enterprise Monitoring Strategy β¬
Back to the main path πΊοΈ Curriculum Map Want the big picture of this level Level 2 Β· Monitor overview Done for the day β the estate bills while idle Cleanup & Reset Something didnβt work Troubleshooting
Heartbeat can notice its absence.ag-iacdemo-oncall. The dotted line is the alert processing rule: between 02:00 and 03:00 UTC it strips the action groups off every alert in the resource group, so maintenance does not page anyone.curriculum/L2.3-proactive-operations/main.bicep Β· main.bicepparam π Going deeper β where is autoscale?</summary>
The learning objective is real, but this estate has nowhere honest to put it. Azure Monitor autoscale targets virtual machine scale sets and App Service plans; the only elastic thing here is the container app, and its scale rules live inside curriculum/L1.3-multi-service-application/main.bicep β the template that owns it. Adding them from this chapter would recreate exactly the shared-ownership problem the callout above warns about. Read the scale block in L1.3βs template instead, and change it there.
</details>
π Going deeper β the permissions this needs</summary>

Azure RBAC
Contributor, or Monitoring Contributor on the lab resource group.
Why: alert rules, action groups and processing rules are all ordinary resources. The Service Health alert is scoped to the subscription and needs read access there β with resource-group-only rights it will fail, which is the first place this lab's permission ceiling shows up. 
Microsoft Entra ID roles
None.
Email receivers are plain addresses, not directory objects.
For more info β Azure Monitor roles, permissions and security
</details>
[!NOTE] π« Classroom: use the GitHub Actions option. Your Azure account holds Reader, so local az deployment commands will be refused β deploys go through your forkβs workflow, which uses the workshop deploy identity automatically. Compiling locally (az bicep build) works for everyone.
π Deploy it β pick any one of three ways

1 Β· Bicep CLI
Copy-paste in the terminal 
2 Β· GitHub Actions
One button in the browser 
3 Β· GitHub Copilot
Ask AI in plain English
Β Option 1 Β· Bicep from the terminal
az deployment group what-if --resource-group $env:AZURE_RESOURCE_GROUP --parameters curriculum/L2.3-proactive-operations/main.bicepparam
az deployment group create --resource-group $env:AZURE_RESOURCE_GROUP --parameters curriculum/L2.3-proactive-operations/main.bicepparam
You should see: metricAlertCount 3, logAlertCount 2, and a monthlyAlertCostBasis string spelling out what you just signed up for.
Want a second inbox? Set it before deploying:
$env:ALERT_EMAIL_SECONDARY = "someone.else@example.com"
Β Option 2 Β· GitHub Actions (push-button)
Actions β βCurriculum L2 - Operations & Monitoringβ β Run workflow β L2.3 - Proactive Operations.
The addresses come from repository variables ALERT_EMAIL and ALERT_EMAIL_SECONDARY β the first is the same one the L1.3 lab already uses, so a class that set it once does not set it again.
Β Option 3 Β· GitHub Copilot (plain English)
Load your values first: ./scripts/Load-LabSettings.ps1. Then in Copilot Chat β Agent mode:
Deploy curriculum/L2.3-proactive-operations/main.bicep to my lab resource group ($env:AZURE_RESOURCE_GROUP) with az deployment group create.
Turn one of L2.2βs saved queries into a rule:
In curriculum/L2.3-proactive-operations/main.bicep, add a scheduled query rule that fires when the firewall denies more than 50 flows in 15 minutes, using the same query as the firewall-verdicts saved search in L2.2. Keep the evaluation frequency at PT15M. Run az bicep build, then show me a what-if.
Notice what you had to decide: a threshold, a window, and whether it is worth $0.50 a month. Every one of those is a judgement, not a lookup.
β
Verify it
-
The rules exist and are enabled:
az monitor metrics alert list -g $env:AZURE_RESOURCE_GROUP -o table
az monitor scheduled-query list -g $env:AZURE_RESOURCE_GROUP -o table
You should see: three metric rules (two if you skipped L1.2) and two scheduled query rules.
-
Make one fire β load a VM through Bastion and wait for the window:
sudo apt-get install -y stress-ng && stress-ng --cpu 2 --timeout 900s
You should see: the CPU rule move to Fired within about 15 minutes, and mail at your alert address. The rule averages over 15 minutes on purpose β a one-minute spike is not an incident.
-
Prove the log alert catches what metrics cannot β stop a VM entirely:
az vm deallocate -g $env:AZURE_RESOURCE_GROUP -n "vm-$env:AZURE_PREFIX-web2"
You should see: A VM stopped reporting fire within about 15 minutes. The CPU metric rule stays silent throughout β a VM that is gone emits no metric to threshold. That difference is the whole reason both rule types exist. Start it again with az vm start afterwards.
-
Check the suppression window is real:
az monitor alert-processing-rule list -g $env:AZURE_RESOURCE_GROUP -o table
You should see: apr-<prefix>-maintenance-window, enabled, 02:00β03:00 UTC. Worth saying out loud: during that hour, genuine alerts are swallowed too. Suppression is a governance decision, not a convenience.
-
What it costs: metric alerts bill $0.10 per monitored metric per month; log alerts are $0.50 each at 15-minute evaluation. The set above is about $2.30/month. Service Health and the processing rule are free.
GitHub feature spotlight Β· Repository variables as the notification path
You just used it: ALERT_EMAIL and ALERT_EMAIL_SECONDARY are repository variables, not values baked into a template. The same Bicep deploys to a class of thirty people and pages thirty different inboxes. Find it: Settings β Secrets and variables β Actions β Variables. Note which one is not a secret β an email address is configuration, and treating it as a secret would only make it harder to review. Beyond the lab: the boundary between βsecretβ and βvariableβ is the same boundary as βwho can see the audit logβ β get it wrong in either direction and something either leaks or becomes unreviewable. Docs β
β‘οΈ What carries forward
L2.4 asks the governing question: which of these rules would you keep if you ran a hundred of these environments, and what would you stop collecting? It is the first chapter in the curriculum designed to reduce the bill.
π§ Where next?
Your situation Go to Ready to keep going β make the bill smaller L2.4 β Enterprise Monitoring Strategy β¬
Back to the main path πΊοΈ Curriculum Map Want the big picture of this level Level 2 Β· Monitor overview Done for the day β the estate bills while idle Cleanup & Reset Something didnβt work Troubleshooting
curriculum/L1.3-multi-service-application/main.bicep β the template that owns it. Adding them from this chapter would recreate exactly the shared-ownership problem the callout above warns about. Read the scale block in L1.3βs template instead, and change it there. π Going deeper β the permissions this needs</summary>

Azure RBAC
Contributor, or Monitoring Contributor on the lab resource group.
Why: alert rules, action groups and processing rules are all ordinary resources. The Service Health alert is scoped to the subscription and needs read access there β with resource-group-only rights it will fail, which is the first place this lab's permission ceiling shows up. 
Microsoft Entra ID roles
None.
Email receivers are plain addresses, not directory objects.
For more info β Azure Monitor roles, permissions and security
</details>
[!NOTE] π« Classroom: use the GitHub Actions option. Your Azure account holds Reader, so local az deployment commands will be refused β deploys go through your forkβs workflow, which uses the workshop deploy identity automatically. Compiling locally (az bicep build) works for everyone.
π Deploy it β pick any one of three ways

1 Β· Bicep CLI
Copy-paste in the terminal 
2 Β· GitHub Actions
One button in the browser 
3 Β· GitHub Copilot
Ask AI in plain English
Β Option 1 Β· Bicep from the terminal
az deployment group what-if --resource-group $env:AZURE_RESOURCE_GROUP --parameters curriculum/L2.3-proactive-operations/main.bicepparam
az deployment group create --resource-group $env:AZURE_RESOURCE_GROUP --parameters curriculum/L2.3-proactive-operations/main.bicepparam
You should see: metricAlertCount 3, logAlertCount 2, and a monthlyAlertCostBasis string spelling out what you just signed up for.
Want a second inbox? Set it before deploying:
$env:ALERT_EMAIL_SECONDARY = "someone.else@example.com"
Β Option 2 Β· GitHub Actions (push-button)
Actions β βCurriculum L2 - Operations & Monitoringβ β Run workflow β L2.3 - Proactive Operations.
The addresses come from repository variables ALERT_EMAIL and ALERT_EMAIL_SECONDARY β the first is the same one the L1.3 lab already uses, so a class that set it once does not set it again.
Β Option 3 Β· GitHub Copilot (plain English)
Load your values first: ./scripts/Load-LabSettings.ps1. Then in Copilot Chat β Agent mode:
Deploy curriculum/L2.3-proactive-operations/main.bicep to my lab resource group ($env:AZURE_RESOURCE_GROUP) with az deployment group create.
Turn one of L2.2βs saved queries into a rule:
In curriculum/L2.3-proactive-operations/main.bicep, add a scheduled query rule that fires when the firewall denies more than 50 flows in 15 minutes, using the same query as the firewall-verdicts saved search in L2.2. Keep the evaluation frequency at PT15M. Run az bicep build, then show me a what-if.
Notice what you had to decide: a threshold, a window, and whether it is worth $0.50 a month. Every one of those is a judgement, not a lookup.
β
Verify it
-
The rules exist and are enabled:
az monitor metrics alert list -g $env:AZURE_RESOURCE_GROUP -o table
az monitor scheduled-query list -g $env:AZURE_RESOURCE_GROUP -o table
You should see: three metric rules (two if you skipped L1.2) and two scheduled query rules.
-
Make one fire β load a VM through Bastion and wait for the window:
sudo apt-get install -y stress-ng && stress-ng --cpu 2 --timeout 900s
You should see: the CPU rule move to Fired within about 15 minutes, and mail at your alert address. The rule averages over 15 minutes on purpose β a one-minute spike is not an incident.
-
Prove the log alert catches what metrics cannot β stop a VM entirely:
az vm deallocate -g $env:AZURE_RESOURCE_GROUP -n "vm-$env:AZURE_PREFIX-web2"
You should see: A VM stopped reporting fire within about 15 minutes. The CPU metric rule stays silent throughout β a VM that is gone emits no metric to threshold. That difference is the whole reason both rule types exist. Start it again with az vm start afterwards.
-
Check the suppression window is real:
az monitor alert-processing-rule list -g $env:AZURE_RESOURCE_GROUP -o table
You should see: apr-<prefix>-maintenance-window, enabled, 02:00β03:00 UTC. Worth saying out loud: during that hour, genuine alerts are swallowed too. Suppression is a governance decision, not a convenience.
-
What it costs: metric alerts bill $0.10 per monitored metric per month; log alerts are $0.50 each at 15-minute evaluation. The set above is about $2.30/month. Service Health and the processing rule are free.
GitHub feature spotlight Β· Repository variables as the notification path
You just used it: ALERT_EMAIL and ALERT_EMAIL_SECONDARY are repository variables, not values baked into a template. The same Bicep deploys to a class of thirty people and pages thirty different inboxes. Find it: Settings β Secrets and variables β Actions β Variables. Note which one is not a secret β an email address is configuration, and treating it as a secret would only make it harder to review. Beyond the lab: the boundary between βsecretβ and βvariableβ is the same boundary as βwho can see the audit logβ β get it wrong in either direction and something either leaks or becomes unreviewable. Docs β
β‘οΈ What carries forward
L2.4 asks the governing question: which of these rules would you keep if you ran a hundred of these environments, and what would you stop collecting? It is the first chapter in the curriculum designed to reduce the bill.
π§ Where next?
Your situation Go to Ready to keep going β make the bill smaller L2.4 β Enterprise Monitoring Strategy β¬
Back to the main path πΊοΈ Curriculum Map Want the big picture of this level Level 2 Β· Monitor overview Done for the day β the estate bills while idle Cleanup & Reset Something didnβt work Troubleshooting
| Azure RBAC Contributor, or Monitoring Contributor on the lab resource group. Why: alert rules, action groups and processing rules are all ordinary resources. The Service Health alert is scoped to the subscription and needs read access there β with resource-group-only rights it will fail, which is the first place this lab's permission ceiling shows up. | |
| Microsoft Entra ID roles None. Email receivers are plain addresses, not directory objects. |
[!NOTE] π« Classroom: use the GitHub Actions option. Your Azure account holds Reader, so local az deployment commands will be refused β deploys go through your forkβs workflow, which uses the workshop deploy identity automatically. Compiling locally (az bicep build) works for everyone.
![]() 1 Β· Bicep CLI Copy-paste in the terminal | ![]() 2 Β· GitHub Actions One button in the browser | ![]() 3 Β· GitHub Copilot Ask AI in plain English |
az deployment group what-if --resource-group $env:AZURE_RESOURCE_GROUP --parameters curriculum/L2.3-proactive-operations/main.bicepparam
az deployment group create --resource-group $env:AZURE_RESOURCE_GROUP --parameters curriculum/L2.3-proactive-operations/main.bicepparam
metricAlertCount 3, logAlertCount 2, and a monthlyAlertCostBasis string spelling out what you just signed up for.$env:ALERT_EMAIL_SECONDARY = "someone.else@example.com"
ALERT_EMAIL and ALERT_EMAIL_SECONDARY β the first is the same one the L1.3 lab already uses, so a class that set it once does not set it again../scripts/Load-LabSettings.ps1. Then in Copilot Chat β Agent mode:Deploy curriculum/L2.3-proactive-operations/main.bicep to my lab resource group ($env:AZURE_RESOURCE_GROUP) with az deployment group create.
In curriculum/L2.3-proactive-operations/main.bicep, add a scheduled query rule that fires when the firewall denies more than 50 flows in 15 minutes, using the same query as the firewall-verdicts saved search in L2.2. Keep the evaluation frequency at PT15M. Run az bicep build, then show me a what-if.
The rules exist and are enabled:
az monitor metrics alert list -g $env:AZURE_RESOURCE_GROUP -o table
az monitor scheduled-query list -g $env:AZURE_RESOURCE_GROUP -o table
You should see: three metric rules (two if you skipped L1.2) and two scheduled query rules.
Make one fire β load a VM through Bastion and wait for the window:
sudo apt-get install -y stress-ng && stress-ng --cpu 2 --timeout 900s
You should see: the CPU rule move to Fired within about 15 minutes, and mail at your alert address. The rule averages over 15 minutes on purpose β a one-minute spike is not an incident.
Prove the log alert catches what metrics cannot β stop a VM entirely:
az vm deallocate -g $env:AZURE_RESOURCE_GROUP -n "vm-$env:AZURE_PREFIX-web2"
You should see: A VM stopped reporting fire within about 15 minutes. The CPU metric rule stays silent throughout β a VM that is gone emits no metric to threshold. That difference is the whole reason both rule types exist. Start it again with az vm start afterwards.
Check the suppression window is real:
az monitor alert-processing-rule list -g $env:AZURE_RESOURCE_GROUP -o table
You should see: apr-<prefix>-maintenance-window, enabled, 02:00β03:00 UTC. Worth saying out loud: during that hour, genuine alerts are swallowed too. Suppression is a governance decision, not a convenience.
What it costs: metric alerts bill $0.10 per monitored metric per month; log alerts are $0.50 each at 15-minute evaluation. The set above is about $2.30/month. Service Health and the processing rule are free.
GitHub feature spotlight Β· Repository variables as the notification path
You just used it: ALERT_EMAIL and ALERT_EMAIL_SECONDARY are repository variables, not values baked into a template. The same Bicep deploys to a class of thirty people and pages thirty different inboxes. Find it: Settings β Secrets and variables β Actions β Variables. Note which one is not a secret β an email address is configuration, and treating it as a secret would only make it harder to review. Beyond the lab: the boundary between βsecretβ and βvariableβ is the same boundary as βwho can see the audit logβ β get it wrong in either direction and something either leaks or becomes unreviewable. Docs β
| Your situation | Go to |
|---|---|
| Ready to keep going β make the bill smaller | L2.4 β Enterprise Monitoring Strategy |
| β¬ Back to the main path | πΊοΈ Curriculum Map |
| Want the big picture of this level | Level 2 Β· Monitor overview |
| Done for the day β the estate bills while idle | Cleanup & Reset |
| Something didnβt work | Troubleshooting |