Skip to content

Commit df57748

Browse files
committed
cleanup
1 parent 399bce7 commit df57748

11 files changed

Lines changed: 282 additions & 40 deletions

File tree

.github/workflows/validate-samples.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ jobs:
212212
echo "No-emulator result: ${{ needs.samples-no-emulator.result }}"
213213
echo "Emulator result: ${{ needs.samples-with-emulator.result }}"
214214
215-
if [[ "${{ needs.samples-no-emulator.result }}" == "failure" ]] || \
216-
[[ "${{ needs.samples-with-emulator.result }}" == "failure" ]]; then
217-
echo "❌ Some samples failed!"
215+
if [[ ! "${{ needs.samples-no-emulator.result }}" =~ ^(success|skipped)$ ]] || \
216+
[[ ! "${{ needs.samples-with-emulator.result }}" =~ ^(success|skipped)$ ]]; then
217+
echo "❌ Some samples failed or were cancelled!"
218218
exit 1
219219
fi
220220
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
# Azure Managed Durable Task Scheduler (DTS) Configuration
22
# Copy this file to .env and update the values for your environment.
3+
#
4+
# To find your endpoint, run:
5+
# az durabletask scheduler show --resource-group <rg> --name <scheduler> --query endpoint -o tsv
6+
#
7+
# Make sure you have the "Durable Task Data Contributor" role assigned on the scheduler resource.
8+
# Authenticate via: az login
9+
310
# Option 1: Using connection string (recommended)
4-
# Supported authentication types: DefaultAzure, ManagedIdentity, WorkloadIdentity,
11+
# Supported authentication types: DefaultAzure, ManagedIdentity, WorkloadIdentity,
512
# Environment, AzureCli, AzurePowerShell, VisualStudioCode, InteractiveBrowser, None
13+
# Use Authentication=None only for the local emulator.
614
DURABLE_TASK_SCHEDULER_CONNECTION_STRING=Endpoint=https://your-scheduler.eastus.durabletask.io;Authentication=DefaultAzure;TaskHub=your-taskhub
15+
716
# Option 2: Using explicit parameters (uses DefaultAzureCredential)
817
# Uncomment these lines and comment out DURABLE_TASK_SCHEDULER_CONNECTION_STRING above
918
# AZURE_DTS_ENDPOINT=https://your-scheduler.eastus.durabletask.io
10-
# AZURE_DTS_TASKHUB=your-taskhub
19+
# AZURE_DTS_TASKHUB=your-taskhub
20+
21+
# Optional: OTLP endpoint for distributed tracing (Jaeger, Azure Monitor, Aspire Dashboard, etc.)
22+
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

examples/azure-managed/README.md

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Runnable samples demonstrating every major feature of the Durable Task JavaScrip
66

77
| Sample | Scenario | Key Features | Emulator Required |
88
|--------|----------|-------------|-------------------|
9-
| [hello-orchestrations](hello-orchestrations/) | Core patterns | Activity sequence, fan-out/fan-in, sub-orchestrations, `whenAny`, deterministic GUID | Yes |
9+
| [hello-orchestrations](hello-orchestrations/) | Core patterns | Activity sequence, fan-out/fan-in, sub-orchestrations, `whenAny` | Yes |
1010
| [retry-and-error-handling](retry-and-error-handling/) | Fault tolerance | `RetryPolicy`, `handleFailure`, `AsyncRetryHandler`, sub-orchestration retry, `raiseIfFailed()` | Yes |
1111
| [human-interaction](human-interaction/) | Event-driven workflows | External events, timers, `whenAny` race, `sendEvent`, custom status | Yes |
1212
| [lifecycle-management](lifecycle-management/) | Orchestration control | Terminate (recursive), suspend/resume, restart, continue-as-new, purge, tags | Yes |
@@ -16,7 +16,7 @@ Runnable samples demonstrating every major feature of the Durable Task JavaScrip
1616
| [index.ts](index.ts) | Azure-managed basics | Connection strings, `DefaultAzureCredential`, `createAzureManagedClient` | Yes |
1717
| [distributed-tracing.ts](distributed-tracing.ts) | OpenTelemetry tracing | `NodeSDK`, OTLP export, Jaeger, `DurableTaskAzureManagedClientBuilder` | Yes |
1818

19-
### Quick Start
19+
### Quick Start (Local Emulator)
2020

2121
```bash
2222
npm install && npm run build # build SDK
@@ -26,6 +26,74 @@ cd ../..
2626
npm run example -- ./examples/azure-managed/hello-orchestrations/index.ts
2727
```
2828

