← Sentinel query library

Identity · Microsoft Sentinel

Find new resource audiences used by managed identities

Compare managed-identity token activity with prior resource relationships while keeping workload attachment and downstream authorization as separate evidence.

Before you run

Data & scope

Required tables
AADManagedIdentitySignInLogs
Time window
15 days: 14-day baseline and 1-day review
  • Microsoft Entra ID connector with AADManagedIdentitySignInLogs available for fifteen complete days.
  • Microsoft Entra ID P1 or P2 for ingestion and an Analytics query experience supporting joins.

Documentation review by Codex (AI). No live-tenant execution or detection-performance claim. Validate schema, data coverage and expected results in your workspace.

Kusto Query Language
Download .kql
// Hunting starter. Documentation checked 2026-11-13; not tenant-tested.
let recentStart = ago(1d);
let successful = AADManagedIdentitySignInLogs
    | where TimeGenerated >= recentStart - 14d and TimeGenerated <= now()
    | where ResultType =~ "Success" or tolong(ResultType) == 0
    | where isnotempty(AADTenantId) and isnotempty(ServicePrincipalId)
        and isnotempty(ResourceIdentity);
let knownResources = successful
    | where TimeGenerated < recentStart
    | distinct AADTenantId, ServicePrincipalId, ResourceIdentity, ResourceOwnerTenantId;
let establishedIdentities = knownResources
    | summarize PriorResourcePairs = count() by AADTenantId, ServicePrincipalId;
successful
| where TimeGenerated >= recentStart
| summarize SignInRows = count(), FirstSeenInReview = min(TimeGenerated),
    LastSeen = max(TimeGenerated), ResourceNames = make_set(ResourceDisplayName, 5),
    IdentityDetails = make_set(ManagedServiceIdentity, 3),
    SourceIPs = make_set(IPAddress, 10)
    by AADTenantId, ServicePrincipalId, ServicePrincipalName, AppId,
        ResourceIdentity, ResourceOwnerTenantId
| join kind=inner establishedIdentities on AADTenantId, ServicePrincipalId
| join kind=leftanti knownResources
    on AADTenantId, ServicePrincipalId, ResourceIdentity, ResourceOwnerTenantId
| project AADTenantId, ServicePrincipalId, ServicePrincipalName, AppId,
    ResourceIdentity, ResourceOwnerTenantId, ResourceNames, PriorResourcePairs,
    FirstSeenInReview, LastSeen, SignInRows, IdentityDetails, SourceIPs
| order by LastSeen desc
| take 200

Read-only query. Run in your own authorized workspace after checking prerequisites.

Managed identities remove application-owned secret handling, but they still represent authority that a workload can exercise. This hunt highlights a recently observed resource relationship for an identity with established sign-in history. Use it to review new dependencies or unexpected behavior in agent runtimes and AI services.

Keep identity, attachment and permission separate

The comparison uses the directory and service-principal object ID for the managed identity. It includes the recorded resource identity and resource-owner tenant, preserving destination context across tenant boundaries. Resource names and ManagedServiceIdentity details are bounded evidence samples rather than join keys. Table reference.

The query cannot tell which attached runtime instance caused every operation, whether the identity attachment was approved, or whether a downstream API authorized a request. A user-assigned identity can be shared across workloads; group-level authentication evidence may therefore combine several deployments. Resolve the managed identity and its attachments through trusted resource inventory.

ResourceIdentity can represent a service audience rather than a specific storage account, search service or vault. The reported new relationship must be traced to resource logs before asserting access to a particular data store. Managed identity sign-ins and resource data-plane operations answer different questions. Sign-in semantics.

Investigate a changed relationship

Compare the recent pair with release records and declared dependencies. Review identity assignments, role changes and the workload’s effective network path. New features, recovery operations, regional failover and scheduled maintenance can create legitimate unfamiliar audiences.

An unexpected destination may be worth escalating even when authentication succeeded with a managed identity. Secretless authentication does not establish that the requesting runtime is uncompromised. Preserve the original event identifiers and correlate destination actions before containment decisions.

Validate and interpret absence

The baseline and recent windows do not overlap. Principals without historical resources are intentionally excluded, and missing resource identifiers cannot participate. Test familiar and unfamiliar relationships, an entirely new identity and a stable identifier whose display name changes.

Confirm fifteen days of collection and retain the distinction between logged success strings and numeric success codes. A quiet or newly connected table cannot support a reliable baseline. This documentation-checked query has not been tenant-tested. The 200-group cap limits displayed candidates, not query cost, and empty output is not proof that all managed identity attachments and permissions are appropriate.

Verify the source

Microsoft references

  1. Microsoft Learn — AADManagedIdentitySignInLogs schema ↗
  2. Microsoft Learn — Managed identity sign-ins ↗
  3. Microsoft Learn — Microsoft Entra ID connector ↗
Before turning a hunt into an alert

Measure normal activity, validate known test cases, account for ingestion delays, choose a threshold and entity mapping, and assign an owner. Results require investigation.

Follow the detection learning path →