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
Copy file name to clipboardExpand all lines: articles/azure-functions/durable/quickstart-python-vscode.md
+52-13Lines changed: 52 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,6 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
66
66
| Select a language | Python (Programming Model V2) | Create a local Python Functions project using the V2 programming model. |
67
67
| Select a version | Azure Functions v4 | You only see this option when the Core Tools aren't already installed. In this case, Core Tools are installed the first time you run the app. |
68
68
| Python version | Python 3.7, 3.8, or 3.9 | Visual Studio Code will create a virtual environment with the version you select. |
69
-
| Select a template for your project's first function | Skip for now ||
70
69
| Select how you would like to open your project | Open in current window | Reopens Visual Studio Code in the folder you selected. |
71
70
::: zone-end
72
71
@@ -176,7 +175,7 @@ You now have a Durable Functions app that can be run locally and deployed to Azu
176
175
177
176
::: zone pivot="python-mode-decorators"
178
177
179
-
Using the V2 Python programming model, all these functions can be placed in a single file. To do this, replace the contents of `function_app.py` with the following code.
178
+
To create a basic Durable Functions app using these 3 function types, replace the contents of `function_app.py` with the following Python code.
Review the table below for an explanation of each function and it's purpose in the sample.
211
+
212
+
| Method | Description |
213
+
| ----- | ----------- |
214
+
|**`hello_orchestrator`**| The orchestrator function, which describes the workflow. In this case, the orchestration starts, invokes three functions in a sequence, and returns the ordered results of all 3 functions in a list. |
215
+
|**`hello`**| The activity function, containing the business logic being orchestrator. The function returns a simple greeting to the city passed as an argument. |
216
+
|**`http_start`**| An [HTTP-triggered function](../functions-bindings-http-webhook.md) that starts an instance of the orchestration and returns a check status response. |
217
+
211
218
::: zone-end
212
219
213
220
## Test the function locally
214
221
215
222
Azure Functions Core Tools lets you run an Azure Functions project on your local development computer. If you don't have it installed, you're prompted to install these tools the first time you start a function from Visual Studio Code.
216
223
224
+
::: zone pivot="python-mode-configuration"
225
+
217
226
1. To test your function, set a breakpoint in the `Hello` activity function code (*Hello/\_\_init__.py*). Press <kbd>F5</kbd> or select `Debug: Start Debugging` from the command palette to start the function app project. Output from Core Tools is displayed in the **Terminal** panel.
218
227
228
+
::: zone-end
229
+
230
+
::: zone pivot="python-mode-decorators"
231
+
232
+
1. To test your function, set a breakpoint in the `hello` activity function code. Press <kbd>F5</kbd> or select `Debug: Start Debugging` from the command palette to start the function app project. Output from Core Tools is displayed in the **Terminal** panel.
233
+
234
+
::: zone-end
235
+
219
236
> [!NOTE]
220
237
> For more information on debugging, see [Durable Functions Diagnostics](durable-functions-diagnostics.md#debugging).
221
238
222
-
1. Durable Functions require an Azure storage account to run. When Visual Studio Code prompts you to select a storage account, select **Select storage account**.
239
+
2. Durable Functions require an Azure storage account to run. When Visual Studio Code prompts you to select a storage account, select **Select storage account**.
223
240
224
241
:::image type="content" source="media/quickstart-python-vscode/functions-select-storage.png" alt-text="Screenshot of how to create a storage account.":::
225
242
226
-
1. Follow the prompts and provide the following information to create a new storage account in Azure:
243
+
3. Follow the prompts and provide the following information to create a new storage account in Azure:
227
244
228
245
| Prompt | Value | Description |
229
246
| ------ | ----- | ----------- |
@@ -233,18 +250,20 @@ Azure Functions Core Tools lets you run an Azure Functions project on your local
233
250
| Select a resource group |*unique name*| Name of the resource group to create |
234
251
| Select a location |*region*| Select a region close to you |
235
252
236
-
1. In the **Terminal** panel, copy the URL endpoint of your HTTP-triggered function.
253
+
4. In the **Terminal** panel, copy the URL endpoint of your HTTP-triggered function.
237
254
238
255
:::image type="content" source="media/quickstart-python-vscode/functions-f5.png" alt-text="Screenshot of Azure local output.":::
239
256
240
-
1. Use your browser, or a tool like [Postman](https://www.getpostman.com/) or [cURL](https://curl.haxx.se/), send an HTTP request to the URL endpoint. Replace the last segment with the name of the orchestrator function (`HelloOrchestrator`). The URL must be similar to `http://localhost:7071/api/orchestrators/HelloOrchestrator`.
257
+
5. Use your browser, or a tool like [Postman](https://www.getpostman.com/) or [cURL](https://curl.haxx.se/), send an HTTP request to the URL endpoint. Replace the last segment with the name of the orchestrator function (`HelloOrchestrator`). The URL must be similar to `http://localhost:7071/api/orchestrators/HelloOrchestrator`.
241
258
242
259
The response is the initial result from the HTTP function letting you know the durable orchestration has started successfully. It isn't yet the end result of the orchestration. The response includes a few useful URLs. For now, let's query the status of the orchestration.
243
260
244
-
1. Copy the URL value for `statusQueryGetUri`, paste it in the browser's address bar, and execute the request. Alternatively, you can also continue to use Postman to issue the GET request.
261
+
6. Copy the URL value for `statusQueryGetUri`, paste it in the browser's address bar, and execute the request. Alternatively, you can also continue to use Postman to issue the GET request.
245
262
246
263
The request will query the orchestration instance for the status. You must get an eventual response, which shows the instance has completed and includes the outputs or results of the durable function. It looks like:
247
264
265
+
::: zone pivot="python-mode-configuration"
266
+
248
267
```json
249
268
{
250
269
"name": "HelloOrchestrator",
@@ -261,8 +280,28 @@ Azure Functions Core Tools lets you run an Azure Functions project on your local
261
280
"lastUpdatedTime": "2020-03-18T21:54:54Z"
262
281
}
263
282
```
283
+
::: zone-end
284
+
::: zone pivot="python-mode-decorators"
285
+
```json
286
+
{
287
+
"name": "hello_orchestrator",
288
+
"instanceId": "9a528a9e926f4b46b7d3deaa134b7e8a",
289
+
"runtimeStatus": "Completed",
290
+
"input": null,
291
+
"customStatus": null,
292
+
"output": [
293
+
"Hello Tokyo!",
294
+
"Hello Seattle!",
295
+
"Hello London!"
296
+
],
297
+
"createdTime": "2020-03-18T21:54:49Z",
298
+
"lastUpdatedTime": "2020-03-18T21:54:54Z"
299
+
}
300
+
```
301
+
::: zone-end
302
+
264
303
265
-
1. To stop debugging, press <kbd>Shift+F5</kbd> in Visual Studio Code.
304
+
7. To stop debugging, press <kbd>Shift+F5</kbd> in Visual Studio Code.
266
305
267
306
After you've verified that the function runs correctly on your local computer, it's time to publish the project to Azure.
0 commit comments