Azure attacks rarely announce themselves with a single obvious alert. More often, the warning signs are buried in sign-in records, role assignments, application permissions, and automated workload activity. A short, repeatable Kusto Query Language (KQL) review can uncover issues before they become incidents. If you manage Microsoft Azure security, Microsoft Entra ID, or Microsoft Sentinel, these seven weekly KQL queries give you a practical identity-first hunting routine. Each query is copy-ready, with guidance on what the results mean, what to investigate, and where the query can mislead you.
Before You Run These Azure Security KQL Queries
Send the relevant Microsoft Entra diagnostic categories to a Log Analytics workspace. This article uses SigninLogs, AuditLogs, and AADServicePrincipalSignInLogs. Optional non-interactive user sign-ins are commonly stored separately in AADNonInteractiveUserSignInLogs. Run the queries in the workspace that actually receives the logs. Confirm data retention covers the seven-day window and that you have permission to query the tables. Feature licensing, diagnostic settings, and ingestion delays affect results. Set the time picker to at least seven days. The queries also contain explicit TimeGenerated filters to make their lookback clear. Test thresholds in your own environment before turning hunts into automated detections.
1. Find high-risk Microsoft Entra ID sign-ins
SigninLogs
| where TimeGenerated >= ago(7d)
| where RiskLevelAggregated in~ ("medium", "high")
| project TimeGenerated, UserPrincipalName, IPAddress,
AppDisplayName, RiskLevelAggregated, RiskState,
ConditionalAccessStatus, ResultType
| order by TimeGenerated desc
Why run it: Risky sign-ins can reveal credential theft, suspicious access patterns, or a session that deserves a second look. Start with medium- and high-risk events, then prioritize successful authentications and accounts with privileged access.
What to investigate: Validate the risk state in Microsoft Entra ID Protection; review authentication details, device and IP context, Conditional Access results, and any correlated alerts. A blocked or remediated event is not the same as an active compromise.
Important caveat: Risk detection details generally require Microsoft Entra ID P2. “Hidden” does not mean low risk. This query only sees sign-ins ingested into SigninLogs.
2. Identify successful single-factor sign-ins
SigninLogs
| where TimeGenerated >= ago(7d)
| where tostring(ResultType) == "0"
| where AuthenticationRequirement =~ "singleFactorAuthentication"
| summarize SuccessfulSignIns=count(),
LastSeen=max(TimeGenerated),
IPs=make_set(IPAddress, 10),
Apps=make_set(AppDisplayName, 10)
by UserPrincipalName
| order by SuccessfulSignIns desc
Why run it: A successful sign-in that reports single-factor authentication deserves review, particularly for administrative users or sensitive applications. This is an exposure-hunting query, not a tenant-wide MFA enrollment report.
What to investigate: Examine individual sign-in authentication details and the Conditional Access policies that actually applied. Decide whether workload exceptions, federated authentication, session reuse, or approved policy behavior explain the result.
Important caveat: AuthenticationRequirement describes a sign-in event; it does not measure user MFA registration or prove that MFA was bypassed. Some strong-authentication context may be satisfied outside the immediate prompt.
3. Surface legacy and unknown authentication clients
SigninLogs
| where TimeGenerated >= ago(7d)
| where ClientAppUsed in~ (
"Exchange ActiveSync", "IMAP", "POP", "SMTP",
"MAPI", "Other clients", "Authenticated SMTP")
| summarize Attempts=count(),
Successful=countif(tostring(ResultType) == "0"),
LastSeen=max(TimeGenerated),
Users=dcount(UserPrincipalName)
by ClientAppUsed, AppDisplayName
| order by Attempts desc
Why run it: Legacy and unfamiliar client categories can highlight applications that may not support modern authentication controls. They also reveal exceptions that deserve documentation before a policy change.
What to investigate: Review the original sign-in record and protocol, check non-interactive user sign-in logs as applicable, identify the owner of the client, and plan replacement or targeted controls.
Important caveat: “Other clients” is a broad or unknown category and is not by itself proof of basic authentication. Depending on ingestion, non-interactive sign-in activity may be in AADNonInteractiveUserSignInLogs and will not appear in this query.
4. Detect password-spray-like failures across multiple accounts
SigninLogs
| where TimeGenerated >= ago(7d)
| where tostring(ResultType) != "0"
| where isnotempty(IPAddress) and isnotempty(UserPrincipalName)
| summarize FailedAttempts=count(),
DistinctUsers=dcount(UserPrincipalName),
SampleUsers=make_set(UserPrincipalName, 8),
FirstSeen=min(TimeGenerated),
LastSeen=max(TimeGenerated)
by IPAddress, bin(TimeGenerated, 1h)
| where DistinctUsers >= 5 and FailedAttempts >= 15
| order by DistinctUsers desc, FailedAttempts desc
Why run it: Password spraying frequently creates many failures from the same source against different identities. Grouping failures by IP and hour helps analysts find clusters without opening thousands of individual events.
What to investigate: Check whether the IP is a trusted proxy, VPN exit, shared corporate egress, or known testing platform. Review success after failure, affected users, risk signals, and block decisions.
Important caveat: Thresholds (five users and 15 failures per hour) are starting points, not universal rules. Distributed attacks across rotating IPs can evade this query, while shared egress can produce false positives.
5. Review Microsoft Entra privileged-role assignments
AuditLogs
| where TimeGenerated >= ago(7d)
| where OperationName has_any (
"Add member to role", "Add eligible member to role",
"Add scoped member to role")
| extend Initiator=coalesce(
tostring(InitiatedBy.user.userPrincipalName),
tostring(InitiatedBy.app.displayName),
"Unknown")
| extend Target=tostring(TargetResources[0].displayName)
| project TimeGenerated, OperationName, Result,
Initiator, Target, TargetResources, CorrelationId
| order by TimeGenerated desc
Why run it: Privileged access is a high-impact attack path. Review new active and eligible role assignments, particularly unexpected changes affecting tenant administration.
What to investigate: Confirm the role, principal, assignment scope, ticket, approver, and PIM record. Review the full TargetResources structure for the actual role and affected principal.
Important caveat: The operation-name filter is a starting set, not an exhaustive catalog of every PIM or role-management event. Azure resource RBAC assignments require separate AzureActivity coverage.
6. Audit new OAuth consent and application permission grants
AuditLogs
| where TimeGenerated >= ago(7d)
| where OperationName in~ (
"Consent to application",
"Add delegated permission grant",
"Add app role assignment to service principal")
| extend Initiator=coalesce(
tostring(InitiatedBy.user.userPrincipalName),
tostring(InitiatedBy.app.displayName),
"Unknown")
| project TimeGenerated, OperationName, Result,
Initiator, TargetResources, CorrelationId
| order by TimeGenerated desc
Why run it: An application receiving delegated or app-only access may acquire access to email, files, directory objects, or other sensitive resources. New consent and permission grants are worth examining even if no malware alert fires.
What to investigate: Check publisher verification, application ownership, granted scopes or roles, consent type, target resource, and the business justification. Investigate unexpected administrator consent and broad Graph permissions.
Important caveat: This query finds relevant audit events but does not classify permission sensitivity automatically. Expand TargetResources and modifiedProperties to confirm the permission names and tenant-specific context.
7. Find unusual service-principal sign-in sources
AADServicePrincipalSignInLogs
| where TimeGenerated >= ago(7d)
| where isnotempty(ServicePrincipalId)
| summarize SignIns=count(),
FirstSeen=min(TimeGenerated),
LastSeen=max(TimeGenerated),
Resources=make_set(ResourceDisplayName, 8)
by ServicePrincipalId, ServicePrincipalName, IPAddress
| order by SignIns desc
Why run it: Service principals support automation and integrations and may have powerful permissions. A new source IP or unfamiliar workload identity can indicate a changed deployment path, misconfiguration, or stolen credential.
What to investigate: Compare source IPs against approved build runners and hosted services, inspect credential history, check sign-in results and accessed resources, and investigate changes to application secrets and certificates.
Important caveat: This gives a seven-day source inventory, not a statistically proven anomaly. For true “new IP” detection, compare with a longer historical baseline and account for retention and legitimate cloud IP churn. Managed identities have a separate sign-in table.
Build a 30-Minute Weekly Azure Security Review
- Check telemetry first (3 minutes): Verify that the relevant log tables have fresh events and that collection is working.
- Review identity sign-ins (10 minutes): Run queries 1–4; prioritize successful suspicious access and broad attack patterns.
- Examine high-impact changes (10 minutes): Run queries 5–6 and reconcile activity against PIM records, approvals, and change tickets.
- Inspect workload identities (5 minutes): Run query 7 and compare sources with approved automation and infrastructure.
- Record and escalate (2 minutes): Assign owners, document decisions, and immediately escalate urgent findings.
Common Mistakes to Avoid
- Treating no results as proof of no exposure rather than checking data collection.
- Assuming single-factor events equal the percentage of users not registered for MFA.
- Labeling every Other clients record as confirmed legacy basic authentication.
- Treating a threshold-based password-spray pattern as proof of compromise.
- Ignoring service principals and OAuth grants because they are not human accounts.
Frequently Asked Questions
How often should I run KQL security queries in Azure?
Weekly reviews are a useful baseline for posture and trend analysis, but high-risk detections, privileged access events, and active attacks should be monitored continuously.
Do I need Microsoft Sentinel to run these queries?
No. KQL queries can run in Azure Monitor Logs / Log Analytics when the required tables are populated. Microsoft Sentinel adds SIEM investigation and analytics capabilities.
Why does my KQL query return no results?
Check the correct workspace, table ingestion, Entra diagnostic settings, chosen time range, retention, access permissions, and relevant licensing. Zero results does not prove there is no risk.
Can these queries measure MFA coverage?
No. The single-factor query describes observed sign-ins, not all users’ MFA registration or Conditional Access coverage. Use the appropriate Microsoft Graph or Entra reporting data for enrollment and policy coverage.
Make Weekly KQL Hunting a Repeatable Habit
Run these checks at least once a week and track what changed since the last review. Record who owns each finding, whether the activity was expected, and what remediation or policy improvement followed. High-severity findings should trigger immediate investigation rather than waiting for Friday's review. Weekly hunting is a complement to—not a replacement for—continuous Microsoft Sentinel analytics, Microsoft Entra ID Protection, Conditional Access, and alert triage. The long-term goal is to turn frequently useful searches into monitored detections and measurable identity-security controls. AzureWise helps teams turn raw Microsoft Entra ID telemetry into an understandable identity-security posture. Explore the AzureWise Identity Security Assessment toolkit and KQL query pack at https://azurewise.io/ to accelerate regular reviews and prioritize remediation.
References
- Microsoft Learn: SigninLogs schema
- Microsoft Learn: AuditLogs schema
- Microsoft Learn: AADServicePrincipalSignInLogs schema
- Microsoft Learn: Application permissions audit logs
- Microsoft Learn: Customize and filter Entra activity logs
Want the Azure identity assessment already built?
AzureWise Identity Security Assessment turns Microsoft Entra ID telemetry into a weighted Security Rating, detailed findings, and prioritized remediation guidance inside Azure Monitor.
Get AzureWise — $99