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
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 storate account. If you're instead using an Azure Storage account, set your storage account connection string here.
129
+
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.
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-reference-python.md
+30-77Lines changed: 30 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ Use the Python annotations included in the [azure.functions.*](/python/api/azure
66
66
::: zone pivot="python-mode-decorators"
67
67
Azure Functions expects a function to be a stateless method in your Python script that processes input and produces output. By default, the runtime expects the method to be implemented as a global method in the `function_app.py` file.
68
68
69
-
Triggers and bindings can be declared and used in a function in a decorator based approach. They are defined in the same file, `function_app.py`, as the functions. As an example, the below _function_app.py_ file represents a function trigger by an HTTP request.
69
+
Triggers and bindings can be declared and used in a function in a decorator based approach. They're defined in the same file, `function_app.py`, as the functions. As an example, the below _function_app.py_ file represents a function trigger by an HTTP request.
To learn about known limitations with the V2 model and their workarounds, see [Troubleshoot Python errors in Azure Functions](./recover-python-functions.md?pivots=python-mode-decorators).
99
+
|Azure Queue Storage| x || x |
100
+
|Azure Service Bus Topic | x || x |
101
+
|Azure Service Bus Queue | x || x |
102
+
|Azure Cosmos DB| x | x | x |
103
+
|Azure Blob Storage| x | x | x |
104
+
|Azure Event Grid | x || x |
105
+
106
+
To learn about known limitations with the v2 model and their workarounds, see [Troubleshoot Python errors in Azure Functions](./recover-python-functions.md?pivots=python-mode-decorators).
107
107
::: zone-end
108
108
109
109
## Alternate entry point
@@ -189,7 +189,7 @@ The main project folder (<project_root>) can contain the following files:
189
189
**.venv/*: (Optional) Contains a Python virtual environment used by local development.
190
190
**.vscode/*: (Optional) Contains store VSCode configuration. To learn more, see [VSCode setting](https://code.visualstudio.com/docs/getstarted/settings).
191
191
**function_app.py*: This is the default location for all functions and their related triggers and bindings.
192
-
**additional_functions.py*: (Optional) Any additional Python files that contain functions (usually for logical grouping) that are referenced in `function_app.py` through blueprints.
192
+
**additional_functions.py*: (Optional) Any other Python files that contain functions (usually for logical grouping) that are referenced in `function_app.py` through blueprints.
193
193
**tests/*: (Optional) Contains the test cases of your function app.
194
194
**.funcignore*: (Optional) Declares files that shouldn't get published to Azure. Usually, this file contains `.vscode/` to ignore your editor setting, `.venv/` to ignore local Python virtual environment, `tests/` to ignore test cases, and `local.settings.json` to prevent local app settings being published.
195
195
**host.json*: Contains configuration options that affect all functions in a function app instance. This file does get published to Azure. Not all options are supported when running locally. To learn more, see [host.json](functions-host-json.md).
@@ -203,7 +203,7 @@ When you deploy your project to a function app in Azure, the entire contents of
203
203
::: zone pivot="python-mode-decorators"
204
204
## Blueprints
205
205
206
-
The v2 programming model introduces the concept of _blueprints_. A blueprint is a new class instantiated to register functions ourside of the core function application. The functions registered in blueprint instances are not indexed directly by function runtime. To get these blueprint functions indexed, the function app needs to register the functions from blueprint instances.
206
+
The v2 programming model introduces the concept of _blueprints_. A blueprint is a new class instantiated to register functions outside of the core function application. The functions registered in blueprint instances aren't indexed directly by function runtime. To get these blueprint functions indexed, the function app needs to register the functions from blueprint instances.
When the function is invoked, the HTTP request is passed to the function as `req`. An entry will be retrieved from the Azure Blob Storage based on the _ID_ in the route URL and made available as `obj` in the function body. Here, the storage account specified is the connection string found in the AzureWebJobsStorage app setting, which is the same storage account used by the function app.
382
382
383
-
Note that at this time, only specific triggers and bindings are supported by the V2 programming model. Supported triggers and bindings are as follows.
383
+
At this time, only specific triggers and bindings are supported by the v2 programming model. Supported triggers and bindings are as follows.
To learn more about defining triggers and bindings in the V2 model, see this [documentation](https://github.com/Azure/azure-functions-python-library/blob/dev/docs/ProgModelSpec.pyi).
396
+
To learn more about defining triggers and bindings in the v2 model, see this [documentation](https://github.com/Azure/azure-functions-python-library/blob/dev/docs/ProgModelSpec.pyi).
397
397
398
398
::: zone-end
399
399
@@ -582,7 +582,7 @@ In the previous examples, a binding name `req` is used. This parameter is an [Ht
582
582
583
583
From the [HttpRequest] object, you can get request headers, query parameters, route parameters, and the message body.
584
584
585
-
The following example is from the the HTTP trigger template for Python V2 programming model. It is the sample code provided when you create a function from Core Tools or VS Code.
585
+
The following example is from the HTTP trigger template for Python v2 programming model. It's the sample code provided when you create a function from Core Tools or VS Code.
586
586
587
587
```python
588
588
@app.function_name(name="HttpTrigger1")
@@ -715,7 +715,7 @@ For a full example, see [Using Flask Framework with Azure Functions](/samples/az
715
715
716
716
::: zone-end
717
717
::: zone pivot="python-mode-decorators"
718
-
You can leverage ASGI and WSGI-compatible frameworks such as Flask and FastAPI with your HTTP-triggered Python functions. The following examples demonstrate how to do so.
718
+
You can use ASGI and WSGI-compatible frameworks such as Flask and FastAPI with your HTTP-triggered Python functions, which is shown in the following example:
When deploying the function, this setting will not be automatically imported- the flag must be declated in Azure for the function application to run using the V2 model.
881
+
When deploying the function, this setting won't be automatically created. You must explicitly create this setting in your function app in Azure for it to run using the v2 model.
882
882
883
-
Multiple Python workers are not supported in V2 at this time. This means that setting `FUNCTIONS_WORKER_PROCESS_COUNT` to greater than 1 is not supported for the functions using the V2 model.
883
+
Multiple Python workers aren't supported in v2 at this time. This means that setting `FUNCTIONS_WORKER_PROCESS_COUNT` to greater than 1 isn't supported for the functions using the v2 model.
884
884
885
885
::: zone-end
886
886
@@ -904,55 +904,9 @@ The runtime uses the available Python version, when you run it locally.
904
904
905
905
To set a Python function app to a specific language version, you need to specify the language and the version of the language in `LinuxFxVersion` field in site config. For example, to change Python app to use Python 3.8, set `linuxFxVersion` to `python|3.8`.
906
906
907
-
To learn more about Azure Functions runtime support policy, refer to this [article](./language-support-policy.md)
908
-
909
-
To see the full list of supported Python versions functions apps, refer to this [article](./supported-languages.md)
910
-
911
-
# [Azure CLI](#tab/azurecli-linux)
912
-
913
-
You can view and set the `linuxFxVersion` from the Azure CLI.
914
-
915
-
Using the Azure CLI, view the current `linuxFxVersion` with the [az functionapp config show](/cli/azure/functionapp/config) command.
916
-
917
-
```azurecli-interactive
918
-
az functionapp config show --name <function_app> \
919
-
--resource-group <my_resource_group>
920
-
```
921
-
922
-
In this code, replace `<function_app>` with the name of your function app. Also replace `<my_resource_group>` with the name of the resource group for your function app.
923
-
924
-
You see the `linuxFxVersion` in the following output, which has been truncated for clarity:
925
-
926
-
```output
927
-
{
928
-
...
929
-
"kind": null,
930
-
"limits": null,
931
-
"linuxFxVersion": <LINUX_FX_VERSION>,
932
-
"loadBalancing": "LeastRequests",
933
-
"localMySqlEnabled": false,
934
-
"location": "West US",
935
-
"logsDirectorySizeLimit": 35,
936
-
...
937
-
}
938
-
```
939
-
940
-
You can update the `linuxFxVersion` setting in the function app with the [az functionapp config set](/cli/azure/functionapp/config) command.
941
-
942
-
```azurecli-interactive
943
-
az functionapp config set --name <FUNCTION_APP> \
944
-
--resource-group <RESOURCE_GROUP> \
945
-
--linux-fx-version <LINUX_FX_VERSION>
946
-
```
947
-
948
-
Replace `<FUNCTION_APP>` with the name of your function app. Also replace `<RESOURCE_GROUP>` with the name of the resource group for your function app. Also, replace `<LINUX_FX_VERSION>` with the Python version you want to use, prefixed by `python|` for example, `python|3.9`.
949
-
950
-
You can run this command from the [Azure Cloud Shell](../cloud-shell/overview.md) by choosing **Try it** in the preceding code sample. You can also use the [Azure CLI locally](/cli/azure/install-azure-cli) to execute this command after executing [az login](/cli/azure/reference-index#az-login) to sign in.
951
-
952
-
The function app restarts after the change is made to the site config.
953
-
954
-
---
907
+
To learn how to view and change the `linuxFxVersion` site setting, see [How to target Azure Functions runtime versions](set-runtime-version.md#manual-version-updates-on-linux).
955
908
909
+
For more general information, see the [Azure Functions runtime support policy](./language-support-policy.md) and [Supported languages in Azure Functions](./supported-languages.md).
956
910
957
911
## Package management
958
912
@@ -976,7 +930,7 @@ Project files and folders that are excluded from publishing, including the virtu
976
930
977
931
There are three build actions supported for publishing your Python project to Azure: remote build, local build, and builds using custom dependencies.
978
932
979
-
You can also use Azure Pipelines to build your dependencies and publish using continuous delivery (CD). To learn more, see [Continuous delivery by using Azure DevOps](functions-how-to-azure-devops.md).
933
+
You can also use Azure Pipelines to build your dependencies and publish using continuous delivery (CD). To learn more, see [Continuous delivery with Azure Pipelines](functions-how-to-azure-devops.md).
Remember to replace `<APP_NAME>` with the name of your function app in Azure.
1004
958
1005
-
When you use the `--build local` option, project dependencies are read from the requirements.txt file and those dependent packages are downloaded and installed locally. Project files and dependencies are deployed from your local computer to Azure. This results in a larger deployment package being uploaded to Azure. If for some reason, you can't get requirements.txt file by Core Tools, you must use the custom dependencies option for publishing.
959
+
When you use the `--build local` option, project dependencies are read from the requirements.txt file, and those dependent packages are downloaded and installed locally. Project files and dependencies are deployed from your local computer to Azure. This results in a larger deployment package being uploaded to Azure. If for some reason, you can't get requirements.txt file by Core Tools, you must use the custom dependencies option for publishing.
1006
960
1007
961
We don't recommend using local builds when developing locally on Windows.
1008
962
@@ -1273,7 +1227,6 @@ For a list of preinstalled system libraries in Python worker Docker images, see
1273
1227
1274
1228
| Functions runtime | Debian version | Python versions |
1275
1229
|------------|------------|------------|
1276
-
| Version 2.x | Stretch |[Python 3.6](https://github.com/Azure/azure-functions-docker/blob/master/host/2.0/stretch/amd64/python/python36/python36.Dockerfile)<br/>[Python 3.7](https://github.com/Azure/azure-functions-docker/blob/master/host/2.0/stretch/amd64/python/python37/python37.Dockerfile)|
@@ -1404,7 +1357,7 @@ Following is a list of troubleshooting guides for common issues:
1404
1357
1405
1358
Following is a list of troubleshooting guides for known issues with the v2 programming model:
1406
1359
1407
-
*[Could not load file or assembly](recover-python-functions.md#troubleshoot-could-not-load-file-or-assembly)
1360
+
*[Couldn't load file or assembly](recover-python-functions.md#troubleshoot-could-not-load-file-or-assembly)
1408
1361
*[Unable to resolve the Azure Storage connection named Storage](recover-python-functions.md#troubleshoot-unable-to-resolve-the-azure-storage-connection).
1409
1362
1410
1363
All known issues and feature requests are tracked using [GitHub issues](https://github.com/Azure/azure-functions-python-worker/issues) list. If you run into a problem and can't find the issue in GitHub, open a new issue and include a detailed description of the problem.
This article provides information to help you troubleshoot errors with your Python functions in Azure Functions. This article supports both the v1 and v2 programming models. Please choose your desired model from the seletor at the top of the article. The v2 model is currently in preview. For more information on Python programming models, see the [Python developer guide](./functions-reference-python.md).
13
+
This article provides information to help you troubleshoot errors with your Python functions in Azure Functions. This article supports both the v1 and v2 programming models. Choose your desired model from the selector at the top of the article. The v2 model is currently in preview. For more information on Python programming models, see the [Python developer guide](./functions-reference-python.md).
14
14
15
15
The following is a list of troubleshooting sections for common issues in Python functions:
16
16
@@ -268,7 +268,7 @@ This specific error may ready:
268
268
> `DurableTask.Netherite.AzureFunctions: Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.DurableTask, Version=2.0.0.0, Culture=neutral, PublicKeyToken=014045d636e89289'.`
269
269
> `The system cannot find the file specified.`
270
270
271
-
The reason this error may be occuring is because of an issue with how the extension bundle was cached. To detect if this is the issue, you can run the command with `--verbose` to see more details.
271
+
The reason this error may be occurring is because of an issue with how the extension bundle was cached. To detect if this is the issue, you can run the command with `--verbose` to see more details.
272
272
273
273
> `func host start --verbose`
274
274
@@ -310,7 +310,7 @@ You may see this error in your local output as the following message:
310
310
> `Value cannot be null. (Parameter 'provider')`
311
311
312
312
This error is a result of how extensions are loaded from the bundle locally. To resolve this error, you can do one of the following:
313
-
* Use a storage emulator such as [Azurerite](../storage/common/storage-use-azurite.md). This is a good option when you aren't planning to use a storage account in your functionapplication.
313
+
* Use a storage emulator such as [Azurite](../storage/common/storage-use-azurite.md). This is a good option when you aren't planning to use a storage account in your functionapplication.
314
314
* Create a storage account and add a connection string to the `AzureWebJobsStorage` environment variable in`localsettings.json`. Use this option when you are using a storage account trigger or binding with your application, or if you have an existing storage account. To get started, see [Create a storage account](../storage/common/storage-account-create.md).
0 commit comments