Durable Task in the Real World: What Problems Does It Actually Solve?
The article explains where Durable Task and Durable Task Scheduler (DTS) provide concrete value: coordinating long-running, interruptible business workflows, remembering progress, and resuming execution after failures. It contrasts this with responsibilities that remain with the application, such as authorization, idempotent integration with external systems, safe cleanup, and deciding whether external effects (like payments or Azure operations) truly completed. Five scenarios illustrate both the advantages and limits of durable execution: invoice approvals, tenant provisioning, subscription payments, webhook-driven search indexing, and AI-assisted incident remediation.
Across all examples, Durable Task is presented as a way to express orchestration boundaries and durable waits instead of hand-rolling continuation handlers, queues, and state machines. However, it does not guarantee exactly-once external effects, does not make external services deterministic, and does not replace application-level protocols for fencing, reconciliation, and safety. The author recommends adopting Durable Task when the logic for remembering and resuming business processes grows into a system of its own, not merely because some methods use await.
Reading notes#
The core question is not how Durable Task works internally but which real problems durable execution solves compared to plain C#, queues, databases, or background workers.
A motivating example is a background worker provisioning an Azure environment that dies mid-process, leaving Azure operations running while the worker’s local state and continuations are lost.
The five scenarios are invoice approvals, Azure tenant provisioning, subscription payments, search indexing fed by out-of-order webhooks, and an AI agent investigating an incident; each one marks where durable orchestration helps and what stays with the application.
In all examples, Durable Task coordinates a subset of the workflow while the application remains authoritative for external decisions and side effects.
In the invoice-processing scenario, a service extracts and validates invoices and may require human review for a subset of items in a batch.
A straightforward C# implementation can call extraction, validation, review opening, and posting, but resuming after a later human approval requires separate continuation handlers and state recovery.
Durable Task can give each invoice its own child orchestration, allowing a batch orchestration to fan out to multiple invoices that proceed independently.
The child orchestration runs extraction and validation as activities; once results are in history, replays reuse them instead of repeating work.
When validation requires review, the orchestration opens a review and uses a durable timer plus
WaitForExternalEventto express the wait without holding a thread.The external approval event is treated as a hint: the authenticated review endpoint must commit a terminal decision in an application review store before signaling the orchestrator.
A
ResolveInvoiceReviewactivity reads or finalizes the authoritative review ticket, including in the timeout case, so stored decisions override timing of hints.Only a valid automatic assessment or committed approval may proceed to accounting; the accounting activity uses a stable posting key and immutable request fingerprint.
The integration with accounting must reconcile repeated posts using that identity, since durable history cannot guarantee exactly-once posting.
The gain in the invoice case is describing extraction, validation, the review wait, and posting in one place, with Durable Task remembering where the process stopped, instead of writing separate continuation handlers. Authorizing reviewers, persisting their decisions, and making accounting submissions safe to repeat stay with the application; if the existing handlers already do all of that cleanly, another runtime may be unnecessary.
For tenant provisioning, a
TenantCreatedevent signals that the tenant record exists but not that its environment is ready.The provisioning process includes network creation, PostgreSQL server and storage, container app deployment, DNS configuration, readiness checks, and tenant activation.
A direct C# method that sequences Azure helper calls is readable, but the author emphasizes that ARM/Bicep already handles deployment ordering, idempotent reapplication, and provider-side deployment state.
For a single infrastructure deployment, reapplying desired state through ARM/Bicep after a crash may be enough, without involving Durable Task.
The broader onboarding process needs more: acknowledging the request, reporting progress, coordinating readiness with activation, handling external approvals, and deciding what to do with partially provisioned environments.
The design separates resource readiness from tenant activation via an outer orchestration that calls a provisioning sub-orchestration and then an activation activity.
Activation is idempotent and revalidates tenant ownership and resource readiness; a failure in activation fails the outer workflow without automatically deleting provisioned resources.
The onboarding API authorizes and durably admits an immutable request, returns
202 Acceptedplus a status URL, and records tenant, environment, specification, and ownership generation.The scheduler handoff is decoupled from database admission using an outbox; the system reconciles workflow identity instead of assuming dispatch is atomic with persistence.
Inside the provisioning child, resources are created in waves: network first, then database and storage in parallel, then application, DNS, and readiness checks.
Each stage uses activities to start or reconcile cloud operations and separate read activities to poll provider status, with the orchestrator using durable timers instead of performing I/O itself.
A polling budget (e.g., 45 minutes) caps additional checks but does not cancel Azure operations that were already accepted.
The article contrasts two failure windows: one where an Azure operation succeeded but its activity completion was not recorded, and one where completion was recorded and then the worker crashed.
In the first case, Durable Task may redeliver the activity, which must consult an operation journal and stable deployment identity to resume or reconcile instead of starting new resources.
In the second case, replay consumes the recorded result from history without re-invoking the activity.
For cleanup after failed provisioning, the article explains that simply “undoing” steps is unsafe because provider operations may still be in flight.
Before deleting, the application must stop the failed attempt from submitting new provisioning operations, reconcile the state of previously submitted operations (including those with lost acknowledgements), and delete only resources that were created exclusively for this attempt.
Only initial onboarding attempts before tenant activation or customer data admission are eligible for automatic cleanup; shared or existing resources and live data are explicitly out of scope.
Deletion should follow reverse dependency order (DNS, app, database/storage, network) and must be conditioned on up-to-date ownership and provider identity checks.
If the system cannot confidently establish which resources may still be created or are safe to delete, it should mark the outcome as
NeedsInterventionand retain the environment for manual reconciliation.The text introduces fencing tokens as a way to prevent outdated attempts from making new changes when enforced by receivers, clarifying that fencing does not revoke already accepted provider requests.
It also mentions the need to drain and reconcile in-flight operations before declaring cleanup complete, distinguishing this practical requirement from formal concurrency guarantees.
The author notes that
Task.WhenAllis used to understand what succeeded and failed in each provisioning wave but does not perform cleanup automatically; explicit compensation logic is still required.In the payments example, a subscription billing cycle is defined as a single billing period and its associated payment obligation, separate from individual charge attempts and from the overall subscription.
Each cycle has its own ID, due date, amount, currency, and initial payment key; cycles share a subscription ID, and a grace deadline bounds automated recovery work.
The distinction between cycles matters for
ContinueAsNew, which lets the orchestrator move to the next cycle with fresh input after confirming a paid receipt, while keeping the same instance ID and starting a new history.The billing ledger, not DTS, is the source of truth: it binds cycle IDs and payment keys to amounts and currencies and distinguishes states such as
Unknown,Pending,Declined,Paid, andNotCharged.A durable orchestration waits until a cycle’s due date, then invokes an activity that either initiates the first payment (when authorized and known not to be submitted) or reconciles existing payment state.
The recovery loop combines six-hour periodic checks, callbacks, and a fixed grace deadline, with logic to send one bounded reminder under specific conditions.
The orchestrator waits on
WaitForExternalEventwith a timeout; a billing event that arrives there only wakes it up.Each callback is expected to be authenticated, deduplicated, and persisted in a billing inbox or ledger before emitting a hint.
After each wait, the orchestrator calls an activity to read a payment snapshot from the ledger, treating that snapshot as the authoritative state.
A maximum of 16 snapshots bounds the loop; if the payment remains unresolved after grace or checks are exhausted, the outcome is
NeedsReconciliationand must be handled by a durable recovery queue.When a paid receipt is validated, an activity closes the current cycle and obtains the next cycle’s plan; the orchestrator then calls
ContinueAsNewwith new input and discards buffered hints, relying on persisted facts in the ledger.Cancelled subscriptions stop future collection when recorded but do not retroactively remove a charge that has already been accepted.
The payment recovery policy reads as one flow: due date, callbacks, reminders, grace boundary, and the move to the next cycle. The billing ledger still decides whether a payment happened, and the workflow cannot guess, charge again, or replace the existing safeguards; where a single scheduled job already handles recovery without much ceremony, the author would keep the job.
The webhook scenario covers a breaking-news publisher where a CMS emits webhooks on article publication, and a separate service updates a search index.
Articles have strictly increasing revision numbers per generation; problems arise when webhooks arrive out of order, are duplicated, or indexing operations finish in a different order from when they started.
Without protection, a slow update for an older revision could overwrite a newer revision in the search index, yielding stale results for readers.
A conventional handler can be correct if it checks the last applied revision from a checkpoint store, ignores outdated notices, reads an immutable snapshot, applies it to the index, and advances the checkpoint only after the index confirms the revision.
This conventional design assumes the search destination atomically rejects stale revisions and treats duplicate applications idempotently.
A durable entity can add a serialized, persistent record of the highest observed and applied revisions for an article, decoupled from the inbox.
The
DocumentRevisionentity maintainsLastObservedandLastApplied, exposingObserve,Read, andConfirmAppliedoperations that are processed serially per entity key.A
SynchronizeDocumentorchestration can callObservefor incoming notices, wait briefly via a durable timer, read the entity state, fetch the current snapshot from the CMS, and attempt to apply it to the search index.After a successful index write, the orchestrator calls
ConfirmAppliedwith a receipt, allowing the entity to updateLastApplied.The article highlights that entity identity (name and key) governs serialization of entity operations but does not guarantee a single orchestrator; without extra measures, multiple orchestration instances can run for the same article.
To enforce a single active synchronization controller per article, the text suggests the singleton orchestrator pattern, using a stable instance ID derived from the article’s generation-qualified key.
A dispatcher and inbox are responsible for admitting notices, starting controllers if needed, or signaling existing controllers, handling races in controller startup through reconciliation rather than assuming mutual exclusion by responses alone.
The entity’s serialization does not serialize external index writes; different orchestrations can still concurrently attempt to write the same revision based on the same entity snapshot.
Debounce-like behavior or fewer index writes are not guaranteed; any correctness still relies on the index performing an atomic revision check that rejects attempts with stale revision numbers.
If the destination cannot enforce a generation/revision fence, the article recommends other single-writer or fenced-writer protocols instead of relying on the entity.
The inbox/outbox pair must also cover races between a controller’s final read and its completion, ensuring that late notices lead to follow-up work and that reconciliation handles missing webhooks.
Resetting or modifying an entity does not change what the search destination already committed, so index-side revision protection remains essential.
The AI-assisted incident workflow example illustrates why determinism and durable orchestration matter when using models and tools.
The scenario is a production incident assistant that gathers telemetry, asks a model to propose a remediation, waits for an engineer to approve a specific proposal, executes the approved action, and verifies the outcome.
The process may span minutes or hours and must handle worker restarts while ensuring that only the intended proposal is executed and that nondeterministic model outputs are not silently replaced.
A naive asynchronous pipeline can collect logs and metrics, generate a remediation with the model, and open an approval request, but needs separate continuation logic to resume after approval.
If the worker fails after the model generates a proposal but before that proposal is safely recorded, regenerating is actually a new decision, not reliable recovery.
The design separates nondeterministic model calls into activities and keeps the orchestrator deterministic by working with stable references to immutable proposals.
Domain types include an
IncidentPlanwith stable incident and request-generation information,EvidenceBundleholding references to saved telemetry, andProposedRemediationwith a proposal ID, evidence references, canonical action parameters, content fingerprint, and policy version.The
InvestigateIncidentorchestrator uses activities to collect evidence, generate and save a proposal, and open an approval request tied to that proposal.It then creates a durable timer based on an approval deadline and waits for an external approval hint, using the event only as a wake-up signal and validating identities against the plan.
After the wait window, an activity resolves the authoritative approval decision from an approval store, which might be approved, rejected, or expired.
Only an
Approveddecision allows progress; other terminal states cause the orchestration to return an outcome without executing remediation.Execution of remediation is delegated to an activity that must independently revalidate authorization, the proposal fingerprint, current policy, and eligibility before running tools.
A verification activity checks remediation success based on a
RemediationReceipt, and the orchestrator returns an incident outcome that includes verification status and receipt reference.The approval endpoint is responsible for atomically committing a single terminal decision for the specific proposal ID and fingerprint before emitting hints.
GenerateAndSaveProposalmust use a stable identity so that, when its activity acknowledgement is lost, it can reconcile a previously saved proposal instead of generating a new one.Likewise,
ExecuteApprovedRemediationmust rely on stable execution keys and operation journals so that redeliveries reconcile prior execution rather than repeating potentially dangerous actions.Four points where the worker can disappear each get a safe recovery. After telemetry collection is recorded, replay reuses the recorded results. After model generation but before its result is recorded, the stable generation identity retrieves or reconciles the saved proposal, so a new plan never silently replaces one already presented. While waiting for the engineer, the durable wait resumes with the same deadline. After a successful remediation whose completion was not yet recorded, redelivery reconciles the execution key and external receipt instead of acting a second time.
The invariant across failures is that only the specifically authorized proposal is executed and that uncertain side effects are reconciled before continuing work.
The author emphasizes that, in this AI scenario, durability is applied around the agent workflow: Durable Task coordinates evidence collection, proposal approval, action execution, and verification, but does not make the model deterministic or internal agent state fully durable.
This motivation leads to a mention of Durable Agents and Durable Workflows built as extensions to Microsoft Agent Framework, intended to bake durability into agent and workflow programming models directly.
The article notes that these extensions are available in the Microsoft Agent Framework Durable Extension repository and that a separate article will explore how durability inside agents changes the design.
Durable Task remembers what completed, what is still awaited, and where execution continues. Whether a payment really happened, whether an Azure operation is still running, or whether an AI-generated action is still safe to run are questions the application has to answer.
The criterion for adopting it is the point where the code for remembering and resuming a business process starts becoming a system of its own, rather than the presence of a few
awaitcalls. The same test shows up case by case: clean existing continuation handlers in the invoice flow, or one scheduled job that already runs payment recovery, make the extra runtime unnecessary.References are provided for Durable Task documentation and SDKs, Durable Task Scheduler, Durable Agents with Microsoft Agent Framework, the Agent Framework Durable Extension, and a durable-task recovery lab that compares queue/database coordination with DTS-based recovery for tenant onboarding.
As a next step for readers, the article suggests describing one long-running workflow’s authoritative state, stable retry identities, and uncertain external side effects before deciding whether to adopt a durable runtime.
