Investigating a Sign-In Anomaly via Azure Logs

Objective:

As an SRE, one key responsibility is maintaining system reliability and security. Unusual sign-in attempts — such as logins from unexpected locations, devices, or at odd hours — may indicate a compromised account or misconfiguration.

Azure Active Directory (Azure AD) and Microsoft Entra provide Sign-in Logs, which record details like:

These logs can be queried in Azure Log Analytics using Kusto Query Language (KQL), allowing you to identify anomalies and take corrective actions.

Step 1 — Access Sign-In Logs

  1. Log in to the Azure Portal.
  2. Navigate to Microsoft Entra ID → Sign-in logs.
  3. Familiarize yourself with the dashboard — note available filters such as:
    • User
    • Status (Success / Failure)
    • Location
    • Application
    • Date Range Confirm that you can view raw sign-in entries for your tenant.

Step 2 — Simulate or Identify an Anomalous Sign-in

There are two paths here:

Option A (Simulation for lab environments):

Option B (Live environment):

Step 3 — Query Logs in Log Analytics

  1. Go to your Log Analytics Workspace (linked to Azure AD logs).
  2. Open the Logs blade.
  3. Run the following KQL query:
    SigninLogs
    | where TimeGenerated > ago(24h)
    | project UserPrincipalName, IPAddress, Location, ResultType, ResultDescription, AppDisplayName, ConditionalAccessStatus, DeviceDetail
    | summarize Count = count() by UserPrincipalName, Location
    | order by Count desc
    
  4. Review which users have multiple sign-ins from different or unexpected locations.
  5. Drill deeper into a single user’s activity:
    SigninLogs
    | where UserPrincipalName == "user@yourdomain.com"
    | project TimeGenerated, Location, IPAddress, AppDisplayName, ResultType, AuthenticationRequirement, ConditionalAccessStatus
    | order by TimeGenerated desc
    

Identify whether the sign-in pattern looks legitimate or suspicious.

Step 4 — Correlate with Conditional Access and Device Information

Run another query to see if Conditional Access policies were applied:

SigninLogs
| where UserPrincipalName == "user@yourdomain.com"
| extend Device = tostring(DeviceDetail.operatingSystem)
| project TimeGenerated, Location, Device, ConditionalAccessStatus, Status = ResultType, ResultDescription

Document any anomalies — e.g., login succeeded from a non-compliant device without MFA.

Step 5 — Investigate IP and Geo-Location

Copy the suspicious IPAddress and use an external service (e.g., iplocation.net) to check the origin country.

Conclude whether the login was likely legitimate or potentially malicious.

Step 6 — Document Findings and Actions

Create a short incident report:

Optional Extension: Create a Sign-In Anomaly Alert

  1. In Azure Monitor, create a Log Alert Rule with the following query:
    SigninLogs
    | where ResultType == 0  // Successful sign-ins
    | summarize distinct_locations = dcount(Location) by UserPrincipalName, bin(TimeGenerated, 1d)
    | where distinct_locations > 2
    
  2. Configure the alert to trigger an email or webhook to your incident response system.

You’ve automated the detection of users signing in from multiple regions within 24 hours.

💬
AI Learning Assistant