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

Lesson 58 — Automating Identity Investigation Workflows

Automate identity evidence collection for suspicious sign-ins, account changes and privilege activity. Build a traceable analyst handoff without automatically disabling users or revoking sessions.

Module 6 — SOC Automation and Response • Identity investigation workflows
Agent Foskett Microsoft Sentinel identity investigation automation
What you will learn

Build a controlled identity evidence playbook.

✓ Extract and validate account entities
✓ Correlate Entra sign-ins and audit activity
✓ Record uncertainty and data gaps
✓ Produce an analyst-ready incident summary

Agent Foskett case file — The sign-in after midnight

A Microsoft Sentinel incident reports a successful sign-in from an unfamiliar location. Minutes later, an account setting changes. The account owner is travelling, and the security team has not yet confirmed whether the change was authorized. Agent Foskett builds an investigation that collects facts before drawing conclusions.

Learning objectives

  • Extract and normalize account entities from a Sentinel incident.
  • Correlate Entra sign-in events and audit records with a bounded time window.
  • Identify identity investigation pivots without treating them as proof.
  • Use a Logic Apps playbook to write an auditable incident comment.
  • Handle missing telemetry, ambiguous identities and repeated execution safely.

Identity investigation architecture

SENTINEL INCIDENT ↓ EXTRACT ACCOUNT ENTITY → VALIDATE IDENTIFIERS ↓ SET UTC EVIDENCE WINDOW + SOURCE COVERAGE ↓ QUERY SIGNINLOGS + AUDITLOGS ↓ CORRELATE TIMELINE + RECORD LIMITATIONS ↓ WRITE INCIDENT COMMENT WITH RUN ID ↓ ANALYST REVIEWS → APPROVED RESPONSE

Prerequisites

  • Complete Lessons 53–57 or equivalent Sentinel and Logic Apps labs.
  • Access a Microsoft Sentinel-enabled workspace with relevant Entra diagnostic logs ingested.
  • Use a test incident and approved lab identity.
  • Confirm connector permissions for reading logs and writing incident comments.
  • Keep the lab playbook non-destructive: no account disabling, password resets or token revocation.

Step 1 — Establish the investigation question

Determine which identity the incident references, what activity occurred, when it occurred, and which evidence sources are available. Account display names can be ambiguous; use stable identifiers when possible.

Step 2 — Copy a known-good playbook

  1. Duplicate your tested incident-enrichment Logic App.
  2. Name the lab copy AF-LAB-Identity-Investigation.
  3. Retain an incident-triggered workflow and approved automation rule.
  4. Document owner, managed identity, resource group and rollback steps.
  5. Confirm the test incident triggers exactly as expected.

Step 3 — Extract account entities safely

Use the supported Sentinel incident entity action or documented trigger fields. Inspect the real payload in a test run. Account entities may contain a UPN, account name, domain, object ID or other identifiers; fields are not guaranteed to be present in every incident. Handle missing and multiple entities explicitly.

Step 4 — Normalize the target identity

  • Prefer a validated Entra object identifier when the available data supports it.
  • For a UPN, normalize whitespace and verify it is the intended account.
  • Do not equate a display name with a unique user.
  • Deduplicate identifiers and cap the number processed per incident.
  • Keep the original incident entity in the audit summary.

Step 5 — Define the evidence window

Start with a 24-hour lab lookback. For production investigations, align the start and end times to the alert activity and ingestion delay. Record the UTC window and do not confuse event time with playbook execution time.

Step 6 — KQL: summarize recent sign-ins

Microsoft Sentinel Logs — SigninLogs
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
let TargetUPN = "analyst@example.com";
SigninLogs
| where TimeGenerated >= ago(24h)
| where UserPrincipalName =~ TargetUPN
| summarize Attempts = count(),
            Successful = countif(ResultType == "0"),
            Failed = countif(ResultType != "0"),
            FirstSeen = min(TimeGenerated),
            LastSeen = max(TimeGenerated)
    by IPAddress, AppDisplayName
| order by Attempts desc

Lab note: replace the example UPN with an approved test identity. A successful sign-in is not proof of compromise, and the query covers only records available in this workspace.

Step 7 — Interpret authentication results

Review sign-in outcomes in context. Repeated failures can arise from stale credentials or malicious attempts; successful events can be legitimate. Use the relevant correlation IDs, applications, device context and conditional access details when available. Avoid simplistic location-based conclusions.

Step 8 — KQL: build a sign-in timeline

Microsoft Sentinel Logs — identity timeline
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
let TargetUPN = "analyst@example.com";
SigninLogs
| where TimeGenerated >= ago(24h)
| where UserPrincipalName =~ TargetUPN
| project TimeGenerated, UserPrincipalName,
          IPAddress, AppDisplayName, ResultType,
          ResultDescription, ConditionalAccessStatus,
          CorrelationId
| order by TimeGenerated asc
| take 200

Analyst check: the 200-row cap may truncate a busy account's history. Document any truncation before using the timeline in a case summary.

Step 9 — Identify relevant audit changes

Entra AuditLogs can provide evidence of directory changes such as user updates, role-related operations and application changes, depending on logging coverage. A nearby timestamp is a lead, not proof that the sign-in caused the change.

Step 10 — KQL: find audit operations involving the account

