Making Microsoft Graph lifecycle automation safe to replay
A provisioning integration duplicates changes after throttling and crashes. Durable checkpoints and desired-state reconciliation let the workflow recover accurately after an interrupted run.
Environment overview
A service ingests workforce records and uses Microsoft Graph for the approved subset of identity and group operations. A worker reconciles changes against the directory and records approved and pending actions.
Business challenge
Duplicate grants and skipped removals have access consequences. The operations team needs to replay events with a clear lineage and scope a recovery without scanning or updating every account.
Technical complexity
Graph cursors are opaque and are specific to a resource and query. Delta responses can span multiple pages, deleted objects need explicit handling, and throttled writes may be retried after a process restart. A remote write may succeed before the local checkpoint is recorded.
Root-cause analysis
Replay a sanitized batch with simulated failures. In this model, the runner persists the next cursor before committing the work it represents, while a separate retry path issues duplicate actions after a timeout.
Engineering approach
Separate discovery, intent and execution. Persist page state after durable processing, store service-provided next or delta links intact, and reconcile from approved desired state on retry. Design for API-supported behavior on each resource.
- Capture changesRead supported delta feeds
- Store approved intentDurable work and cursor
- Reconcile safelyRetry from observed state
Implementation
Use bounded concurrency and honor Retry-After where supplied. Record action keys and compare actual state before retrying a write with uncertain outcome. Treat cursor expiry as a controlled resync with deduplication, alarms and review for exception cases.
Resolution & validation
Exercise process interruption, duplicate input, throttling and a full rebuild from a stale checkpoint. Verify the audit log can distinguish intended actions, observed state and operator intervention.
Expected business value
The architecture would make an automation failure recoverable without losing auditability or granting permissions twice. Operators could investigate with a smaller and more precise set of evidence.
Engineering insight
Idempotency is an application contract here. A checkpoint by itself cannot guarantee what Microsoft Graph already applied when your worker timed out.
