Agent Foskett Academy • Microsoft Sentinel • Module 6 • Lesson 53

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.

Module 6 — SOC Automation and Response • Hands-on incident automation
Agent Foskett Microsoft Sentinel SOC automation and response academy
What you will learn

Configure, test and verify an incident-triggered automation rule.

✓ Trigger and conditions
✓ Safe incident tagging
✓ Rule order and expiration
✓ Test, audit and rollback

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

NEW SENTINEL INCIDENT ↓ RULE ENABLED + TRIGGER MATCHES? ↓ CONDITIONS MATCH LAB INCIDENT? ↙ ↘ YES NO ↓ ↓ ADD LAB TAG NO ACTION ↓ VERIFY INCIDENT HISTORY ↓ DOCUMENT + DISABLE LAB RULE

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

  1. Use an approved test workspace or a controlled lab scenario.
  2. Confirm you can view incidents and have permission to create or edit Sentinel automation rules.
  3. Identify an incident source you can safely use for testing.
  4. Choose a unique tag, such as AF-LAB-AUTOMATION-53.
  5. 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

  1. Open Microsoft Sentinel in your organisation’s supported portal experience.
  2. Select the intended workspace or Sentinel environment.
  3. Navigate to Automation and the automation rules area.
  4. Choose the option to create a new automation rule.
  5. Confirm the environment before saving any changes.

Use a descriptive name: AF Lab 53 - Tag Test Incidents.

Step 5 — Configure the trigger

  1. Select the supported trigger for when an incident is created.
  2. Check which incident types and sources are eligible for that trigger.
  3. Verify that the test incident will be created after the rule is enabled.
  4. 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

  1. Add the condition field that identifies your approved lab incident.
  2. Enter the exact test value, paying attention to field availability and matching behaviour.
  3. Review any additional conditions and whether they use AND/OR logic.
  4. 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

  1. Choose the built-in action to add a tag to the incident, if available.
  2. Set the tag value to AF-LAB-AUTOMATION-53.
  3. Do not add actions that close incidents, modify severity, change ownership or execute playbooks in this lab.
  4. 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

  1. Open the newly created test incident.
  2. Look for the tag AF-LAB-AUTOMATION-53.
  3. Inspect incident activity/history for the automation change where supported.
  4. Record the incident number, observed action and timestamp.
  5. 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.

Inspect recent incident labels
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 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 desc

Some 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

QuestionWhat 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 itemRecord
Rule name and environmentAF Lab 53 - Tag Test Incidents; lab workspace
Trigger and conditionsExact event and lab-only filter used
ActionAdd tag: AF-LAB-AUTOMATION-53
Positive testIncident number, timestamp, observed tag
Negative testIncident number, confirmation no tag applied
RollbackRule 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

  1. Disable or remove the lab automation rule according to your change-control process.
  2. Confirm it is no longer active.
  3. Remove the lab tag from test incidents if appropriate and permitted.
  4. 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

  1. Create a lab-only incident automation rule.
  2. Use the incident-created trigger and a narrow condition.
  3. Add only the unique lab tag.
  4. Observe a matching test incident receive the tag.
  5. Observe a non-matching test incident remain unchanged.
  6. Capture activity evidence and any KQL verification.
  7. Disable the rule and document rollback.

Pass condition: both positive and negative tests behave as expected, with no unintended incident changes.

Knowledge check

  1. Why should an incident-created rule be tested with a newly created incident?
  2. Why is a unique tag safer than automatically closing an incident?
  3. What does a successful negative test demonstrate?
  4. Why should you check rule order and expiration?
  5. 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.”

Lesson 53 complete — your first Sentinel automation rule!
You can now configure a safe incident rule, validate matching and non-matching cases, investigate failures and document rollback.
Sentinel Academy Home

Related Agent Foskett learning

Build on the concepts and incident-handling practices behind this exercise.