Demonstrates four fundamental orchestration patterns every Durable Task developer needs.
| Feature | API |
|---|---|
| Activity sequence | ctx.callActivity() in a loop |
| Fan-out/fan-in | whenAll() with parallel callActivity() |
| Sub-orchestrations | ctx.callSubOrchestrator() |
| Race pattern | whenAny() |
- Node.js ≥ 22
- Docker (for the DTS Emulator)
# From the repository root
cd examples/azure-managed
docker compose up -d # start DTS emulator
cp .env.emulator .env # configure for local emulator
cd ../..
npm install && npm run buildnpm run example -- ./examples/azure-managed/hello-orchestrations/index.ts=== 1. Activity Sequence ===
Result: [1,2,3,4,5,6]
=== 2. Fan-out/Fan-in ===
Result: {"items":4,"totalChars":24}
=== 3. Sub-orchestrations ===
Result: {"result1":12,"result2":22}
=== 4. whenAny (Race) ===
Result: {"winnerResult":5}
=== All orchestrations completed successfully! ===
npm run example -- ./examples/azure-managed/hello-orchestrations/index.ts 2>&1 | grep "All orchestrations completed successfully"- Connection refused: Ensure the DTS emulator is running (
docker compose up -dfrom theexamples/azure-manageddirectory). - Worker timeout: The emulator may need a few seconds to start. Retry the command.
To run this sample against a real Azure Managed Durable Task Scheduler instead of the local emulator:
-
Create a scheduler and task hub (if you haven't already) — see the parent README for
az durabletaskcommands. -
Configure
.envfor your cloud endpoint:cd examples/azure-managed cp .env.example .env # Edit .env with your scheduler endpoint and task hub name
Example
.env:DURABLE_TASK_SCHEDULER_CONNECTION_STRING=Endpoint=https://your-scheduler.eastus.durabletask.io;Authentication=DefaultAzure;TaskHub=your-taskhub
-
Authenticate with Azure:
az login
-
Run (no Docker needed):
npm run example -- ./examples/azure-managed/hello-orchestrations/index.ts