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
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-add-output-binding-storage-queue-python.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ You can [examine the Storage queue message](#query-the-storage-queue) again to v
86
86
87
87
## Next steps
88
88
89
-
You've updated your HTTP-triggered function to write data to a Storage queue. To learn more about developing Azure Functions with Python, see the [Azure Functions Python developer guide](functions-reference-python.md) and [Azure Functions triggers and bindings](functions-triggers-bindings.md). For examples of complete Function projects in Python, see the [Python Functions samples](/samples/browse/?products=azure-functions&languages=python).
89
+
You've updated your HTTP-triggered function to write data to a Storage queue. To learn more about developing Azure Functions with Python, see the [Azure Functions Python developer guide](functions-reference-python.md) and [Azure Functions triggers and bindings](functions-triggers-bindings.md). For examples of complete Function projects in Python, see the [Python Functions samples](/samples/browse/?products=azure-functions&languages=python). To learn more about pricing, see the [Functions pricing page](https://azure.microsoft.com/pricing/details/functions/) and the [Estimating Consumption plan costs](functions-consumption-costs.md) article.
90
90
91
91
Next, you should enable Application Insights monitoring for your function app:
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-create-first-function-python.md
+49-89Lines changed: 49 additions & 89 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,37 +3,39 @@ title: Create an HTTP triggered Python function in Azure
3
3
description: Learn how to create your first Python function in Azure using the Azure Functions Core Tools and the Azure CLI.
4
4
author: ggailey777
5
5
ms.author: glenga
6
-
ms.date: 09/11/2019
6
+
ms.date: 11/07/2019
7
7
ms.topic: quickstart
8
8
ms.service: azure-functions
9
9
ms.custom: mvc
10
10
ms.devlang: python
11
11
manager: gwallace
12
12
---
13
13
14
-
# Create an HTTP triggered Python function in Azure
14
+
# Quickstart: Create an HTTP triggered Python function in Azure
15
15
16
-
This article shows you how to use command-line tools to create a Python project that runs in Azure Functions. You also create a function that is triggered by an HTTP request. Finally, you publish your project to run as a [serverless function](functions-scale.md#consumption-plan) in Azure.
16
+
This article shows you how to use command-line tools to create a Python project that runs in Azure Functions. You also create a function that is triggered by an HTTP request. After running locally, you publish your project to run as a [serverless function](functions-scale.md#consumption-plan) in Azure.
17
17
18
18
This article is the first of two Python quickstarts for Azure Functions. After you complete this quickstart, you can [add an Azure Storage queue output binding](functions-add-output-binding-storage-queue-python.md) to your function.
19
19
20
+
There is also a [Visual Studio Code-based version](/azure/python/tutorial-vs-code-serverless-python-01) of this article.
21
+
20
22
## Prerequisites
21
23
22
24
Before you start, you must:
23
25
24
-
+ Install [Python 3.6.8](https://www.python.org/downloads/). This version of Python is verified with Functions. 3.7 and later versions are not yet supported.
26
+
+ Install [Python 3.7.4](https://www.python.org/downloads/). This version of Python is verified with Functions. Python 3.8 and later versions are not yet supported.
25
27
26
-
+ Install [Azure Functions Core Tools](./functions-run-local.md#v2) version 2.7.1575 or a later version.
28
+
+ Install [Azure Functions Core Tools](./functions-run-local.md#v2) version 2.7.1846 or a later version.
27
29
28
-
+ Install the [Azure CLI](/cli/azure/install-azure-cli) version 2.x or a later version.
30
+
+ Install the [Azure CLI](/cli/azure/install-azure-cli) version 2.0.76 or a later version.
## Create and activate a virtual environment (optional)
36
+
## Create and activate a virtual environment
35
37
36
-
You should use a Python 3.6.x environment to locally develop Python functions. Run the following commands to create and activate a virtual environment named `.venv`.
38
+
You should use a Python 3.7 environment to locally develop Python functions. Run the following commands to create and activate a virtual environment named `.venv`.
37
39
38
40
> [!NOTE]
39
41
> If Python didn't install venv on your Linux distribution, you can install it using the following command:
@@ -58,111 +60,69 @@ Now that you activated the virtual environment, run the remaining commands in it
58
60
59
61
## Create a local functions project
60
62
61
-
A functions project is the equivalent of a functionappin Azure. It can have multiple functions that all share the same local and hosting configurations.
63
+
A functions project can have multiple functions that all share the same local and hosting configurations.
62
64
63
-
1. In the virtual environment, run the following command:
65
+
In the virtual environment, run the following commands:
64
66
65
-
```console
66
-
func init MyFunctionProj
67
-
```
67
+
```console
68
+
func init MyFunctionProj --python
69
+
cd MyFunctionProj
70
+
```
68
71
69
-
1. Select **python** as your worker runtime.
72
+
The `func init`command creates a _MyFunctionProj_ folder. The Python project in this folder doesn't yet have any functions. You'll add them next.
70
73
71
-
The command creates a _MyFunctionProj_ folder. It contains these three files:
74
+
## Create a function
72
75
73
-
**local.settings.json*: used to store app settings and connection strings when running locally. This file doesn't get published to Azure.
74
-
* *requirements.txt*: contains the list of packages the system will install on publishing to Azure.
75
-
* *host.json*: contains global configuration options that affect all functions in a function app. This file does get published to Azure.
76
+
To add a functionto your project, run the following command:
76
77
77
-
1. Go to the new *MyFunctionProj* folder:
78
+
```console
79
+
func new --name HttpTrigger --template "HTTP trigger"
80
+
```
78
81
79
-
```console
80
-
cd MyFunctionProj
81
-
```
82
+
This commands creates a subfolder named _HttpTrigger_, which contains the following files:
82
83
83
-
## Create a function
84
+
**function.json*: configuration file that defines the function, trigger, and other bindings. Notice that in this file, the value for`scriptFile` points to the file containing the function, and the `bindings` array defines the invocation trigger and bindings.
84
85
85
-
Add a function to the new project.
86
+
Each binding requires a direction, type and a unique name. The HTTP trigger has an input binding of type [`httpTrigger`](functions-bindings-http-webhook.md#trigger) and output binding of type [`http`](functions-bindings-http-webhook.md#output).
86
87
87
-
1. To add a functionto your project, run the following command:
88
+
**\_\_init\_\_.py*: script file that is your HTTP triggered function. Notice that this script has a default `main()`. HTTP data from the trigger passes to the functionusing the `req` named `binding parameter`. The `req`, which is defined in function.json, is an instance of the [azure.functions.HttpRequest class](/python/api/azure-functions/azure.functions.httprequest).
88
89
89
-
```console
90
-
func new
91
-
```
90
+
The return object, defined as `$return`in*function.json*, is an instance of [azure.functions.HttpResponse class](/python/api/azure-functions/azure.functions.httpresponse). To learn more, see [Azure Functions HTTP triggers and bindings](functions-bindings-http-webhook.md).
92
91
93
-
1. Use your down-arrow to select the **HTTP trigger** template.
92
+
Now you can run the new functionon your local computer.
94
93
95
-
1. When you're prompted for a functionname, enter *HttpTrigger* and then press Enter.
94
+
## Run the function locally
96
95
97
-
These commands create a subfolder named _HttpTrigger_. It contains the following files:
96
+
This command starts the functionapp using the Azure Functions runtime (func.exe):
98
97
99
-
**function.json*: configuration file that defines the function, trigger, and other bindings. Notice that in this file, the value for`scriptFile` points to the file containing the function, and the `bindings` array defines the invocation trigger and bindings.
98
+
```console
99
+
func host start
100
+
```
100
101
101
-
Each binding requires a direction, type and a unique name. The HTTP trigger has an input binding of type [`httpTrigger`](functions-bindings-http-webhook.md#trigger) and output binding of type [`http`](functions-bindings-http-webhook.md#output).
102
+
You should see the following information written to the output:
102
103
103
-
**\_\_init\_\_.py*: script file that is your HTTP triggered function. Notice that this script has a default `main()`. HTTP data from the trigger passes to the functionusing the `req` named `binding parameter`. The `req`, which is defined in function.json, is an instance of the [azure.functions.HttpRequest class](/python/api/azure-functions/azure.functions.httprequest).
104
+
```output
105
+
Http Functions:
104
106
105
-
The return object, defined as `$return`in*function.json*, is an instance of [azure.functions.HttpResponse class](/python/api/azure-functions/azure.functions.httpresponse). To learn more, see [Azure Functions HTTP triggers and bindings](functions-bindings-http-webhook.md).
Copy the URL of your `HttpTrigger` function from this output and paste it into your browser's address bar. Append the query string `?name=<yourname>` to this URL and execute the request. The following screenshot shows the response to the GET request that the local function returns to the browser:
111
+
112
+

113
+
114
+
Use Ctrl+C to shut down your function app execution.
108
115
109
-
The functionruns locally using the Azure Functions runtime.
110
-
111
-
1. This command starts the functionapp:
112
-
113
-
```console
114
-
func host start
115
-
```
116
-
117
-
When the Azure Functions host starts, it writes something like the following output. It's truncated here so you can read it better:
1. Copy the URL of your `HttpTrigger` function from the runtime output and paste it into your browser's address bar.
150
-
151
-
1. Append the query string `?name=<yourname>` to this URL and execute the request. The following screenshot shows the response to the GET request that the localfunctionreturns to the browser:
152
-
153
-

154
-
155
-
1. Select Ctrl+C to shut down your functionapp.
156
-
157
-
Now that you have run your functionlocally, you can create the functionapp and other required resources in Azure.
116
+
Now that you have run your function locally, you can deploy your function code to Azure.
117
+
Before you can deploy your app, you'll need to create some Azure resources.
A functionapp provides an environment for executing your functioncode. It lets you group functions as a logical unit for easier management, deployment, and sharing of resources.
125
+
A function app provides an environment for executing your function code. It lets you group functions as a logical unit for easier management, deployment, and sharing of resources.
166
126
167
127
Run the following command. Replace `<APP_NAME>` with a unique function app name. Replace `<STORAGE_NAME>` with a storage account name. The `<APP_NAME>` is also the default DNS domain for the function app. This name needs to be unique across all apps in Azure.
168
128
@@ -171,11 +131,11 @@ Run the following command. Replace `<APP_NAME>` with a unique function app name.
171
131
172
132
```azurecli-interactive
173
133
az functionapp create --resource-group myResourceGroup --os-type Linux \
The preceding command also provisions an associated Azure Application Insights instance in the same resource group. You can use this instance to monitor your function app and view logs.
138
+
The preceding command creates a function app running Python 3.7.4. It also provisions an associated Azure Application Insights instance in the same resource group. You can use this instance to monitor your function app and view logs.
179
139
180
140
You're now ready to publish your local functions project to the function app in Azure.
181
141
@@ -187,7 +147,7 @@ After you create the function app in Azure, you can use the [func azure function
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-create-function-linux-custom-image.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ You can also use the [Azure Cloud Shell](https://shell.azure.com/bash).
52
52
53
53
## Create the local project
54
54
55
-
Run the following command from the command line to create a function app project in the `MyFunctionProj` folder of the current local directory. For a Python project, you [must be running in a virtual environment](functions-create-first-function-python.md#create-and-activate-a-virtual-environment-optional).
55
+
Run the following command from the command line to create a function app project in the `MyFunctionProj` folder of the current local directory. For a Python project, you [must be running in a virtual environment](functions-create-first-function-python.md#create-and-activate-a-virtual-environment).
|**Java**|[Debugger for Java extension](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug)<br/>[Java 8](https://aka.ms/azure-jdks)<br/>[Maven 3 or later](https://maven.apache.org/)|
|**Python**|[Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)<br/>[Python 3.6 or later](https://www.python.org/downloads/)|
0 commit comments