Question

Difficulty: MediumImplement Durable Functions

You are developing a serverless order processing workflow using Azure Durable Functions. The workflow is initiated via an HTTP request, performs a payment processing activity, and then runs a receipt generation activity.

Arrange the execution and execution replay events of the Durable Functions runtime in the correct sequential order from the arrival of the initial client request to the execution of the second activity.

  1. 1The client function is triggered by an HTTP request, calls the Durable Client binding to start the orchestration, and returns an HTTP 202 response containing status check endpoints.
  2. 2The orchestrator function begins execution, writes a start event to the history table, and schedules the first activity function (payment processing) using an awaited call.
  3. 3The orchestrator function yields execution (enters a suspended state) to save resources, while the runtime assigns the payment processing activity to an execution worker.
  4. 4The payment processing activity completes, its output is logged in the Azure Storage history table, and a message is queued to resume the orchestrator.
  5. 5The orchestrator function wakes up and replays from the beginning, pulling the payment processing result from history instead of re-running the activity, then schedules the receipt generation activity.

Answer

The correct sequence begins with the client function initiating the orchestrator and returning a response, followed by the orchestrator starting and scheduling the first activity. The orchestrator then yields execution while the activity runs. After the activity completes and logs its output to history, the orchestrator wakes up, replays from the beginning, retrieves the activity output from history, and schedules the second activity.
The correct sequence mirrors the fundamental event-sourcing and execution replay design of Durable Functions. The workflow is started by a client function returning status endpoints. Then, the orchestrator begins, schedules the first activity, and yields. When the activity finishes, its outcome is recorded in Azure Storage, triggering the orchestrator to wake up, replay from the beginning using history, and proceed to the next activity.

Step-by-Step Solution

1
Trigger the orchestration client.
The client function starts the orchestration instance and returns an HTTP 202 response.
Durable workflows are kicked off by a starter client function which generates the management endpoints.
2
Begin orchestrator execution and schedule the first activity.
The orchestrator runs and calls the payment activity using an await expression.
The orchestrator must schedule the first task in the sequence.
3
Yield orchestrator execution.
The orchestrator goes to sleep, saving execution state.
Yielding execution ensures that compute resources are not wasted while waiting for long-running activities.
4
Log activity completion.
The completed activity's return value is saved to the history table in storage.
The runtime relies on persistent storage history to reconstruct the workflow state.
5
Replay the orchestrator and schedule the next activity.
The orchestrator executes again, reads the payment result from history, and schedules the receipt activity.
To maintain state safely, the orchestrator replays its code, bypassing completed tasks recorded in the history table.

Key Concept

Replay mechanism and event sourcing in Azure Durable Functions
Rate this question