Retry Error Handling for Activities and Orchestrations in Azure Durable Functions

Azure Durable Functions provides a rich set of Error Handling APIs. This post shows how Activities or Sub-Orchestrations can be re-run with the different retry options.

Activities in a workflow can call an API or run a code flow which might fail due to connection problems, network timeouts or other similar problems. If it was run a second time, it might succeed, and the flow could then complete successfully. For this, a retry Error Handling can be implemented. The HttpClient in .NET Core can implement this by using Polly. Azure Durable functions supports this directly without requiring extra Nuget packages. This can also be used to retry whole sub-orchestrations and not just single Http API calls.


Posts in this series

Retrying Azure Durable Function Activities.

The IDurableOrchestrationContext interface provides the Retry Error Handling APIs in Azure Durable Functions. This interface is added as a parameter in the Azure Function using the OrchestrationTrigger.

public async Task<MyOrchestrationDto> RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context,
ILogger log)

The RetryOptions class provides the configuration for the different Retry calls. This can be used to set max timeouts, a fall off for retrying, or whatever configuration you might require.

The CallActivityWithRetryAsync method can then be called and if the Activity being called fails, the retry options will be used to re-run the activity until the max has be reached or it succeeds. If the activity continues to throw exceptions, the Durable function will complete with a Failed status, unless otherwise set.

var retryOptions = new RetryOptions(
	firstRetryInterval: TimeSpan.FromSeconds(3),
	maxNumberOfAttempts: 5)
	BackoffCoefficient = 1.5

var myActivityThreeResult = 
	await context.CallActivityWithRetryAsync<string> (

Retrying Azure Durable Function Sub-Orchestrations.

Polly provides the same functionality when calling APIs. What’s nice about retry in Azure Durable Functions is that the Retry Error Handling can be applied to complete Orchestrations. If any part of the sub-orchestration fails, the whole thing can be re-run using this error handling. This can be implemented using the CallSubOrchestratorWithRetryAsync method.

var mySubOrchestrationDto = 
	await context.CallSubOrchestratorWithRetryAsync<MySubOrchestrationDto> (

If we add an Exception one on the activities, we can see the retry APIs running and view the status of the orchestration running. (You need to set the showhistory=true)


Microsoft Azure Storage Explorer

Microsoft Azure Storage Emulator

Install the Azure Functions Core Tools


Azure CLI

Azure SDK

Visual Studio zure development extensions


  1. […] Retry Error Handling for Activities and Orchestrations in Azure Durable Functions (Damien Bowden) […]

  2. […] Retry Error Handling for Activities and Orchestrations in Azure Durable Functions – Damien Bowden […]

  3. Hi, I have been trying to find some documentation on what happens with a Durable function execution if the request that triggered it times out, but there are no errors in the function itself? For example, a Power Automate Flow sending an HTTP request to a durable function, and that request action times out due to hitting the configured timeout limit, does the Durable function keep going, or is it cancelled? In this scenario, I can’t find any trace of this function execution in Application Insights, and can’t tell if the function did its job or was cancelled.

    1. Hi JD this will be persisted in the storage, you can check this using azure functions monitor, or just check the storage yourself. With the monitor you can then re-run cancel or whatever.

      Greetings Damien

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: