You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Like Azure Functions, there are templates to help you develop Durable Functions using [Visual Studio 2019](durable-functions-create-first-csharp.md), [Visual Studio Code](quickstart-js-vscode.md), and the [Azure portal](durable-functions-create-portal.md).
30
+
> [!NOTE]
31
+
> The new programming model for authoring Functions in Python (V2) is currently in preview. Compared to the current model, the new experience is designed to have a more idiomatic and intuitive. To learn more, see Azure Functions Python [developer guide](/azure/azure-functions/functions-reference-python.md?pivots=python-mode-decorators).
32
+
>
33
+
> In the following code snippets, Python (PM2) denotes programming model V2, the new experience.
34
+
35
+
Like Azure Functions, there are templates to help you develop Durable Functions using [Visual Studio](durable-functions-create-first-csharp.md), [Visual Studio Code](quickstart-js-vscode.md), and the [Azure portal](durable-functions-create-portal.md).
30
36
31
37
## Application patterns
32
38
@@ -141,6 +147,29 @@ You can use the `context` object to invoke other functions by name, pass paramet
141
147
> [!NOTE]
142
148
> The `context` object in Python represents the orchestration context. Access the main Azure Functions context using the `function_context` property on the orchestration context.
You can use the `context` object to invoke other functions by name, pass parameters, and return function output. Each time the code calls `yield`, the Durable Functions framework checkpoints the progress of the current function instance. If the process or virtual machine recycles midway through the execution, the function instance resumes from the preceding `yield` call. For more information, see the next section, Pattern #2: Fan out/fan in.
169
+
170
+
> [!NOTE]
171
+
> The `context` object in Python represents the orchestration context. Access the main Azure Functions context using the `function_context` property on the orchestration context.
172
+
144
173
# [PowerShell](#tab/powershell)
145
174
146
175
```PowerShell
@@ -292,6 +321,32 @@ The fan-out work is distributed to multiple instances of the `F2` function. The
292
321
293
322
The automatic checkpointing that happens at the `yield` call on `context.task_all` ensures that a potential midway crash or reboot doesn't require restarting an already completed task.
parallel_tasks = [ context.call_activity("F2", b) for b in work_batch ]
338
+
339
+
outputs =yield context.task_all(parallel_tasks)
340
+
341
+
# Aggregate all N outputs and send the result to F3.
342
+
total =sum(outputs)
343
+
yield context.call_activity("F3", total)
344
+
```
345
+
346
+
The fan-out work is distributed to multiple instances of the `F2` function. The work is tracked by using a dynamic list of tasks. `context.task_all` API is called to wait for all the called functions to finish. Then, the `F2` function outputs are aggregated from the dynamic task list and passed to the `F3` function.
347
+
348
+
The automatic checkpointing that happens at the `yield` call on `context.task_all` ensures that a potential midway crash or reboot doesn't require restarting an already completed task.
# Perform more work here, or let the orchestration end.
602
+
```
603
+
517
604
# [PowerShell](#tab/powershell)
518
605
519
606
```powershell
@@ -699,6 +786,36 @@ main = df.Orchestrator.create(orchestrator_function)
699
786
700
787
To create the durable timer, call `context.create_timer`. The notification is received by `context.wait_for_external_event`. Then, `context.task_any` is called to decide whether to escalate (timeout happens first) or process the approval (the approval is received before timeout).
To create the durable timer, call `context.create_timer`. The notification is received by `context.wait_for_external_event`. Then, `context.task_any` is called to decide whether to escalate (timeout happens first) or process the approval (the approval is received before timeout).
818
+
702
819
# [PowerShell](#tab/powershell)
703
820
704
821
```powershell
@@ -806,13 +923,33 @@ module.exports = async function (context) {
0 commit comments