29+
### Quick Start (Azure Managed DTS — Cloud)
30+
31+
To run samples against a **real Azure Managed Durable Task Scheduler** instead of the local emulator:
32+
33+
#### 1. Create a Durable Task Scheduler resource
34+
35+
If you haven't already, create a Durable Task Scheduler and a Task Hub in Azure:
36+
37+
```bash
38+
# Install the Durable Task Scheduler CLI extension
39+
az extension add --name durabletask
40+
41+
# Create a scheduler
42+
az durabletask scheduler create \
43+
--resource-group <your-rg> \
44+
--name <your-scheduler-name> \
45+
--location <region> \
46+
--sku free
47+
48+
# Create a task hub
49+
az durabletask taskhub create \
50+
--resource-group <your-rg> \
51+
--scheduler-name <your-scheduler-name> \
52+
--name <your-taskhub-name>
53+
```
54+
55+
#### 2. Assign yourself the "Durable Task Data Contributor" role
56+
57+
```bash
58+
SCHEDULER_ID=$(az durabletask scheduler show \
59+
--resource-group <your-rg> \
60+
--name <your-scheduler-name> \
61+
--query id -o tsv)
62+
63+
az role assignment create \
64+
--assignee $(az ad signed-in-user show --query id -o tsv) \
65+
--role "Durable Task Data Contributor" \
66+
--scope $SCHEDULER_ID
67+
```
68+
69+
#### 3. Configure your `.env` file
70+
71+
```bash
72+
cd examples/azure-managed
73+
cp .env.example .env
74+
```
75+
76+
Edit `.env` with your scheduler's endpoint and task hub name:
77+
78+
```env
79+
# Option A: Connection string (recommended)
80+
DURABLE_TASK_SCHEDULER_CONNECTION_STRING=Endpoint=https://<your-scheduler>.eastus.durabletask.io;Authentication=DefaultAzure;TaskHub=<your-taskhub>
81+
82+
# Option B: Explicit parameters
83+
# AZURE_DTS_ENDPOINT=https://<your-scheduler>.eastus.durabletask.io
84+
# AZURE_DTS_TASKHUB=<your-taskhub>
85+
```
86+
87+
#### 4. Authenticate and run
88+
89+
```bash
90+
az login # authenticate with Azure
91+
cd ../.. # back to repo root
92+
npm run example -- ./examples/azure-managed/hello-orchestrations/index.ts
93+
```
94+
95+
> **Supported authentication types** in the connection string: `DefaultAzure`, `ManagedIdentity`, `WorkloadIdentity`, `Environment`, `AzureCli`, `AzurePowerShell`, `VisualStudioCode`, `InteractiveBrowser`.
96+
2997
See each sample's README for details. See [Feature Coverage Map](#feature-coverage-map) below for full feature mapping.
3098

3199
### CI Validation
@@ -53,7 +121,7 @@ done
53121
| `whenAll()` | hello-orchestrations, unit-testing |
54122
| `whenAny()` | hello-orchestrations, human-interaction |
55123
| `ctx.callSubOrchestrator()` | hello-orchestrations, retry-and-error-handling, lifecycle-management |
56-
| `ctx.newGuid()` | hello-orchestrations |
124+
57125
| `ctx.waitForExternalEvent()` | human-interaction, unit-testing |
58126
| `client.raiseOrchestrationEvent()` | human-interaction, unit-testing |
59127
| `ctx.createTimer()` | human-interaction, query-and-history, unit-testing |

examples/azure-managed/hello-orchestrations/README.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Hello Orchestrations
22

3-
Demonstrates the five fundamental orchestration patterns every Durable Task developer needs.
3+
Demonstrates four fundamental orchestration patterns every Durable Task developer needs.
44

55
## Features Covered
66

@@ -10,7 +10,6 @@ Demonstrates the five fundamental orchestration patterns every Durable Task deve
1010
| Fan-out/fan-in | `whenAll()` with parallel `callActivity()` |
1111
| Sub-orchestrations | `ctx.callSubOrchestrator()` |
1212
| Race pattern | `whenAny()` |
13-
| Deterministic GUID | `ctx.newGuid()` |
1413

1514
## Prerequisites
1615

