Skip to content

Commit 136a3d0

Browse files
committed
Adressing review feedback
Signed-off-by: Ryan Lettieri <[email protected]>
1 parent 026c572 commit 136a3d0

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Examples
22

3-
This directory contains examples of how to author durable orchestrations using the Durable Task Python SDK. There are two backends that are compatible with the Durable Task Python SDK: The Dapr sidecar, and the Durable Task Scheduler (DTS)
3+
This directory contains examples of how to author durable orchestrations using the Durable Task Python SDK. There are two backends that are compatible with the Durable Task Python SDK: The Dapr sidecar, and the Durable Task Scheduler (DTS).
44

55
## Prerequisites for using Dapr
66

examples/dts/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Examples
2+
3+
This directory contains examples of how to author durable orchestrations using the Durable Task Python SDK in conjunction with the Durable Task Scheduler (DTS).
4+
5+
## Prerequisites
6+
7+
All the examples assume that you have a Durable Task Scheduler taskhub created.
8+
9+
The simplest way to create a taskhub is by using the az cli commands:
10+
11+
1. Create a scheduler:
12+
az durabletask scheduler create --resource-group <testrg> --name <testscheduler> --location <eastus> --ip-allowlist "[0.0.0.0/0]" --sku-capacity 1 --sku-name "Dedicated" --tags "{}"
13+
14+
2. Create your taskhub
15+
az durabletask taskhub create --resource-group <testrg> --scheduler-name <testscheduler> --name <testtaskhub>
16+
17+
3. Retrieve the endpoint for the scheduler. This can be done by locating the taskhub in the portal.
18+
19+
4. Set the appropriate environment variables for the TASKHUB and ENDPOINT
20+
21+
```sh
22+
export TASKHUB=<taskhubname>
23+
```
24+
25+
```sh
26+
export ENDPOINT=<taskhubEndpoint>
27+
```
28+
29+
## Running the examples
30+
31+
With one of the sidecars running, you can simply execute any of the examples in this directory using `python3`:
32+
33+
```sh
34+
python3 dts_activity_sequence.py
35+
```

examples/dts_activity_sequence.py renamed to examples/dts/dts_activity_sequence.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ def sequence(ctx: task.OrchestrationContext, _):
4141
if endpoint:
4242
print(f"The value of ENDPOINT is: {endpoint}")
4343
else:
44-
print("ENDPOINT is not set. Please set the ENDPOINT environment variable to the endpoint of the taskhub")
45-
print("If you are using windows powershell, run the following: $env:ENDPOINT=\"<taskhubEndpoint>\"")
46-
print("If you are using bash, run the following: export ENDPOINT=\"<taskhubEndpoint>\"")
44+
print("ENDPOINT is not set. Please set the ENDPOINT environment variable to the endpoint of the scheduler")
45+
print("If you are using windows powershell, run the following: $env:ENDPOINT=\"<schedulerEndpoint>\"")
46+
print("If you are using bash, run the following: export ENDPOINT=\"<schedulerEndpoint>\"")
4747
exit()
4848

4949

5050
default_credential = DefaultAzureCredential()
5151
# Define the scope for Azure Resource Manager (ARM)
5252
arm_scope = "https://durabletask.io/.default"
5353

54-
# Retrieve the access token
54+
# Retrieve the access token. Note that this approach doesn't support token refresh and can't be used in production.
5555
access_token = "Bearer " + default_credential.get_token(arm_scope).token
56-
# create a client, start an orchestration, and wait for it to finish
56+
5757
metaData: list[tuple[str, str]] = [
58-
("taskhub", taskhub_name), # Hardcode for now, just the taskhub name
59-
("authorization", access_token) # use azure identity sdk for python
58+
("taskhub", taskhub_name),
59+
("authorization", access_token)
6060
]
6161
# configure and start the worker
6262
with worker.TaskHubGrpcWorker(host_address=endpoint, metadata=metaData, secure_channel=True) as w:

0 commit comments

Comments
 (0)