Demonstrates all orchestration lifecycle operations: terminate, suspend/resume, restart, continue-as-new, purge, and tags.
| Feature | API |
|---|---|
| Terminate | client.terminateOrchestration() |
| Terminate with output | terminateOptions({ output }) |
| Recursive terminate | terminateOptions({ recursive: true }) |
| Suspend | client.suspendOrchestration() |
| Resume | client.resumeOrchestration() |
| Continue-as-new | ctx.continueAsNew() |
| Restart | client.restartOrchestration() |
| Purge | client.purgeOrchestration() |
| Tags | scheduleNewOrchestration(..., { tags }) |
- Node.js ≥ 22
- Docker (for the DTS Emulator)
cd examples/azure-managed
docker compose up -d
cp .env.emulator .env
cd ../..
npm install && npm run buildnpm run example -- ./examples/azure-managed/lifecycle-management/index.ts=== 1. Terminate (with output) ===
Status: TERMINATED
Output: "Cancelled by admin"
=== 2. Terminate (recursive — parent + child) ===
Parent status: TERMINATED
=== 3. Suspend / Resume ===
After suspend: SUSPENDED
After resume: RUNNING
Final result: "Completed normally"
=== 4. Continue-as-new ===
Status: COMPLETED
Result: {"status":"all batches done","batchNum":3,"processed":9}
=== 5. Restart Orchestration ===
Restarted as new ID: <new-id>
Result: "Done: original-run"
=== 6. Purge Orchestration ===
Purged instances: 1
State after purge: undefined (deleted)
=== 7. Orchestration Tags ===
Tags: {"environment":"staging","owner":"demo-user","priority":"high"}
Result: "Done: tagged-run"
=== All lifecycle demos completed successfully! ===
npm run example -- ./examples/azure-managed/lifecycle-management/index.ts 2>&1 | grep "All lifecycle demos completed successfully"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/lifecycle-management/index.ts