Skip to content

Commit 6f40862

Browse files
committed
restore changes to tutorials
1 parent 9904ff5 commit 6f40862

File tree

3 files changed

+4
-118
lines changed

3 files changed

+4
-118
lines changed

articles/azure-functions/durable/durable-functions-cloud-backup.md

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,6 @@ After yielding from `context.task_all`, we know that all function calls have com
8686

8787
---
8888

89-
# [Python (V2)](#tab/python-v2)
90-
91-
The function uses the standard *function.json* for orchestrator functions.
92-
93-
[!code-json[Main](~/samples-durable-functions-python/samples/fan_in_fan_out/E2_BackupSiteContent/function.json)]
94-
95-
Here is the code that implements the orchestrator function:
96-
97-
[!code-python[Main](~/samples-durable-functions-python/samples/fan_in_fan_out/E2_BackupSiteContent/\_\_init\_\_.py)]
98-
99-
Notice the `yield context.task_all(tasks);` line. All the individual calls to the `E2_CopyFileToBlob` function were *not* yielded, which allows them to run in parallel. When we pass this array of tasks to `context.task_all`, we get back a task that won't complete *until all the copy operations have completed*. If you're familiar with [`asyncio.gather`](https://docs.python.org/3/library/asyncio-task.html#asyncio.gather) in Python, then this is not new to you. The difference is that these tasks could be running on multiple virtual machines concurrently, and the Durable Functions extension ensures that the end-to-end execution is resilient to process recycling.
100-
101-
> [!NOTE]
102-
> Although tasks are conceptually similar to Python awaitables, orchestrator functions should use `yield` as well as the `context.task_all` and `context.task_any` APIs to manage task parallelization.
103-
104-
After yielding from `context.task_all`, we know that all function calls have completed and have returned values back to us. Each call to `E2_CopyFileToBlob` returns the number of bytes uploaded, so we can calculate the sum total byte count by adding all the return values together.
105-
106-
---
107-
10889
### Helper activity functions
10990

11091
The helper activity functions, as with other samples, are just regular functions that use the `activityTrigger` trigger binding.
@@ -137,16 +118,6 @@ And here is the implementation:
137118

138119
[!code-python[Main](~/samples-durable-functions-python/samples/fan_in_fan_out/E2_GetFileList/\_\_init\_\_.py)]
139120

140-
# [Python (V2)](#tab/python-v2)
141-
142-
The *function.json* file for `E2_GetFileList` looks like the following:
143-
144-
[!code-json[Main](~/samples-durable-functions-python/samples/fan_in_fan_out/E2_GetFileList/function.json)]
145-
146-
And here is the implementation:
147-
148-
[!code-python[Main](~/samples-durable-functions-python/samples/fan_in_fan_out/E2_GetFileList/\_\_init\_\_.py)]
149-
150121
---
151122

152123
> [!NOTE]
@@ -183,16 +154,6 @@ The Python implementation uses the [Azure Storage SDK for Python](https://github
183154

184155
[!code-python[Main](~/samples-durable-functions-python/samples/fan_in_fan_out/E2_CopyFileToBlob/\_\_init\_\_.py)]
185156

186-
# [Python (V2)](#tab/python-v2)
187-
188-
The *function.json* file for `E2_CopyFileToBlob` is similarly simple:
189-
190-
[!code-json[Main](~/samples-durable-functions-python/samples/fan_in_fan_out/E2_CopyFileToBlob/function.json)]
191-
192-
The Python implementation uses the [Azure Storage SDK for Python](https://github.com/Azure/azure-storage-python) to upload the files to Azure Blob Storage.
193-
194-
[!code-python[Main](~/samples-durable-functions-python/samples/fan_in_fan_out/E2_CopyFileToBlob/\_\_init\_\_.py)]
195-
196157
---
197158

198159
The implementation loads the file from disk and asynchronously streams the contents into a blob of the same name in the "backups" container. The return value is the number of bytes copied to storage, that is then used by the orchestrator function to compute the aggregate sum.

articles/azure-functions/durable/durable-functions-phone-verification.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,6 @@ Here is the code that implements the function:
6969

7070
[!code-python[Main](~/samples-durable-functions-python/samples/human_interaction/E4_SmsPhoneVerification/\_\_init\_\_.py)]
7171

72-
> [!NOTE]
73-
> It may not be obvious at first, but this orchestrator does not violate the [deterministic orchestration constraint](durable-functions-code-constraints.md). It is deterministic because the `currentUtcDateTime` property is used to calculate the timer expiration time, and it returns the same value on every replay at this point in the orchestrator code. This behavior is important to ensure that the same `winner` results from every repeated call to `context.df.Task.any`.
74-
>
75-
> # [Python (V2)](#tab/python-v2)
76-
77-
The **E4_SmsPhoneVerification** function uses the standard *function.json* for orchestrator functions.
78-
79-
[!code-json[Main](~/samples-durable-functions-python/samples/human_interaction/E4_SmsPhoneVerification/function.json)]
80-
81-
Here is the code that implements the function:
82-
83-
[!code-python[Main](~/samples-durable-functions-python/samples/human_interaction/E4_SmsPhoneVerification/\_\_init\_\_.py)]
84-
8572
> [!NOTE]
8673
> It may not be obvious at first, but this orchestrator does not violate the [deterministic orchestration constraint](durable-functions-code-constraints.md). It is deterministic because the `currentUtcDateTime` property is used to calculate the timer expiration time, and it returns the same value on every replay at this point in the orchestrator code. This behavior is important to ensure that the same `winner` results from every repeated call to `context.df.Task.any`.
8774
@@ -130,17 +117,6 @@ And here is the code that generates the four-digit challenge code and sends the
130117

131118
[!code-python[Main](~/samples-durable-functions-python/samples/human_interaction/SendSMSChallenge/\_\_init\_\_.py)]
132119

133-
# [Python (V2)](#tab/python-v2)
134-
135-
The *function.json* is defined as follows:
136-
137-
[!code-json[Main](~/samples-durable-functions-python/samples/human_interaction/SendSMSChallenge/function.json)]
138-
139-
And here is the code that generates the four-digit challenge code and sends the SMS message:
140-
141-
[!code-python[Main](~/samples-durable-functions-python/samples/human_interaction/SendSMSChallenge/\_\_init\_\_.py)]
142-
143-
144120
---
145121

146122
## Run the sample

articles/azure-functions/durable/durable-functions-sequence.md

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ The `context` object contains a `df` durable orchestration context object that l
6464

6565
# [Python](#tab/python)
6666

67+
> [!NOTE]
68+
> Python Durable Functions are available for the Functions 3.0 runtime only.
69+
70+
6771
#### function.json
6872

6973
If you use Visual Studio Code or the Azure portal for development, here's the content of the *function.json* file for the orchestrator function. Most orchestrator *function.json* files look almost exactly like this.
@@ -88,28 +92,6 @@ All Python orchestration functions must include the [`durable-functions` package
8892

8993
The `context` object lets you call other *activity* functions and pass input parameters using its `call_activity` method. The code calls `E1_SayHello` three times in sequence with different parameter values, using `yield` to indicate the execution should wait on the async activity function calls to be returned. The return value of each call is returned at the end of the function.
9094

91-
# [Python (V2)](#tab/python-v2)
92-
93-
#### function.json
94-
95-
[!code-json[Main](~/samples-durable-functions-python/samples-v2/function_app.py)]
96-
97-
> [!WARNING]
98-
> To abide by the "no I/O" rule of orchestrator functions, don't use any input or output bindings when using the `orchestrationTrigger` trigger binding. If other input or output bindings are needed, they should instead be used in the context of `activityTrigger` functions, which are called by the orchestrator. For more information, see the [orchestrator function code constraints](durable-functions-code-constraints.md) article.
99-
100-
#### \_\_init\_\_.py
101-
102-
Here is the orchestrator function:
103-
104-
[!code-python[Main](~/samples-durable-functions-python/samples-v2/function_chaining/function_app.py)]
105-
106-
All Python orchestration functions must include the [`durable-functions` package](https://pypi.org/project/azure-functions-durable). It's a library that enables you to write Durable Functions in Python. There are two significant differences between an orchestrator function and other Python functions:
107-
108-
1. The orchestrator function is a [generator function](https://wiki.python.org/moin/Generators).
109-
2. The _file_ should register the orchestrator function as an orchestrator by stating `main = df.Orchestrator.create(<orchestrator function name>)` at the end of the file. This helps distinguish it from other, helper, functions declared in the file.
110-
111-
The `context` object lets you call other *activity* functions and pass input parameters using its `call_activity` method. The code calls `E1_SayHello` three times in sequence with different parameter values, using `yield` to indicate the execution should wait on the async activity function calls to be returned. The return value of each call is returned at the end of the function.
112-
11395
---
11496

11597
## E1_SayHello activity function
@@ -164,25 +146,6 @@ The implementation of `E1_SayHello` is a relatively trivial string formatting op
164146

165147
Unlike the orchestrator function, an activity function needs no special setup. The input passed to it by the orchestrator function is directly accessible as the parameter to the function.
166148

167-
# [Python (V2)](#tab/python-v2)
168-
169-
#### E1_SayHello/function.json
170-
171-
The *function.json* file for the activity function `E1_SayHello` is similar to that of `E1_HelloSequence` except that it uses an `activityTrigger` binding type instead of an `orchestrationTrigger` binding type.
172-
173-
[!code-json[Main](~/samples-durable-functions-python/samples/function_chaining/E1_SayHello/function.json)]
174-
175-
> [!NOTE]
176-
> All activity functions called by an orchestration function must use the `activityTrigger` binding.
177-
178-
The implementation of `E1_SayHello` is a relatively trivial string formatting operation.
179-
180-
#### E1_SayHello/\_\_init\_\_.py
181-
182-
[!code-python[Main](~/samples-durable-functions-python/samples/function_chaining/E1_SayHello/\_\_init\_\_.py)]
183-
184-
Unlike the orchestrator function, an activity function needs no special setup. The input passed to it by the orchestrator function is directly accessible as the parameter to the function.
185-
186149
---
187150

188151
## HttpStart client function
@@ -223,20 +186,6 @@ To interact with orchestrators, the function must include a `durableClient` inpu
223186

224187
Use the `DurableOrchestrationClient` constructor to obtain a Durable Functions client. You use the client to start an orchestration. It can also help you return an HTTP response containing URLs for checking the status of the new orchestration.
225188

226-
# [Python (V2)](#tab/python-v2)
227-
228-
#### HttpStart/function.json
229-
230-
[!code-json[Main](~/samples-durable-functions-python/samples/function_chaining/HttpStart/function.json)]
231-
232-
To interact with orchestrators, the function must include a `durableClient` input binding.
233-
234-
#### HttpStart/\_\_init\_\_.py
235-
236-
[!code-python[Main](~/samples-durable-functions-python/samples/function_chaining/HttpStart/\_\_init\_\_.py)]
237-
238-
Use the `DurableOrchestrationClient` constructor to obtain a Durable Functions client. You use the client to start an orchestration. It can also help you return an HTTP response containing URLs for checking the status of the new orchestration.
239-
240189
---
241190

242191
## Run the sample

0 commit comments

Comments
 (0)