@@ -49,9 +48,6 @@ Result: {"result1":12,"result2":22}
4948
=== 4. whenAny (Race) ===
5049
Result: {"winnerResult":5}
5150
52-
=== 5. Deterministic GUID ===
53-
Result: {"guid1":"<uuid>","guid2":"<uuid>","areDifferent":true}
54-
5551
=== All orchestrations completed successfully! ===
5652
```
5753

@@ -65,3 +61,35 @@ npm run example -- ./examples/azure-managed/hello-orchestrations/index.ts 2>&1 |
6561

6662
- **Connection refused**: Ensure the DTS emulator is running (`docker compose up -d` from the `examples/azure-managed` directory).
6763
- **Worker timeout**: The emulator may need a few seconds to start. Retry the command.
64+
65+
## Running Against Azure Managed DTS (Cloud)
66+
67+
To run this sample against a real [Azure Managed Durable Task Scheduler](https://learn.microsoft.com/azure/durable-task-scheduler/) instead of the local emulator:
68+
69+
1. **Create a scheduler and task hub** (if you haven't already) — see the [parent README](../README.md#quick-start-azure-managed-dts--cloud) for `az durabletask` commands.
70+
71+
2. **Configure `.env`** for your cloud endpoint:
72+
73+
```bash
74+
cd examples/azure-managed
75+
cp .env.example .env
76+
# Edit .env with your scheduler endpoint and task hub name
77+
```
78+
79+
Example `.env`:
80+
81+
```env
82+
DURABLE_TASK_SCHEDULER_CONNECTION_STRING=Endpoint=https://your-scheduler.eastus.durabletask.io;Authentication=DefaultAzure;TaskHub=your-taskhub
83+
```
84+
85+
3. **Authenticate** with Azure:
86+
87+
```bash
88+
az login
89+
```
90+
91+
4. **Run** (no Docker needed):
92+
93+
```bash
94+
npm run example -- ./examples/azure-managed/hello-orchestrations/index.ts
95+
```

examples/azure-managed/hello-orchestrations/index.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// 2. Fan-out/fan-in — run activities in parallel, aggregate results
88
// 3. Sub-orchestrations — compose orchestrators hierarchically
99
// 4. whenAny — race multiple tasks, use winner's result
10-
// 5. Deterministic GUID — generate replay-safe unique IDs
1110

1211
import * as dotenv from "dotenv";
1312
import * as path from "path";
@@ -41,11 +40,6 @@ const processItem = async (_ctx: ActivityContext, item: string): Promise<number>
4140
return item.length;
4241
};
4342

44-
/** Return a greeting string for the given name. */
45-
const greet = async (_ctx: ActivityContext, name: string): Promise<string> => {
46-
return `Hello, ${name}!`;
47-
};
48-
4943
/** Child orchestration: adds two to the input via two plusOne activity calls. */
5044
const doubleOrchestrator: TOrchestrator = async function* (ctx: OrchestrationContext, value: number): any {
5145
const doubled: number = yield ctx.callActivity(plusOne, value);
@@ -102,17 +96,6 @@ const raceOrchestrator: TOrchestrator = async function* (ctx: OrchestrationConte
10296
return { winnerResult: winner.getResult() };
10397
};
10498

105-
/** 5. Deterministic GUID — generates replay-safe unique IDs. */
106-
const guidOrchestrator: TOrchestrator = async function* (ctx: OrchestrationContext): any {
107-
// Call an activity so the generator has at least one yield point
108-
const label: string = yield ctx.callActivity(greet, "GUID demo");
109-
const guid1 = ctx.newGuid();
110-
const guid2 = ctx.newGuid();
111-
112-
// These GUIDs are deterministic: same values across replays
113-
return { label, guid1, guid2, areDifferent: guid1 !== guid2 };
114-
};
115-
11699
// ---------------------------------------------------------------------------
117100
// Main
118101
// ---------------------------------------------------------------------------
@@ -136,10 +119,8 @@ const guidOrchestrator: TOrchestrator = async function* (ctx: OrchestrationConte
136119
.addOrchestrator(parentOrchestrator)
137120
.addOrchestrator(doubleOrchestrator)
138121
.addOrchestrator(raceOrchestrator)
139-
.addOrchestrator(guidOrchestrator)
140122
.addActivity(plusOne)
141123
.addActivity(processItem)
142-
.addActivity(greet)
143124
.build();
144125

145126
try {
@@ -174,13 +155,6 @@ const guidOrchestrator: TOrchestrator = async function* (ctx: OrchestrationConte
174155
console.log(`Result: ${raceState?.serializedOutput}`);
175156
// Expected: {"winnerResult":<length of whichever completed first>}
176157

177-
// --- 5. Deterministic GUID ---
178-
console.log("\n=== 5. Deterministic GUID ===");
179-
const guidId = await client.scheduleNewOrchestration(guidOrchestrator);
180-
const guidState = await client.waitForOrchestrationCompletion(guidId, true, 30);
181-
console.log(`Result: ${guidState?.serializedOutput}`);
182-
// Expected: {"guid1":"<uuid>","guid2":"<uuid>","areDifferent":true}
183-
184158
console.log("\n=== All orchestrations completed successfully! ===");
185159
} catch (error) {
186160
console.error("Error:", error);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "hello-orchestrations",
3-
"description": "Core orchestration patterns: activity sequences, fan-out/fan-in, sub-orchestrations, whenAny, and deterministic GUIDs",
3+
"description": "Core orchestration patterns: activity sequences, fan-out/fan-in, sub-orchestrations, whenAny",
44
"requiresEmulator": true
55
}

examples/azure-managed/human-interaction/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,35 @@ Result: {"event1":"Hello","event2":"World"}
6161
```bash
6262
npm run example -- ./examples/azure-managed/human-interaction/index.ts 2>&1 | grep "All human-interaction demos completed successfully"
6363
```
64+
65+
## Running Against Azure Managed DTS (Cloud)
66+
67+
To run this sample against a real [Azure Managed Durable Task Scheduler](https://learn.microsoft.com/azure/durable-task-scheduler/) instead of the local emulator:
68+
69+
1. **Create a scheduler and task hub** (if you haven't already) — see the [parent README](../README.md#quick-start-azure-managed-dts--cloud) for `az durabletask` commands.
70+
71+
2. **Configure `.env`** for your cloud endpoint:
72+
73+
```bash
74+
cd examples/azure-managed
75+
cp .env.example .env
76+
# Edit .env with your scheduler endpoint and task hub name
77+
```
78+
79+
Example `.env`:
80+
81+
```env
82+
DURABLE_TASK_SCHEDULER_CONNECTION_STRING=Endpoint=https://your-scheduler.eastus.durabletask.io;Authentication=DefaultAzure;TaskHub=your-taskhub
83+
```
84+
85+
3. **Authenticate** with Azure:
86+
87+
```bash
88+
az login
89+
```
90+
91+
4. **Run** (no Docker needed):
92+
93+
```bash
94+
npm run example -- ./examples/azure-managed/human-interaction/index.ts
95+
```

examples/azure-managed/lifecycle-management/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,35 @@ Result: "Done: tagged-run"
7676
```bash
7777
npm run example -- ./examples/azure-managed/lifecycle-management/index.ts 2>&1 | grep "All lifecycle demos completed successfully"
7878
```
79+
80+
## Running Against Azure Managed DTS (Cloud)
81+
82+
To run this sample against a real [Azure Managed Durable Task Scheduler](https://learn.microsoft.com/azure/durable-task-scheduler/) instead of the local emulator:
83+
84+
1. **Create a scheduler and task hub** (if you haven't already) — see the [parent README](../README.md#quick-start-azure-managed-dts--cloud) for `az durabletask` commands.
85+
86+
2. **Configure `.env`** for your cloud endpoint:
87+
88+
```bash
89+
cd examples/azure-managed
90+
cp .env.example .env
91+
# Edit .env with your scheduler endpoint and task hub name
92+
```
93+
94+
Example `.env`:
95+
96+
```env
97+
DURABLE_TASK_SCHEDULER_CONNECTION_STRING=Endpoint=https://your-scheduler.eastus.durabletask.io;Authentication=DefaultAzure;TaskHub=your-taskhub
98+
```
99+
100+
3. **Authenticate** with Azure:
101+
102+
```bash
103+
az login
104+
```
105+
106+
4. **Run** (no Docker needed):
107+
108+
```bash
109+
npm run example -- ./examples/azure-managed/lifecycle-management/index.ts
110+
```

examples/azure-managed/query-and-history/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,35 @@ Created 6 orchestration instances.
7272
```bash
7373
npm run example -- ./examples/azure-managed/query-and-history/index.ts 2>&1 | grep "All query/history demos completed successfully"
7474
```
75+
76+
## Running Against Azure Managed DTS (Cloud)
77+
78+
To run this sample against a real [Azure Managed Durable Task Scheduler](https://learn.microsoft.com/azure/durable-task-scheduler/) instead of the local emulator:
79+
80+
1. **Create a scheduler and task hub** (if you haven't already) — see the [parent README](../README.md#quick-start-azure-managed-dts--cloud) for `az durabletask` commands.
81+
82+
2. **Configure `.env`** for your cloud endpoint:
83+
84+
```bash
85+
cd examples/azure-managed
86+
cp .env.example .env
87+
# Edit .env with your scheduler endpoint and task hub name
88+
```
89+
90+
Example `.env`:
91+
92+
```env
93+
DURABLE_TASK_SCHEDULER_CONNECTION_STRING=Endpoint=https://your-scheduler.eastus.durabletask.io;Authentication=DefaultAzure;TaskHub=your-taskhub
94+
```
95+
96+
3. **Authenticate** with Azure:
97+
98+
```bash
99+
az login
100+
```
101+
102+
4. **Run** (no Docker needed):
103+
104+
```bash
105+
npm run example -- ./examples/azure-managed/query-and-history/index.ts
106+
```

0 commit comments

Comments
 (0)