|
3 | 3 | This is a quickstart on how you create and deploy a Python function on Azure Functions 2.X using the [Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python).
|
4 | 4 |
|
5 | 5 |
|
6 |
| -## Prerequisites |
7 |
| -- Install Python 3.6 |
8 |
| -- Install [Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#v2) version 2.2.70 or later |
9 |
| - |
| 6 | +<!-- TOC --> |
| 7 | +- [Quickstart V2 Python Functions with Azure Functions Core Tools](#quickstart-v2-python-functions-with-azure-functions-core-tools) |
| 8 | + - [Prerequisites](#prerequisites) |
| 9 | + - [Create a Python functions project](#create-a-python-functions-project) |
| 10 | + - [Create Python functions from templates](#create-python-functions-from-templates) |
| 11 | + - [Create and activate a virtual environment](#create-and-activate-a-virtual-environment) |
| 12 | + - [Manage package with requirements.txt](#manage-package-with-requirementstxt) |
| 13 | + - [function.json](#functionjson) |
| 14 | + - [Update the host.json file to use extension bundles,](#update-the-hostjson-file-to-use-extension-bundles) |
| 15 | + - [Run the function locally](#run-the-function-locally) |
| 16 | + - [Publishing to Azure](#publishing-to-azure) |
| 17 | + - [LINKS](#links) |
10 | 18 |
|
11 |
| -```sh |
12 |
| -# Linux & Windows |
13 |
| -$ npm install -g azure-functions-core-tools |
14 | 19 |
|
15 |
| -# Mac |
16 |
| -$ brew tap azure/functions |
17 |
| -$ brew install azure-functions-core-tools |
| 20 | +## Prerequisites |
| 21 | +- Install `Python 3.6` |
| 22 | +- Install [Azure Core Tools version 2.x](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#v2) (the latest one) |
| 23 | + |
| 24 | +```bash |
| 25 | +# Install the latest Azure Core Tools version 2.x |
| 26 | +npm install -g azure-functions-core-tools |
| 27 | + |
| 28 | +# If it's on macOS, you can install with homebrew |
| 29 | +brew tap azure/functions |
| 30 | +brew install azure-functions-core-tools |
18 | 31 | ```
|
19 | 32 |
|
20 | 33 | ## Create a Python functions project
|
@@ -96,18 +109,35 @@ pip install -r requirements.txt
|
96 | 109 | ### function.json
|
97 | 110 | Configure trigger, input and output binding with `function.json`. Please see [Azure Functions Python developer guide](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python) for the detail
|
98 | 111 |
|
99 |
| -## Run the function locally |
100 | 112 |
|
101 |
| -When you develop functions locally, you can install the extensions you need by using the Azure Functions Core Tools from the Terminal or from a command prompt. |
102 |
| -After you have updated your function.json file to include all the bindings that your function needs, run the following command in the project folder. For more detail, please refer to [Local development Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-register#local-development-azure-functions-core-tools) |
| 113 | +## Update the host.json file to use extension bundles, |
103 | 114 |
|
104 |
| -```sh |
105 |
| -$ func extensions install |
| 115 | +In version 2.x of the Azure Functions runtime, you have to explicitly register the binding extensions that you use in your function app. To use extension bundles, update the `host.json` file to include the following entry for extensionBundle: |
| 116 | +> host.json |
| 117 | +```json |
| 118 | +{ |
| 119 | + "version": "2.0", |
| 120 | + "extensionBundle": { |
| 121 | + "id": "Microsoft.Azure.Functions.ExtensionBundle", |
| 122 | + "version": "[1.*, 2.0.0)" |
| 123 | + } |
| 124 | +} |
106 | 125 | ```
|
| 126 | +> [NOTE] As an alternative way, you can manually install extension bundles by running a command - `func extensions install` so appropritate binding extensions are installed in `bin` directory. But if you already added the entry for extensionBundle in `host.json` like above, you don't need this. |
| 127 | +> ```bash |
| 128 | +> # change directory to a project directory |
| 129 | +> cd functions |
| 130 | +> # Manually install extension bundles using func command (Azure Core Tools) |
| 131 | +> func extensions install |
| 132 | +> ``` |
| 133 | +
|
| 134 | +## Run the function locally |
107 | 135 |
|
108 | 136 | ```sh
|
109 |
| -$ func host start |
| 137 | +func host start |
110 | 138 | ```
|
| 139 | +For more detail, please refer to [Local development Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-register#local-development-azure-functions-core-tools) |
| 140 | +> |
111 | 141 |
|
112 | 142 | ### Publishing to Azure
|
113 | 143 |
|
|
0 commit comments