Before you run
Data & scope
- Required tables
- Time window
- 24-hour role-change window ending 1 hour ago; 1-hour follow-up
- Azure Activity connector or subscription diagnostic settings exporting Administrative events into AzureActivity.
- Query access, at least 25 hours of retained coverage, and an Analytics table plan supporting the self-join.
Documentation review by Codex (AI). No live-tenant execution or detection-performance claim. Validate schema, data coverage and expected results in your workspace.
// Hunting starter. Documentation checked 2026-11-13; not tenant-tested.
let followup = 1h;
let changeEnd = now() - followup;
let changeStart = changeEnd - 1d;
let activity = materialize(
AzureActivity
| where TimeGenerated >= changeStart and TimeGenerated <= now()
| where CategoryValue =~ "Administrative"
| extend CallerKey = tolower(Caller), SubscriptionKey = tolower(SubscriptionId)
| where isnotempty(CallerKey) and isnotempty(SubscriptionKey)
| project TimeGenerated, CallerKey, SubscriptionKey, CallerIpAddress,
OperationNameValue, ActivityStatusValue, ResourceId, _ResourceId,
CorrelationId, OperationId, EventDataId
);
let roleChanges = activity
| where TimeGenerated < changeEnd and ActivityStatusValue =~ "Succeeded"
| where OperationNameValue in~ (
"Microsoft.Authorization/roleAssignments/write",
"Microsoft.Authorization/roleAssignments/delete")
| project CallerKey, SubscriptionKey, ChangeTime = TimeGenerated,
RoleOperation = OperationNameValue,
AssignmentResource = coalesce(ResourceId, _ResourceId),
ChangeEventId = EventDataId, ChangeOperationId = OperationId,
ChangeCorrelationId = CorrelationId, ChangeIp = CallerIpAddress;
let followupActivity = activity
| where ActivityStatusValue in~ ("Succeeded", "Failed")
| where OperationNameValue !in~ (
"Microsoft.Authorization/roleAssignments/write",
"Microsoft.Authorization/roleAssignments/delete")
| project CallerKey, SubscriptionKey, ActivityTime = TimeGenerated,
FollowupOperation = OperationNameValue, FollowupStatus = ActivityStatusValue,
FollowupResource = coalesce(ResourceId, _ResourceId),
FollowupIp = CallerIpAddress, FollowupEventId = EventDataId,
FollowupCorrelationId = CorrelationId;
roleChanges
| join kind=inner followupActivity on CallerKey, SubscriptionKey
| where ActivityTime > ChangeTime and ActivityTime <= ChangeTime + followup
| extend MinutesAfterChange = datetime_diff("minute", ActivityTime, ChangeTime)
| project ChangeTime, ActivityTime, MinutesAfterChange, SubscriptionKey,
CallerKey, RoleOperation, AssignmentResource, ChangeIp,
FollowupOperation, FollowupStatus, FollowupResource, FollowupIp,
ChangeEventId, FollowupEventId, ChangeOperationId,
ChangeCorrelationId, FollowupCorrelationId
| order by ActivityTime desc, ChangeTime desc
| take 200
Read-only query. Run in your own authorized workspace after checking prerequisites.
Use this hunt to follow an administrator or deployment identity from a successful role-assignment write or delete into its subsequent control-plane activity. It anchors the investigation to the same caller within the same subscription, over a one-hour interval. This can help reconstruct an unexpected access-management sequence or explain a deployment that changed permissions before modifying resources.
The caller is the actor that made the role change. It is not automatically the principal receiving access. The query therefore makes no claim that the later operation used the newly assigned role, or that the grantee performed it. Establish those relationships separately from the assignment’s actual principal, role, scope and conditions.
Read the event sequence
The selected assignment operations are the documented write/delete identifiers. Only a Succeeded change can anchor the sequence. Follow-up activity retains Succeeded and Failed administrative records so a denied subsequent operation remains visible. Other assignment writes and deletes are excluded from the follow-up side to keep the view focused. RBAC activity documentation.
Both sides use normalized caller and subscription strings, excluding empty values. Matching is exact after case normalization: different representations of the same identity can still fail to join. The target resource does not need to match the assignment scope, and the query does not calculate scope inheritance or effective authorization.
Each returned row is a candidate event pair. A busy caller can generate many pairs, and overlapping role changes can share follow-up events. Event IDs and correlation IDs allow you to return to the original records. A shared correlation ID may identify one larger deployment transaction; it does not make each returned pair an independent finding. Azure Activity event semantics.
Investigate what the sequence means
Retrieve the role-change event and resolve the affected assignment. Determine whether the caller changed its own access, another principal’s access, or a deployment identity’s permissions. Compare the actual role definition, scope and condition with the approved change record. For deletion, verify whether other assignments still provided equivalent authority.
Next, inspect the later operations and their outcomes. An unexpected resource modification or failed high-impact action can justify deeper review, but its proximity to a permission change is not causal proof. Check the caller’s authentication history, deployment run and resource-specific data-plane logs where relevant. The Activity Log is not a complete record of reads, application requests or secret access.
Tune and validate
Infrastructure deployments, access provisioning, teardown jobs and incident recovery frequently produce these sequences legitimately. Tune using a specific subscription, actor, operation or known deployment interval rather than suppressing every change from a privileged automation account. Separate approved activity from unexplained deviations in its target or timing.
The change window ends one hour before execution to give each anchor a complete follow-up interval. Ingestion delay can still remove part of that interval. The latest 200 pairs limit output, not self-join cost; a smaller time range is the first response to excessive volume.
This is a read-only, documentation-checked hunt with no live-tenant test or validated detection claim. Verify it against an approved role change followed by both a successful and denied administrative operation. Confirm the returned caller is the initiator, and test that another caller’s activity does not match.
Verify the source
Microsoft references
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 →