Microsoft Sentinel Logs — AuditLogs
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
let TargetUPN = "analyst@example.com";
AuditLogs
| where TimeGenerated >= ago(24h)
| extend Targets = tostring(TargetResources)
| where Targets contains TargetUPN
| project TimeGenerated, OperationName,
          Result, ResultReason,
          InitiatedBy, TargetResources,
          CorrelationId
| order by TimeGenerated desc
| take 100

Important: this is a practical text-based discovery query. Nested audit records may require more precise parsing of TargetResources and InitiatedBy. A non-match does not prove no change occurred.

Step 11 — Correlate without inventing causation

Place sign-in events and audit operations on a common UTC timeline. Compare account identifiers and correlation IDs where available. Do not claim an audit event was caused by a specific sign-in merely because both occurred within minutes.

Step 12 — Choose the right query execution method

For Logic Apps, select a supported Azure Monitor Logs or Log Analytics query action, confirm the target workspace and configure a least-privilege identity. Validate the incident-derived account value before it is used in a query. Test the connector's real response schema rather than assuming it matches a portal screenshot.

Step 13 — Protect query inputs

  • Do not concatenate untrusted account strings into KQL without validation.
  • Use supported safe parameter handling or a tightly validated input approach.
  • Limit query time ranges and result counts.
  • Avoid returning unnecessary personal information.
  • Never log credentials, access tokens or connector secrets.

Step 14 — Handle coverage gaps

If SigninLogs or AuditLogs is absent, ingestion is delayed or permissions fail, label the corresponding source unavailable. Zero returned rows means no matching records in the queried source and window — not that the account is safe.

Step 15 — Build the incident summary

AUTOMATED IDENTITY INVESTIGATION — LAB Incident: [identifier] Account: [validated identifier] UTC window: [start → end] Sign-ins: [count / unavailable] Observed IPs: [count, bounded list] Audit operations: [count / unavailable] Relevant correlations: [identifiers / not established] Missing sources: [coverage or permission gaps] Conclusion: EVIDENCE SUMMARY ONLY Run ID: [Logic Apps execution identifier] Next step: ANALYST REVIEW

Include query times, row caps and any truncation. Keep the summary factual and avoid declaring compromise from a single signal.

Step 16 — Write an incident comment

Use the supported Sentinel incident comment action. Prefix the comment with an automation label and workflow version so analysts can distinguish machine-collected evidence from human conclusions. Do not automatically change incident severity, classification or status.

Step 17 — Prevent repeat-run loops

An incident update may trigger another automation run. Use documented trigger conditions, a stable workflow marker or another tested idempotency mechanism to avoid duplicate comments and endless retriggering. Verify behavior with two consecutive test runs.

Step 18 — Build explicit failure handling

ScenarioSafe workflow result
No account entityRecord missing input and stop enrichment
Multiple possible identitiesFlag ambiguity for analyst review
Query deniedRecord unavailable source
Telemetry delayedRecord ingestion uncertainty
Connector timeoutBound retries and report partial result
Duplicate invocationAvoid duplicate comments or disclose rerun

Step 19 — Test the workflow

  1. One account entity with matching sign-in events.
  2. One account with no sign-in records in the window.
  3. Multiple account entities.
  4. An incident with no account entity.
  5. An unavailable audit table or denied query.
  6. A high-volume account with truncated output.
  7. Repeated invocation of the same incident.

Inspect Logic Apps run history, output shape and final incident comment for each case.

Step 20 — Privacy and permissions

Identity logs contain sensitive operational and personal information. Scope read access to the intended workspace, limit incident write permissions and configure run-history retention appropriately. Follow organizational policies for storing identifiers, locations and device information.

Step 21 — Performance and cost

Bound the number of accounts, the query lookback and the rows returned. Use controlled retries and monitor workflow duration. Logic Apps actions and log queries may have cost and throttling implications. Test with a small lab scope before broad rollout.

Agent Foskett case file — The midnight change

The automated timeline shows a successful sign-in from an unfamiliar IP, followed by a directory audit event involving the same user. The summary records both observations, their timestamps and their identifiers — but does not label the event an account takeover. The analyst checks the user's travel context, verifies the exact audit operation and examines additional telemetry before deciding what happened.

Finding: correlation helps prioritize an investigation; it does not replace evidence of authorization or intent.

Hands-on challenge

  1. Create the AF-LAB-Identity-Investigation playbook.
  2. Extract a test account entity and validate its identifier.
  3. Run the sign-in summary and timeline queries.
  4. Search audit events involving that identity.
  5. Record source coverage and time-window limits.
  6. Post an evidence-only comment to the test incident.
  7. Test missing-data and repeated-run paths.
  8. Document two further analyst pivots.

Pre-publish checklist

  • Account identifiers validated and ambiguous matches handled.
  • All three KQL editors display line numbers.
  • Queries use bounded windows and row caps.
  • Missing data is not treated as evidence of safety.
  • Incident comments contain sources, timestamps and run ID.
  • Permissions, privacy and failure paths reviewed.
  • No destructive response is automated.
  • Previous lesson navigation and canonical URL checked.

Agent Foskett takeaway

Identity automation should make the evidence clearer, not make the verdict faster. Collect the sign-in records, inspect the directory changes and show the analyst what is known — and what is still uncertain.

The logs already knew. Agent Foskett followed the identity trail.

Lesson 58 complete — identity investigation automation!
You can now build a controlled identity evidence workflow with Sentinel, Entra logs, KQL and analyst-led response.
Sentinel Academy Home

Related Agent Foskett learning

Review the incident enrichment and investigation automation lessons that support this workflow.