This project contains core sample orchestrations demonstrating fundamental patterns of the Durable Task Framework using the Azure Storage backend.
- .NET Framework 4.8 or later
- Azure Storage Emulator (Azurite) or Azure Storage account
Configure the connection string in App.config:
<appSettings>
<add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
<add key="taskHubName" value="SamplesHub" />
</appSettings>For Azure Storage, replace UseDevelopmentStorage=true with your connection string (if not using the emulator):
DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...
DurableTask.Samples.exe -cDurableTask.Samples.exe -s <OrchestrationName> [-p <parameters>]The worker automatically starts and waits for the orchestration to complete.
Each sample's full source is linked below. For deeper explanations of the patterns they demonstrate, see the DTFx documentation.
Two activities run in sequence: GetUserTask produces a name, then SendGreetingTask
greets it. A minimal introduction to orchestrations and activities.
- Source: Greetings/GreetingsOrchestration.cs
- Docs: Orchestrations, Activities
- Run:
DurableTask.Samples.exe -s Greetings
A variation that races the GetUserTask activity against a durable timer using
Task.WhenAny, so the orchestration proceeds when the user responds or the timeout
elapses, whichever comes first. The parameter is the timeout in seconds.
- Source: Greetings2/GreetingsOrchestration.cs
- Docs: Timers
- Run:
DurableTask.Samples.exe -s Greetings2 -p 5
Runs CronTask on a schedule, using CreateTimer to wait between runs. The sample loops a
fixed number of times (currently 4) and then returns — it is not an eternal orchestration and
does not use ContinueAsNew. The parameter is a cron
expression (via NCrontab) and is optional (it falls back to a fixed interval when omitted).
- Source: Cron/CronOrchestration.cs
- Docs: Timers
- Run:
DurableTask.Samples.exe -s Cron -p "0 12 * */2 Mon"
A fan-out/fan-in pattern that splits a numeric range into chunks, computes a partial sum
for each chunk in parallel via ComputeSumTask, then aggregates the results into an
average. Parameters are <start> <end> <step>.
- Source: AverageCalculator/AverageCalculatorOrchestration.cs
- Docs: Orchestrations
- Run:
DurableTask.Samples.exe -s Average -p "1 50 10"
Demonstrates exception handling with try/catch around activities and a compensating
CleanupTask when an activity fails.
- Source: ErrorHandling/ErrorHandlingOrchestration.cs
- Docs: Error Handling, Retries
- Run:
DurableTask.Samples.exe -s ErrorHandling
Demonstrates external events using the OnEvent + TaskCompletionSource pattern: the
orchestration waits for an external signal and then sends a greeting with the signaled value.
- Source: Signal/SignalOrchestration.cs
- Docs: External Events
- Run:
DurableTask.Samples.exe -s Signal
To raise an event to a running instance:
DurableTask.Samples.exe -n <eventName> -i <instanceId> -p <eventData>You can also start an instance and raise its first event in one step with the
SignalAndRaise sample:
- Run:
DurableTask.Samples.exe -s SignalAndRaise -n <eventName> -p <eventData>
A recursive fan-out/fan-in example that walks a nested JSON array
(BagofNumbers.json), squaring integers via
SumOfSquaresTask and recursing into nested arrays as sub-orchestrations.
- Source: SumOfSquares/SumOfSquaresOrchestration.cs
- Docs: Sub-Orchestrations
- Run:
DurableTask.Samples.exe -s SumOfSquares
| Option | Description |
|---|---|
-c |
Create the task hub (required on first run) |
-s <name> |
Start the specified orchestration |
-p <params> |
Parameters to pass to the orchestration |
-i <id> |
Instance ID (auto-generated if not specified) |
-n <name> |
Event name for raising events |
-w |
Skip the worker (useful when worker runs separately) |