Skip to content

Commit 4684b4f

Browse files
committed
small edits to formatting
1 parent a0a0f8d commit 4684b4f

File tree

2 files changed

+53
-14
lines changed

2 files changed

+53
-14
lines changed

articles/azure-functions/durable/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
- name: Create durable function - JavaScript
2727
displayName: get started, chaining
2828
href: quickstart-js-vscode.md
29-
- name: CReate durable function - Python
29+
- name: Create durable function - Python
3030
displayName: get started, chaining
3131
href: quickstart-python-vscode.md
3232
- name: Create durable function - PowerShell

articles/azure-functions/durable/quickstart-python-vscode.md

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
6666
| Select a language | Python (Programming Model V2) | Create a local Python Functions project using the V2 programming model. |
6767
| 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. |
6868
| 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 | |
7069
| Select how you would like to open your project | Open in current window | Reopens Visual Studio Code in the folder you selected. |
7170
::: zone-end
7271

@@ -176,7 +175,7 @@ You now have a Durable Functions app that can be run locally and deployed to Azu
176175
177176
::: zone pivot="python-mode-decorators"
178177
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.
180179
181180
```Python
182181
import azure.functions as func
@@ -187,43 +186,61 @@ myApp = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)
187186
# An HTTP-Triggered Function with a Durable Functions Client binding
188187
@myApp.route(route="orchestrators/{functionName}")
189188
@myApp.durable_client_input(client_name="client")
190-
async def durable_trigger(req: func.HttpRequest, client):
189+
async def http_start(req: func.HttpRequest, client):
191190
function_name = req.route_params.get('functionName')
192191
instance_id = await client.start_new(function_name)
193192
response = client.create_check_status_response(req, instance_id)
194193
return response
195194
196195
# Orchestrator
197196
@myApp.orchestration_trigger(context_name="context")
198-
def my_orchestrator(context):
197+
def hello_orchestrator(context):
199198
result1 = yield context.call_activity("hello", "Seattle")
200199
result2 = yield context.call_activity("hello", "Tokyo")
201200
result3 = yield context.call_activity("hello", "London")
202201
203202
return [result1, result2, result3]
204203
205204
# Activity
206-
@myApp.activity_trigger(input_name="myInput")
207-
def hello(myInput: str):
208-
return "Hello " + myInput
205+
@myApp.activity_trigger(input_name="city")
206+
def hello(city: str):
207+
return "Hello " + city
209208
```
210209

210+
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+
211218
::: zone-end
212219

213220
## Test the function locally
214221

215222
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.
216223

224+
::: zone pivot="python-mode-configuration"
225+
217226
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.
218227

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+
219236
> [!NOTE]
220237
> For more information on debugging, see [Durable Functions Diagnostics](durable-functions-diagnostics.md#debugging).
221238

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**.
223240

224241
:::image type="content" source="media/quickstart-python-vscode/functions-select-storage.png" alt-text="Screenshot of how to create a storage account.":::
225242

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:
227244

228245
| Prompt | Value | Description |
229246
| ------ | ----- | ----------- |
@@ -233,18 +250,20 @@ Azure Functions Core Tools lets you run an Azure Functions project on your local
233250
| Select a resource group | *unique name* | Name of the resource group to create |
234251
| Select a location | *region* | Select a region close to you |
235252

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.
237254

238255
:::image type="content" source="media/quickstart-python-vscode/functions-f5.png" alt-text="Screenshot of Azure local output.":::
239256

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`.
241258

242259
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.
243260

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.
245262

246263
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:
247264

265+
::: zone pivot="python-mode-configuration"
266+
248267
```json
249268
{
250269
"name": "HelloOrchestrator",
@@ -261,8 +280,28 @@ Azure Functions Core Tools lets you run an Azure Functions project on your local
261280
"lastUpdatedTime": "2020-03-18T21:54:54Z"
262281
}
263282
```
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+
264303

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.
266305

267306
After you've verified that the function runs correctly on your local computer, it's time to publish the project to Azure.
268307

0 commit comments

Comments
 (0)