Skip to content

Commit 6bc4806

Browse files
author
Yoichi Kawasaki
committed
Added host.json update procedure to install extension bundle automatically
1 parent 8371488 commit 6bc4806

4 files changed

+51
-24
lines changed

docs/quickstart-samples-custom-image-with-docker.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This is a quickstart on how you start running Python function samples as a custo
2323
- [Docker](https://docs.docker.com/)
2424

2525
## Git clone source code
26-
```sh
26+
```bash
2727
git clone https://github.com/yokawasa/azure-functions-python-samples.git
2828
```
2929

@@ -123,7 +123,6 @@ curl -s http://localhost:8080/api/http-trigger-dump-request |jq
123123
"params": {},
124124
"get_body": ""
125125
}
126-
127126
```
128127

129128
## Tips

docs/quickstart-v2-python-functions.md

+46-16
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,31 @@
33
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).
44

55

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)
1018

11-
```sh
12-
# Linux & Windows
13-
$ npm install -g azure-functions-core-tools
1419

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
1831
```
1932

2033
## Create a Python functions project
@@ -96,18 +109,35 @@ pip install -r requirements.txt
96109
### function.json
97110
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
98111

99-
## Run the function locally
100112

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,
103114

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+
}
106125
```
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
107135
108136
```sh
109-
$ func host start
137+
func host start
110138
```
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+
>
111141
112142
### Publishing to Azure
113143

v2functions/host.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"version": "2.0",
3-
"logger": {
4-
"defaultLevel": "Trace",
5-
"categoryLevels": {
6-
"Worker": "Trace"
7-
}
3+
"extensionBundle": {
4+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
5+
"version": "[1.*, 2.0.0)"
86
}
97
}

v2functions/local.settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"IsEncrypted": false,
33
"Values": {
44
"FUNCTIONS_WORKER_RUNTIME": "python",
5-
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"AzureWebJobsStorage": "<Storage Connection String>",
66
"MyCosmosDBConnectionString": "<CosmosDB Connection String>",
77
"ComputerVisionSubscription": "<Azure Computer Vision API SubscriptionKey>",
88
"ComputerVisionApiEndpoint": "<Azure Computer Vision API Endpoint",

0 commit comments

Comments
 (0)