Skip to content

Commit 9987f55

Browse files
authored
Update samples (#236)
1 parent 58779ce commit 9987f55

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

samples/fan_in_fan_out/E2_CopyFileToBlob/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import pathlib
23
from azure.storage.blob import BlobServiceClient
34
from azure.core.exceptions import ResourceExistsError
45

@@ -18,9 +19,11 @@ def main(filePath: str) -> str:
1819
pass
1920

2021
# Create a blob client using the local file name as the name for the blob
21-
blob_client = blob_service_client.get_blob_client(container=container_name, blob=filePath)
22+
parent_dir, fname = pathlib.Path(filePath).parts[-2:] # Get last two path components
23+
blob_name = parent_dir + "_" + fname
24+
blob_client = blob_service_client.get_blob_client(container=container_name, blob=blob_name)
2225

23-
# Count bytes i nfile
26+
# Count bytes in file
2427
byte_count = os.path.getsize(filePath)
2528

2629
# Upload the created file
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import os
2+
from os.path import dirname
23
from typing import List
34

45
def main(rootDirectory: str) -> List[str]:
56

67
all_file_paths = []
7-
# We walk the file system, looking for all files
8-
# below "rootDirectory"
8+
# We walk the file system
99
for path, _, files in os.walk(rootDirectory):
10-
# For each file, we add their full-path to the list
11-
for name in files:
12-
file_path = os.path.join(path, name)
13-
all_file_paths.append(file_path)
10+
# We copy the code for activities and orchestrators
11+
if "E2_" in path:
12+
# For each file, we add their full-path to the list
13+
for name in files:
14+
if name == "__init__.py" or name == "function.json":
15+
file_path = os.path.join(path, name)
16+
all_file_paths.append(file_path)
17+
1418
return all_file_paths

samples/fan_in_fan_out/HttpStart/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import logging
2-
2+
import json
33
import azure.functions as func
44
import azure.durable_functions as df
55

66

77
async def main(req: func.HttpRequest, starter: str) -> func.HttpResponse:
88
client = df.DurableOrchestrationClient(starter)
9-
payload = req.get_body()
9+
payload: str = json.loads(req.get_body().decode()) # Load JSON post request data
1010
instance_id = await client.start_new(req.route_params["functionName"], client_input=payload)
1111

1212
logging.info(f"Started orchestration with ID = '{instance_id}'.")

samples/fan_in_fan_out/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Fan-Out Fan-In
22

3-
This directory contains a executable version of [this](TODO) tutorial. Please review the link above for instructions on how to run it.
3+
This directory contains a executable version of [this](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-cloud-backup?tabs=python) tutorial. Please review the link above for instructions on how to run it.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Function Chaining
22

3-
This directory contains a executable version of [this](TODO) tutorial. Please review the link above for instructions on how to run it.
3+
This directory contains a executable version of [this](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-sequence?tabs=python) tutorial. Please review the link above for instructions on how to run it.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Human Interaction
22

3-
This directory contains a executable version of [this](TODO) tutorial. Please review the link above for instructions on how to run it.
3+
This directory contains a executable version of [this](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-phone-verification?tabs=python) tutorial. Please review the link above for instructions on how to run it.

samples/monitor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Human Interaction
22

3-
This directory contains a executable version of [this](TODO) tutorial. Please review the link above for instructions on how to run it.
3+
This directory contains a executable version of [this](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-monitor-python) tutorial. Please review the link above for instructions on how to run it.

0 commit comments

Comments
 (0)