Skip to content

Commit fbe7d83

Browse files
authored
Fixes in the CLI article too
1 parent 577ec5c commit fbe7d83

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

Diff for: articles/azure-functions/create-first-function-cli-python.md

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Create a Python function from the command line - Azure Functions
33
description: Learn how to create a Python function from the command line, then publish the local project to serverless hosting in Azure Functions.
4-
ms.date: 03/22/2023
4+
ms.date: 07/15/2023
55
ms.topic: quickstart
66
ms.devlang: python
77
ms.custom: devx-track-python, devx-track-azurecli, devx-track-azurepowershell, mode-api, devdivchpfy22
@@ -28,12 +28,8 @@ Before you begin, you must have the following requirements in place:
2828

2929
+ An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
3030

31-
::: zone pivot="python-mode-configuration"
3231
+ The [Azure Functions Core Tools](functions-run-local.md#v2) version 4.x.
33-
::: zone-end
34-
::: zone pivot="python-mode-decorators"
35-
+ The [Azure Functions Core Tools](functions-run-local.md#v2) version 4.2.1 or later.
36-
::: zone-end
32+
3733
+ One of the following tools for creating Azure resources:
3834

3935
+ [Azure CLI](/cli/azure/install-azure-cli) version 2.4 or later.
@@ -171,16 +167,25 @@ In Azure Functions, a function project is a container for one or more individual
171167

172168
1. The file `function_app.py` can include all functions within your project. To start with, there's already an HTTP function stored in the file.
173169

174-
```python
175-
import azure.functions as func
176-
177-
app = func.FunctionApp()
170+
```python
171+
import azure.functions as func
172+
173+
app = func.FunctionApp()
174+
175+
@app.function_name(name="HttpTrigger1")
176+
@app.route(route="hello")
177+
def test_function(req: func.HttpRequest) -> func.HttpResponse:
178+
return func.HttpResponse("HttpTrigger1 function processed a request!")
179+
```
180+
1. Open the local.settings.json project file and verify that the `AzureWebJobsFeatureFlags` setting has a value of `EnableWorkerIndexing`. This is required for Functions to interpret your project correctly as the Python v2 model. You'll add this same setting to your application settings after you publish your project to Azure.
181+
182+
1. In the local.settings.json file, update the `AzureWebJobsStorage` setting as in the following example:
183+
184+
```json
185+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
186+
```
178187

179-
@app.function_name(name="HttpTrigger1")
180-
@app.route(route="hello")
181-
def test_function(req: func.HttpRequest) -> func.HttpResponse:
182-
return func.HttpResponse("HttpTrigger1 function processed a request!")
183-
```
188+
This tells the local Functions host to use the storage emulator for the storage connection currently required by the Python v2 model. When you publish your project to Azure, you'll need to instead use the default storage account. If you're instead using an Azure Storage account, set your storage account connection string here.
184189
::: zone-end
185190

186191
### (Optional) Examine the file contents

0 commit comments

Comments
 (0)