A user says they "can't get in", a pipeline starts failing with an AADSTS error, or someone asks who removed an app owner last night. The Entra admin center can answer one question at a time. Log Analytics lets you answer it for the whole tenant and keep the query for next time.
This cheat sheet assumes Entra ID logs are already streaming to a Log Analytics workspace. If they aren't, start with the first section.
Check the logs are actually flowing
Entra diagnostic settings are tenant-level, not subscription-level, so az monitor diagnostic-settings list on a resource won't show them. Read them through ARM directly:
az rest --method get \
--url "https://management.azure.com/providers/microsoft.aadiam/diagnosticSettings?api-version=2017-04-01" \
--query "value[].{name:name, workspace:properties.workspaceId, logs:properties.logs[?enabled].category}"
Then confirm each table has recent rows:
union withsource=Table SigninLogs, AADNonInteractiveUserSignInLogs,
AADServicePrincipalSignInLogs, AADManagedIdentitySignInLogs, AuditLogs
| where TimeGenerated > ago(1d)
| summarize Rows = count(), Latest = max(TimeGenerated) by Table
| Table | Diagnostic category | What's in it |
|---|---|---|
SigninLogs | SignInLogs | Interactive user sign-ins (browser, prompts) |
AADNonInteractiveUserSignInLogs | NonInteractiveUserSignInLogs | Token refreshes and silent sign-ins by clients on behalf of users |
AADServicePrincipalSignInLogs | ServicePrincipalSignInLogs | Apps signing in with a secret, certificate or federated credential |
AADManagedIdentitySignInLogs | ManagedIdentitySignInLogs | Managed identities getting tokens |
AuditLogs | AuditLogs | Directory changes: users, groups, apps, roles, policies |
Tip
A table that is missing entirely usually means the category isn't enabled in the diagnostic setting. Exporting sign-in logs needs an Entra ID P1 or P2 licence in the tenant. Entries usually arrive within a few minutes but can take longer, so don't treat an empty last five minutes as proof that nothing happened.
Interactive user sign-ins
ResultType is a string. "0" means success, and any other value is the AADSTS error number without the prefix.
Top failure reasons in the last 24 hours
SigninLogs
| where TimeGenerated > ago(24h)
| where ResultType != "0"
| summarize Failures = count(), Users = dcount(UserPrincipalName)
by ResultType, ResultDescription
| order by Failures desc
One user's recent sign-ins
SigninLogs
| where TimeGenerated > ago(3d)
| where UserPrincipalName =~ "jane.doe@contoso.com"
| project TimeGenerated, AppDisplayName, ResultType, ResultDescription,
IPAddress, Location, ClientAppUsed, ConditionalAccessStatus,
OS = tostring(DeviceDetail.operatingSystem),
Browser = tostring(DeviceDetail.browser),
CorrelationId
| order by TimeGenerated desc
Give the CorrelationId to Microsoft Support or paste it into the sign-in log blade to see the full detail.
Common error codes to look for
| ResultType | Meaning | Usual fix |
|---|---|---|
| 50126 | Invalid username or password | Password reset, or check for a script using an old password |
| 50053 | Account locked (smart lockout or too many attempts) | Find the source IP below; wait out the lockout or block the source |
| 50057 | Account disabled | Re-enable if expected; check HR/offboarding process |
| 50076 / 50074 | MFA required but not completed | Usually informational; user then completes MFA |
| 53003 | Blocked by Conditional Access | See the Conditional Access section |
| 530032 | Blocked by security defaults or a security policy | Check security defaults and the policy named in the detail |
| 700016 | Application not found in the directory | Wrong tenant or app ID, or the app was deleted |
Codes and descriptions change over time. Trust ResultDescription in your own data over any static table.
Password spray and lockout sources
SigninLogs
| where TimeGenerated > ago(1h)
| where ResultType in ("50126", "50053")
| summarize Attempts = count(), DistinctUsers = dcount(UserPrincipalName),
SampleUsers = make_set(UserPrincipalName, 5)
by IPAddress, Location
| where DistinctUsers > 5
| order by DistinctUsers desc
One IP trying many users is spraying. One user failing from many IPs is often an old password stuck in a phone mail client.
Conditional Access
Sign-ins blocked by Conditional Access, by policy
SigninLogs
| where TimeGenerated > ago(24h)
| where ConditionalAccessStatus == "failure"
| mv-expand Policy = ConditionalAccessPolicies
| where tostring(Policy.result) == "failure"
| summarize Blocked = count(), Users = dcount(UserPrincipalName)
by PolicyName = tostring(Policy.displayName), AppDisplayName
| order by Blocked desc
What a report-only policy would have blocked
SigninLogs
| where TimeGenerated > ago(7d)
| mv-expand Policy = ConditionalAccessPolicies
| where tostring(Policy.result) == "reportOnlyFailure"
| summarize WouldBlock = count(), Users = dcount(UserPrincipalName)
by PolicyName = tostring(Policy.displayName), AppDisplayName, ClientAppUsed
| order by WouldBlock desc
Warning
In
AADNonInteractiveUserSignInLogstheConditionalAccessPoliciescolumn is a string, not dynamic. Wrap it asmv-expand Policy = todynamic(ConditionalAccessPolicies)or the query returns nothing. Column types vary between tables, so check withAADNonInteractiveUserSignInLogs | getschemaif a query comes back empty.
Legacy authentication still in use
SigninLogs
| where TimeGenerated > ago(7d)
| where ClientAppUsed !in ("Browser", "Mobile Apps and Desktop clients")
| summarize SignIns = count(), Users = make_set(UserPrincipalName, 10)
by ClientAppUsed, AppDisplayName
| order by SignIns desc
Values such as "Exchange ActiveSync", "IMAP4", "SMTP" and "Other clients" are legacy protocols. Move these users and apps off them before you enforce a block-legacy-auth policy.
Service principals and managed identities
Apps that started failing
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(24h)
| where ResultType != "0"
| summarize Failures = count(), LastFailure = max(TimeGenerated),
Errors = make_set(ResultType, 5)
by ServicePrincipalName, AppId, IPAddress
| order by Failures desc
7000222 (expired client secret), 7000215 (invalid secret) and 700027 (certificate assertion problem) are the usual results after a credential rotation went wrong.
Which credential each app uses
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(7d) and ResultType == "0"
| summarize LastSuccess = max(TimeGenerated)
by ServicePrincipalName, AppId, ClientCredentialType
| order by ServicePrincipalName asc
Use this before deleting an old secret. If ClientCredentialType still shows clientSecret for an app you thought moved to a certificate or federation, it hasn't. The column name may differ in older workspaces; check getschema.
Managed identity token failures
AADManagedIdentitySignInLogs
| where TimeGenerated > ago(24h)
| summarize Total = count(), Failed = countif(ResultType != "0")
by ServicePrincipalName, ResourceDisplayName
| where Failed > 0
| order by Failed desc
ResourceDisplayName is the API the identity asked a token for, such as Azure Key Vault or Azure Storage. A token request that succeeds but is followed by a 403 is an RBAC problem on the target resource, not an Entra problem.
Who changed what in the directory
Changes in the last 24 hours, with the actor
AuditLogs
| where TimeGenerated > ago(24h)
| extend Actor = coalesce(tostring(InitiatedBy.user.userPrincipalName),
tostring(InitiatedBy.app.displayName))
| extend Target = tostring(TargetResources[0].displayName)
| project TimeGenerated, Actor, OperationName, Category, Target, Result
| order by TimeGenerated desc
High-risk operations
AuditLogs
| where TimeGenerated > ago(7d)
| where OperationName has_any (
"Add member to role", "Add eligible member to role",
"Add service principal credentials", "Update application – Certificates and secrets management",
"Add owner to application", "Update conditional access policy",
"Delete conditional access policy", "Delete application", "Hard delete user")
| extend Actor = coalesce(tostring(InitiatedBy.user.userPrincipalName),
tostring(InitiatedBy.app.displayName))
| project TimeGenerated, Actor, OperationName,
Target = tostring(TargetResources[0].displayName), Result
| order by TimeGenerated desc
Operation names change from time to time, and some include special characters such as en dashes. Run AuditLogs | summarize count() by OperationName in your own workspace and copy the exact strings.
What changed on one object
AuditLogs
| where TimeGenerated > ago(30d)
| mv-expand Target = TargetResources
| where tostring(Target.displayName) == "app-payments-prod"
| mv-expand Prop = Target.modifiedProperties
| project TimeGenerated, OperationName,
Actor = tostring(InitiatedBy.user.userPrincipalName),
Property = tostring(Prop.displayName),
OldValue = tostring(Prop.oldValue), NewValue = tostring(Prop.newValue)
| order by TimeGenerated desc
Prevent it next time
- Turn on all five categories in the Entra diagnostic setting. Non-interactive and service principal logs are where most automation failures show up.
- Set workspace retention to match how far back incident reviews need to go. The Entra portal keeps sign-in history for a limited time, so check the current retention for your licence.
- Save the queries above as workspace functions (for example
EntraFailedApps()) so on-call can run them without editing. - Create log search alerts on the high-risk operations query and on service principal failures for your production apps.
- Review the report-only query weekly before switching any Conditional Access policy to On.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get