Skip to content

Commit 577ec5c

Browse files
authored
Update v2
1 parent 79551a4 commit 577ec5c

File tree

1 file changed

+8
-44
lines changed

1 file changed

+8
-44
lines changed

articles/azure-functions/create-first-function-vs-code-python.md

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
7575
|**Select a template for your project's first function**| Choose `HTTP trigger`.|
7676
|**Provide a function name**| Enter `HttpExample`.|
7777
|**Authorization level**| Choose `Anonymous`, which lets anyone call your function endpoint. For more information about the authorization level, see [Authorization keys](functions-bindings-http-webhook-trigger.md#authorization-keys).|
78-
|**Select how you would like to open your project**| Choose `Open in current window`.|
7978

8079
4. Visual Studio Code uses the provided information and generates an Azure Functions project with an HTTP trigger. You can view the local project files in the Explorer. For more information about the files that are created, see [Generated project files](functions-develop-vs-code.md?tabs=python#generated-project-files).
8180
::: zone-end
@@ -86,56 +85,21 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
8685
|--|--|
8786
|**Select a language**| Choose `Python (Programming Model V2)`.|
8887
|**Select a Python interpreter to create a virtual environment**| Choose your preferred Python interpreter. If an option isn't shown, type in the full path to your Python binary.|
89-
|**Select how you would like to open your project**| Choose `Open in current window`.|
88+
|**Select a template for your project's first function** | Choose `HTTP trigger`. |
89+
|**Name of the function you want to create**| Enter `HttpExample`.|
90+
|**Authorization level**| Choose `ANONYMOUS`, which lets anyone call your function endpoint. For more information about the authorization level, see [Authorization keys](functions-bindings-http-webhook-trigger.md#authorization-keys).|
9091

91-
4. Visual Studio Code uses the provided information and generates an Azure Functions project.
92-
93-
5. Open the generated `function_app.py` project file, which contains your functions.
94-
95-
6. Uncomment the `test_function` function, which is an HTTP triggered function.
96-
97-
7. Replace the `app.route()` method call with the following code:
98-
99-
```python
100-
@app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
101-
```
102-
103-
This code enables your HTTP function endpoint to be called in Azure without having to provide an [Authorization keys](functions-bindings-http-webhook-trigger.md#authorization-keys). Local execution doesn't require authorization keys.
104-
105-
Your function code should now look like the following example:
106-
107-
```python
108-
app = func.FunctionApp()
109-
@app.function_name(name="HttpTrigger1")
110-
@app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
111-
def test_function(req: func.HttpRequest) -> func.HttpResponse:
112-
logging.info('Python HTTP trigger function processed a request.')
113-
114-
name = req.params.get('name')
115-
if not name:
116-
try:
117-
req_body = req.get_json()
118-
except ValueError:
119-
pass
120-
else:
121-
name = req_body.get('name')
122-
123-
if name:
124-
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
125-
else:
126-
return func.HttpResponse(
127-
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
128-
status_code=200
129-
)
130-
```
92+
4. Visual Studio Code uses the provided information and generates an Azure Functions project with an HTTP trigger. You can view the local project files in the Explorer. The generated `function_app.py` project file contains your functions.
13193

132-
8. Open the local.settings.json project file and updated the `AzureWebJobsStorage` setting as in the following example:
94+
5. 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.
95+
96+
6. In the local.settings.json file, update the `AzureWebJobsStorage` setting as in the following example:
13397

13498
```json
13599
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
136100
```
137101

138-
This tells the local Functions host to use the storage emulator for the storage connection currently required by the v2 model. When you publish your project to Azure, you'll instead use the default storage account. If you're instead using an Azure Storage account, set your storage account connection string here.
102+
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.
139103

140104
## Start the emulator
141105

0 commit comments

Comments
 (0)