.NET | Durable Functions
Demonstrates attaching custom properties to FailureDetails when an activity throws, using the Durable Task Scheduler (DTS) backend.
When an activity throws a BusinessValidationException, the registered IExceptionPropertiesProvider extracts structured fields (string, int, long, date-time, dictionary, list, null) from the exception. The Durable worker propagates those values onto FailureDetails.Properties, which the orchestration observes when it catches the failure — making rich, typed error context available to the orchestrator instead of just a message and stack trace.
- .NET 8 SDK
- Docker (for running the emulator)
- Azure Functions Core Tools v4
Note: The custom exception property provider requires these minimum versions (the sample references the latest available):
Microsoft.Azure.Functions.Worker.Extensions.DurableTask>= 1.9.0Microsoft.DurableTask.Worker>= 1.16.1 (providesIExceptionPropertiesProvider)Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged>= 1.2.0 (for the Durable Task Scheduler backend)
-
Start the Durable Task Scheduler emulator:
docker run -d -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latest
-
Start the Function app:
cd samples/durable-functions/dotnet/CustomExceptionPropertyProvider func start -
Start the orchestration:
curl -X POST http://localhost:7071/api/orchestrators/customException
-
Follow the
statusQueryGetUrifrom the response to see the completed output. -
View in the dashboard: http://localhost:8082
The orchestration returns the caught FailureDetails, whose Properties carry the custom values supplied by the provider:
{
"errorType": "CustomExceptionPropertyProvider.BusinessValidationException",
"errorMessage": "Business logic validation failed",
"properties": {
"StringProperty": "validation-error-123",
"IntProperty": 100,
"LongProperty": 999999999,
"DateTimeProperty": "2025-10-15T14:30:00Z",
"DictionaryProperty": {
"error_code": "VALIDATION_FAILED",
"retry_count": 3,
"is_critical": true
},
"ListProperty": ["error1", "error2", 500, null],
"NullProperty": null
}
}BusinessExceptionPropertiesProviderimplementsMicrosoft.DurableTask.Worker.IExceptionPropertiesProviderand is registered as a singleton inProgram.cs.BusinessActivitythrows aBusinessValidationExceptioncarrying the structured fields.OrchestrationWithCustomExceptioncalls the activity, catches the propagatedTaskFailedException, and returnsex.FailureDetails— including the customProperties.