You implement a Durable Functions workflow for expense approvals. The orchestrator must wait up to 48 hours for a manager’s approval, then proceed. If no approval is received within 48 hours, it must auto-reject and send a notification. The solution must be resilient to restarts and replays. What should you implement in the orchestrator?
Choose an answer
Tap an option to check your answer.
Correct answer: Wait for an external event (e.g., "Approved") and create a durable timer for 48 hours, await Task.WhenAny(eventTask, timerTask), cancel the timer if approval arrives first, otherwise continue with rejection..
Why this is the answer
The correct approach uses Task.WhenAny with an external event and a durable timer. Durable Functions are deterministic, so Task.WhenAny correctly handles race conditions between the event and the timer. If the approval event arrives first, the timer is cancelled, preventing unnecessary execution. If the timer expires first, the orchestrator proceeds with auto-rejection. This pattern is resilient to orchestrator restarts and replays because durable timers and external event subscriptions are managed by the Durable Task Framework, ensuring state is preserved. Incorrect options: Polling a database with Thread.Sleep is inefficient, non-deterministic, and not resilient to orchestrator restarts. Thread.Sleep is not allowed in orchestrator functions. Thread.Sleep in an orchestrator function is non-deterministic and will cause replay issues. Orchestrators must not block threads directly. Using queue messages with invisibility delays for timeouts is an anti-pattern for Durable Functions. The framework provides built-in durable timers for this purpose.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed