Skip to content

Commit 9acce27

Browse files
authored
Fix numbering and remove the optional section
1 parent fbe7d83 commit 9acce27

File tree

1 file changed

+16
-78
lines changed

1 file changed

+16
-78
lines changed

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

Lines changed: 16 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,6 @@ Before you begin, you must have the following requirements in place:
4343

4444
[!INCLUDE [functions-x86-emulation-on-arm64-note](../../includes/functions-x86-emulation-on-arm64-note.md)]
4545

46-
### Prerequisite check
47-
48-
Verify your prerequisites, which depend on whether you're using Azure CLI or Azure PowerShell for creating Azure resources.
49-
50-
# [Azure CLI](#tab/azure-cli)
51-
52-
::: zone pivot="python-mode-configuration"
53-
+ In a terminal or command window, run `func --version` to check that the Azure Functions Core Tools version is 4.x.
54-
::: zone-end
55-
::: zone pivot="python-mode-decorators"
56-
+ In a terminal or command window, run `func --version` to check that the Azure Functions Core Tools version is 4.0.4785 or later.
57-
::: zone-end
58-
+ Run `az --version` to check that the Azure CLI version is 2.4 or later.
59-
60-
+ Run `az login` to sign in to Azure and verify an active subscription.
61-
62-
+ Run `python --version` (Linux/macOS) or `py --version` (Windows) to check your Python version reports 3.9.x, 3.8.x, or 3.7.x.
63-
64-
# [Azure PowerShell](#tab/azure-powershell)
65-
66-
+ In a terminal or command window, run `func --version` to check that the Azure Functions Core Tools version is 4.x.
67-
68-
+ Run `(Get-Module -ListAvailable Az).Version` and verify version 5.0 or later.
69-
70-
+ Run `Connect-AzAccount` to sign in to Azure and verify an active subscription.
71-
72-
+ Run `python --version` (Linux/macOS) or `py --version` (Windows) to check your Python version reports 3.9.x, 3.8.x, or 3.7.x.
73-
74-
---
75-
7646
## <a name="create-venv"></a>Create and activate a virtual environment
7747

7848
In a suitable folder, run the following commands to create and activate a virtual environment named `.venv`. Make sure that you're using Python 3.9, 3.8, or 3.7, which are supported by Azure Functions.
@@ -143,14 +113,9 @@ In Azure Functions, a function project is a container for one or more individual
143113
```
144114

145115
`func new` creates a subfolder matching the function name that contains a code file appropriate to the project's chosen language and a configuration file named *function.json*.
146-
147-
Get the list of templates by using the following command:
148-
149-
```console
150-
func templates list -l python
151-
```
152-
::: zone-end
153-
::: zone pivot="python-mode-decorators"
116+
```
117+
::: zone-end
118+
::: zone pivot="python-mode-decorators"
154119
1. Run the `func init` command as follows to create a functions project in a folder named *LocalFunctionProj* with the specified runtime and the specified programming model version.
155120

156121
```console
@@ -162,21 +127,22 @@ In Azure Functions, a function project is a container for one or more individual
162127
```console
163128
cd LocalFunctionProj
164129
```
165-
130+
166131
This folder contains various files for the project, including configuration files named [*local.settings.json*](functions-develop-local.md#local-settings-file) and [*host.json*](functions-host-json.md). Because *local.settings.json* can contain secrets downloaded from Azure, the file is excluded from source control by default in the *.gitignore* file.
167132

168133
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.
169134

170-
```python
171-
import azure.functions as func
135+
```python
136+
import azure.functions as func
172137
173-
app = func.FunctionApp()
138+
app = func.FunctionApp()
174139
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-
```
140+
@app.function_name(name="HttpTrigger1")
141+
@app.route(route="hello")
142+
def test_function(req: func.HttpRequest) -> func.HttpResponse:
143+
return func.HttpResponse("HttpTrigger1 function processed a request!")
144+
```
145+
180146
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.
181147

182148
1. In the local.settings.json file, update the `AzureWebJobsStorage` setting as in the following example:
@@ -185,37 +151,9 @@ In Azure Functions, a function project is a container for one or more individual
185151
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
186152
```
187153

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.
189-
::: zone-end
190-
191-
### (Optional) Examine the file contents
192-
193-
If desired, you can skip to [Run the function locally](#run-the-function-locally) and examine the file contents later.
194-
195-
::: zone pivot="python-mode-configuration"
196-
#### \_\_init\_\_.py
197-
198-
*\_\_init\_\_.py* contains a `main()` Python function that's triggered according to the configuration in *function.json*.
199-
200-
:::code language="python" source="~/functions-quickstart-templates/Functions.Templates/Templates/HttpTrigger-Python/__init__.py":::
201-
202-
For an HTTP trigger, the function receives request data in the variable `req` as defined in *function.json*. `req` is an instance of the [azure.functions.HttpRequest class](/python/api/azure-functions/azure.functions.httprequest). The return object, defined as `$return` in *function.json*, is an instance of [azure.functions.HttpResponse class](/python/api/azure-functions/azure.functions.httpresponse). For more information, see [Azure Functions HTTP triggers and bindings](./functions-bindings-http-webhook.md?tabs=python).
203-
204-
#### function.json
205-
206-
*function.json* is a configuration file that defines the input and output `bindings` for the function, including the trigger type.
207-
208-
If desired, you can change `scriptFile` to invoke a different Python file.
209-
210-
:::code language="json" source="~/functions-quickstart-templates/Functions.Templates/Templates/HttpTrigger-Python/function.json":::
211-
212-
Each binding requires a direction, a type, and a unique name. The HTTP trigger has an input binding of type [`httpTrigger`](functions-bindings-http-webhook-trigger.md) and output binding of type [`http`](functions-bindings-http-webhook-output.md).
213-
::: zone-end
214-
::: zone pivot="python-mode-decorators"
215-
`function_app.py` is the entry point to the function and where functions will be stored and/or referenced. This file will include configuration of triggers and bindings through decorators, and the function content itself.
216-
217-
For more information, see [Azure Functions HTTP triggers and bindings](./functions-bindings-http-webhook.md?tabs=python).
218-
154+
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.
155+
::: zone-end
156+
::: zone pivot="python-mode-decorators"
219157
## Start the storage emulator
220158

221159
By default, local development uses the Azurite storage emulator. This emulator is used when the `AzureWebJobsStorage` setting in the *local.settings.json* project file is set to `UseDevelopmentStorage=true`. When using the emulator, you must start the local Azurite storage emulator before running the function.

0 commit comments

Comments
 (0)