Implementing Retry Logic in Durable Functions Orchestrations
You have a Durable Functions orchestration that calls an activity function which may throw an exception due to a transient network issue. You want to retry the activity up to 3 times with a 2-second delay between attempts and exponential backoff. Which method should you use in the orchestrator function?
Quick Answer
The answer is to use `CallActivityWithRetryAsync` with a `RetryOptions` object specifying a 2-second initial delay and 3 retry attempts. This method is specifically designed for implementing retry logic in Durable Functions orchestrations, automatically applying exponential backoff between each retry to handle transient network issues gracefully. On the AZ-204 exam, this tests your understanding of how Durable Functions manage fault tolerance in orchestrator functions, often appearing as a scenario where you must distinguish between `CallActivityAsync` (no retry) and `CallActivityWithRetryAsync`. A common trap is forgetting that `RetryOptions` requires a `TimeSpan` for the first retry interval and a maximum attempt count, not a total timeout. Memory tip: think "Retry with Options" — the method name literally tells you it supports configurable retry policies, and exponential backoff is built-in, so you never need to implement it manually.
⚠ Common exam trap
Candidates often confuse `CallActivityWithRetryAsync` with `CallActivityAsync` or `CallSubOrchestratorAsync`, not realizing that only `CallActivityWithRetryAsync` provides the built-in retry mechanism with configurable delay and exponential backoff for activity functions.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
await context.CallActivityWithRetryAsync("MyActivity", new RetryOptions(TimeSpan.FromSeconds(2), 3), input);
The `CallActivityWithRetryAsync` method is specifically designed for retrying activity functions in Durable Functions. It accepts a `RetryOptions` object where you can configure the delay (`TimeSpan.FromSeconds(2)`) and the maximum number of retry attempts (3), and it automatically applies exponential backoff between retries. This directly satisfies the requirement to retry the activity up to 3 times with a 2-second initial delay and exponential backoff.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
await context.CallActivityAsync("MyActivity", input);
Why it's wrong here
Incorrect. CallActivityAsync does not include built-in retry logic.
- ✓
await context.CallActivityWithRetryAsync("MyActivity", new RetryOptions(TimeSpan.FromSeconds(2), 3), input);
Why this is correct
Correct. CallActivityWithRetryAsync with RetryOptions(TimeSpan.FromSeconds(2), 3) implements up to 3 attempts with a 2-second initial delay.
- ✗
await context.CallSubOrchestratorAsync("MyActivity", input);
Why it's wrong here
Incorrect. CallSubOrchestratorAsync is for calling a sub-orchestrator, not an activity, and does not provide retry options.
- ✗
await context.CallHttpAsync(HttpMethod.Get, new Uri("..."), input);
Why it's wrong here
Incorrect. CallHttpAsync is for making HTTP calls, not for calling activity functions.
Visual reference
Go deeper
Related to this question
About these practice questions
One of 881 original AZ-204 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on AZ-204
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. You are implementing a Durable Functions orchestration that calls an activity function which may fail transiently. You want to retry the activity up to 3 times with a 5-second delay and exponential backoff. Which code snippet should you use?
hard- A.await context.CallActivityAsync("Activity", input);
- ✓ B.await context.CallActivityWithRetryAsync("Activity", new RetryOptions(TimeSpan.FromSeconds(5), 3), input);
- C.await context.CallActivityAsync("Activity", input, new RetryOptions(TimeSpan.FromSeconds(5), 3));
- D.Use a durable timer and a loop to retry manually.
Why B: The Durable Functions SDK provides the `CallActivityWithRetryAsync` method, which accepts a `RetryOptions` object to configure retry count and delay. The `RetryOptions` constructor takes `TimeSpan.FromSeconds(5)` as the first retry interval and `3` as the maximum number of attempts, including the initial call. This built-in method handles exponential backoff automatically, eliminating the need for manual retry logic.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.