Lesson 53 — Building Your First Sentinel Automation Rule
Move from automation theory to a working, low-risk Microsoft Sentinel automation rule. Match a lab incident, add a visible tag, verify the outcome and document how to roll back safely.

What you will learn
Configure, test and verify an incident-triggered automation rule.
Lesson 53 — Automate one safe action
In Lesson 52, you planned automation. Now you will create an incident-triggered automation rule in Microsoft Sentinel. The lab action adds a tag to a matching test incident, rather than closing incidents, changing severity or containing an account. The point is to prove the trigger, filter and audit trail before introducing higher-impact actions.
Learning objectives
- Explain what an incident-triggered automation rule evaluates.
- Choose a lab-only matching condition and a non-destructive action.
- Create a rule, set its order and review its enablement and expiration settings.
- Verify both matching and non-matching incidents.
- Use incident history and rule settings to troubleshoot and document the outcome.
The workflow you will build
In this lesson, a successful run means the right incident receives the right tag. It does not mean a threat has been contained.
Step 1 — Understand the scope
Microsoft Sentinel automation rules can respond to supported incident and alert events. This exercise uses the incident created trigger and a deliberately narrow condition. The rule evaluates incident information available at the time of execution; later changes to the incident do not retroactively cause the original creation trigger to run again.
Exact labels and configuration screens can vary between the Azure portal and the Defender portal experience. Follow the available Sentinel automation interface in your tenant.
Step 2 — Prepare a safe lab
- Use an approved test workspace or a controlled lab scenario.
- Confirm you can view incidents and have permission to create or edit Sentinel automation rules.
- Identify an incident source you can safely use for testing.
- Choose a unique tag, such as
AF-LAB-AUTOMATION-53. - Agree how the test incident will be created, and record its incident number.
Important: never generate real malicious activity or modify production incidents merely to complete this exercise.
Step 3 — Choose the matching condition
Use an incident attribute that reliably distinguishes your test incident, such as an approved test analytics-rule name or an incident title prefix, if that condition is offered by your portal. Do not assume every portal exposes identical fields. Keep the match narrow enough that ordinary incidents cannot accidentally satisfy it.
If you cannot create an isolated test incident or reliably filter it, stop at the design exercise rather than enabling the rule against production incidents.
Step 4 — Open Automation
- Open Microsoft Sentinel in your organisation’s supported portal experience.
- Select the intended workspace or Sentinel environment.
- Navigate to Automation and the automation rules area.
- Choose the option to create a new automation rule.
- Confirm the environment before saving any changes.
Use a descriptive name: AF Lab 53 - Tag Test Incidents.
Step 5 — Configure the trigger
- Select the supported trigger for when an incident is created.
- Check which incident types and sources are eligible for that trigger.
- Verify that the test incident will be created after the rule is enabled.
- Record the trigger type in your lab notes.
An existing incident will not generally be reprocessed by a newly created incident-creation rule just because you save the rule.
Step 6 — Add a narrow condition
- Add the condition field that identifies your approved lab incident.
- Enter the exact test value, paying attention to field availability and matching behaviour.
- Review any additional conditions and whether they use AND/OR logic.
- Make sure an unrelated incident should fail the conditions.
For a first lab, a positive match and a negative match are both required to establish confidence.
Step 7 — Add the action
- Choose the built-in action to add a tag to the incident, if available.
- Set the tag value to
AF-LAB-AUTOMATION-53. - Do not add actions that close incidents, modify severity, change ownership or execute playbooks in this lab.
- Review the full rule before enabling it.
Tags make the result easy to inspect and are simpler to reverse than disruptive response actions.
Step 8 — Review order, status and expiration
Automation rules can be ordered, and multiple rules may act on the same incident. Review your rule’s execution order relative to existing rules, especially any that change status or stop processing. If the interface supports an expiration date, use a short lab-appropriate period. Record whether the rule is enabled and when it should be disabled.
Do not change existing production rules to make the lab work.
Step 9 — Save and perform a preflight check
- Correct Sentinel environment selected.
- Rule name clearly identifies it as a lab.
- Trigger is incident creation.
- Condition matches only the intended test incident.
- Only action is adding the lab tag.
- Order, expiration and enablement reviewed.
- Test owner and rollback plan recorded.
Save the rule only after every check passes.
Step 10 — Generate an approved test incident
Use your organisation’s sanctioned lab mechanism, such as a test analytics rule with benign synthetic data or an existing training workflow that creates a fresh incident. Capture the incident number and creation time. The incident must be created after the automation rule becomes active.
Depending on the source and integration configuration, incident creation may occur in Microsoft Defender XDR or Microsoft Sentinel; verify the resulting incident is actually eligible for your selected automation trigger.
Step 11 — Verify the positive match
- Open the newly created test incident.
- Look for the tag
AF-LAB-AUTOMATION-53. - Inspect incident activity/history for the automation change where supported.
- Record the incident number, observed action and timestamp.
- If the tag is absent, do not immediately broaden the rule’s conditions.
A visible tag is an observable result. Use activity/history to strengthen the evidence of how it was applied.
Step 12 — Verify the negative match
With permission, use a separate benign test incident that does not meet the condition. It should not receive the lab tag. If an unrelated incident is tagged, disable the lab rule immediately and review its scope before doing anything else.
Never use unrelated live incidents as an uncontrolled negative test.
Step 13 — Inspect incident evidence with KQL
The following query is a read-only verification aid. It checks the latest known incident record for a tag, where the Labels field is available. It does not prove which automation rule added that tag; incident activity/history provides additional context.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
SecurityIncident
| where TimeGenerated > ago(7d)
| summarize arg_max(TimeGenerated, *) by IncidentNumber
| extend LabelText = tostring(Labels)
| where LabelText contains "AF-LAB-AUTOMATION-53"
| project IncidentNumber, Title, Status,
TimeGenerated, LabelText
| order by TimeGenerated descSome workspaces may expose incident labels differently or not include the expected record. Inspect your actual schema and use the incident UI as the primary verification point.
Step 14 — Troubleshoot a missing tag
| Question | What to check |
|---|---|
| Was the incident new? | Created after rule activation, not merely updated. |
| Did the trigger apply? | Incident source and event type eligible for this rule. |
| Did the condition match? | Actual incident field value, exact comparison and logic. |
| Was the rule active? | Enabled status, expiration and correct environment. |
| Did another rule interfere? | Order, stop-processing behaviour and other rule actions. |
| Was the action permitted? | Role/permissions and any execution errors shown by the platform. |
Step 15 — Document the outcome
| Evidence item | Record |
|---|---|
| Rule name and environment | AF Lab 53 - Tag Test Incidents; lab workspace |
| Trigger and conditions | Exact event and lab-only filter used |
| Action | Add tag: AF-LAB-AUTOMATION-53 |
| Positive test | Incident number, timestamp, observed tag |
| Negative test | Incident number, confirmation no tag applied |
| Rollback | Rule disabled; lab tag removed if appropriate |
Replace the example values with real observations. Never report a test as passed until you have verified it.
Step 16 — Roll back the lab
- Disable or remove the lab automation rule according to your change-control process.
- Confirm it is no longer active.
- Remove the lab tag from test incidents if appropriate and permitted.
- Preserve evidence and notes for future lessons.
Do not leave experimental rules enabled indefinitely.
Step 17 — What comes next?
Adding a tag proves the automation-rule workflow, but more advanced enrichment often needs a Logic Apps playbook. In the next lesson, we will build a first controlled incident-response playbook and discuss connectors, identities, run history and error handling before introducing any impactful response action.
Agent Foskett case file — The overenthusiastic assistant
“Agent Foskett, good news. We automated incident handling.”
“Excellent. What does it do?”
“It closes every incident labelled suspicious.”
Agent Foskett put down his coffee. “And who labels them suspicious?”
“The rule does.”
“So we have automated the investigation and the conclusion?”
“Very efficiently.”
Lesson: start with observable, reversible actions. A successful automation is one that does exactly what was authorised — and nothing else.
Hands-on lab — Your acceptance criteria
- Create a lab-only incident automation rule.
- Use the incident-created trigger and a narrow condition.
- Add only the unique lab tag.
- Observe a matching test incident receive the tag.
- Observe a non-matching test incident remain unchanged.
- Capture activity evidence and any KQL verification.
- Disable the rule and document rollback.
Pass condition: both positive and negative tests behave as expected, with no unintended incident changes.
Knowledge check
- Why should an incident-created rule be tested with a newly created incident?
- Why is a unique tag safer than automatically closing an incident?
- What does a successful negative test demonstrate?
- Why should you check rule order and expiration?
- Can a KQL row containing a tag, by itself, prove which rule added it?
Agent Foskett takeaway
Automate the repeatable action. Verify the trigger. Keep the blast radius small.
Agent Foskett closes the case file: “The rule worked. More importantly, it knew when not to work.”
