Skip to content

Commit 906c771

Browse files
committed
1561426, incorporated first round of peer review feedback.
1 parent dd4efb2 commit 906c771

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

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

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ manager: gwallace
1515

1616
This article shows you how to use command-line tools to create a Python project that runs in Azure Functions. An HTTP request triggers the function you create. Finally, you publish your project to run as a [serverless function](functions-scale.md#consumption-plan) in Azure.
1717

18-
This article is the first of two quickstarts for Azure Functions. After you complete this article, you [add an Azure Storage queue output binding](functions-add-output-binding-storage-queue-python.md) to your function.
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.
1919

2020
## Prerequisites
2121

@@ -29,11 +29,11 @@ Before you start, you must:
2929

3030
+ Have an active Azure subscription.
3131

32-
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
32+
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
3333

3434
## Create and activate a virtual environment (optional)
3535

36-
To locally develop and test Python functions, it's recommended to use a Python 3.6.x environment. Run the following commands to create and activate a virtual environment named `.venv`.
36+
You can use a Python 3.6.x environment to locally develop and test Python functions. Run the following commands to create and activate a virtual environment named `.venv`.
3737

3838
> [!NOTE]
3939
> If Python didn't install venv on your Linux distribution, you can install it using the following command:
@@ -54,15 +54,11 @@ py -m venv .venv
5454
.venv\scripts\activate
5555
```
5656
57-
Now that the virtualenv is activated, you'll run the remaining commands in it. If you want to get out of the virtual environment, run this command:
57+
Now that you activated the virtual environment, run the remaining commands in it. To get out of the virtual environment, run `deactivate`.
5858
59-
```console
60-
deactivate
61-
```
62-
63-
## Create a local Functions project
59+
## Create a local functions project
6460
65-
A Functions project is the equivalent of a function app in Azure. It can have multiple functions that all share the same local and hosting configurations.
61+
A functions project is the equivalent of a function app in Azure. It can have multiple functions that all share the same local and hosting configurations.
6662
6763
1. In the virtual environment, run the following command:
6864
@@ -74,9 +70,9 @@ A Functions project is the equivalent of a function app in Azure. It can have mu
7470
7571
The command creates a _MyFunctionProj_ folder. It contains these three files:
7672
77-
* `local.settings.json`: used to store app settings and connection strings when running locally. This file doesn't get published to Azure.
78-
* `requirements.txt`: contains the list of packages the system will install on publishing to Azure.
79-
* `host.json`: contains global configuration options that affect all functions in a function app. This file does get published to Azure.
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.
8076
8177
1. Go to the new *MyFunctionProj* folder:
8278
@@ -86,7 +82,7 @@ A Functions project is the equivalent of a function app in Azure. It can have mu
8682
8783
## Create a function
8884
89-
Now it's time to create a function for the new project.
85+
Add a function to the new project.
9086
9187
1. To add a function to your project, run the following command:
9288
@@ -100,25 +96,25 @@ Now it's time to create a function for the new project.
10096
10197
These commands create a subfolder named _HttpTrigger_. It contains the following files:
10298
103-
* **function.json**: configuration file that defines the function, trigger, and other bindings. Take a look at this file. Notice that the value for `scriptFile` points to the file containing the function, while the system defines the invocation trigger and bindings in the `bindings` array.
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.
104100
105101
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).
106102
107-
* **\_\_init\_\_.py**: script file that is your HTTP triggered function. Open the script. Take note that it contains a default `main()`. HTTP data from the trigger is passed to this function using the `req` named binding parameter. Defined in function.json, `req` is an instance of the [azure.functions.HttpRequest class](/python/api/azure-functions/azure.functions.httprequest).
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 function using 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).
108104
109105
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).
110106
111107
## Run the function locally
112108
113-
The function runs locally using the same Azure Functions runtime that is in Azure.
109+
The function runs locally using the Azure Functions runtime.
114110
115111
1. This command starts the function app:
116112
117113
```console
118114
func host start
119115
```
120116
121-
When the Functions host starts, it writes something like the following output. It's truncated so you can read it better:
117+
When the Azure Functions host starts, it writes something like the following output. It's truncated here so you can read it better:
122118
123119
```output
124120
@@ -150,11 +146,9 @@ The function runs locally using the same Azure Functions runtime that is in Azur
150146
[8/27/2018 10:38:27 PM] Job host started
151147
```
152148
153-
1. Copy the URL of your `HttpTrigger` function from the runtime output.
149+
1. Copy the URL of your `HttpTrigger` function from the runtime output and paste it into your browser's address bar.
154150
155-
1. Paste it into your browser's address bar.
156-
157-
1. Append the query string `?name=<yourname>` to this URL and execute the request. The following screenshot shows the response in the browser to the GET request returned by the local function:
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 local function returns to the browser:
158152
159153
![Test locally in the browser](./media/functions-create-first-function-python/function-test-local-browser.png)
160154
@@ -172,29 +166,30 @@ A function app provides an environment for executing your function code. It lets
172166
173167
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.
174168
169+
> [!NOTE]
170+
> You can't host Linux and Windows apps in the same resource group. If you have an existing resource group named `myResourceGroup` with a Windows function app or web app, you must use a different resource group.
171+
175172
```azurecli-interactive
176173
az functionapp create --resource-group myResourceGroup --os-type Linux \
177174
--consumption-plan-location westeurope --runtime python \
178175
--name <APP_NAME> --storage-account <STORAGE_NAME>
179176
```
180-
> [!NOTE]
181-
> You can't host Linux and Windows apps in the same resource group. If you have an existing resource group named `myResourceGroup` with a Windows function app or web app, you must use a different resource group.
182177
183-
This command will also provision an associated Azure Application Insights instance. It will be in the same resource group that you can use for monitoring and viewing logs.
178+
The preceeding command will also provision an associated Azure Application Insights instance. It will be in the same resource group, which you can use for monitoring and viewing logs.
184179
185180
You're now ready to publish your local functions project to the function app in Azure.
186181
187182
## Deploy the function app project to Azure
188183
189-
After the function app is created in Azure, you can use the [func azure functionapp publish](functions-run-local.md#project-file-deployment) Core Tools command to deploy your project code to Azure. In these examples, replace `<APP_NAME>` with the name of your app from the previous step.
184+
After you create the function app in Azure, you can use the [func azure functionapp publish](functions-run-local.md#project-file-deployment) Core Tools command to deploy your project code to Azure. In this examples, replace `<APP_NAME>` with the name of your app.
190185
191186
```azurecli-interactive
192187
func azure functionapp publish <APP_NAME> --build remote
193188
```
194189
195190
The `--build remote` option builds your Python project remotely in Azure from the files in the deployment package.
196191
197-
You'll see output similar to the following message. It's truncated so you can read it better:
192+
You'll see output similar to the following message. It's truncated here so you can read it better:
198193
199194
```output
200195
Getting site publishing info...
@@ -210,12 +205,12 @@ Functions in myfunctionapp:
210205
Invoke url: https://myfunctionapp.azurewebsites.net/api/httptrigger?code=cCr8sAxfBiow548FBDLS1....
211206
```
212207
213-
Copy the `Invoke url` value for your `HttpTrigger`. You can use it to test your function in Azure. The URL contains a `code` query string value. It's your function key. This key makes it difficult for others to call your HTTP trigger endpoint in Azure.
208+
You can copy the `Invoke url` value for your `HttpTrigger` and use it to test your function in Azure. The URL contains a `code` query string value that is your function key, which makes it difficult for others to call your HTTP trigger endpoint in Azure.
214209
215210
[!INCLUDE [functions-test-function-code](../../includes/functions-test-function-code.md)]
216211
217212
> [!NOTE]
218-
> To view near real-time logs for a published Python app, we recommend using the [Application Insights Live Metrics Stream](functions-monitoring.md#streaming-logs)
213+
> To view near real-time logs for a published Python app, use the [Application Insights Live Metrics Stream](functions-monitoring.md#streaming-logs).
219214
220215
## Next steps
221216

includes/functions-create-resource-group.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ ms.author: glenga
77
---
88
## Create a resource group
99

10-
Create a resource group with the [az group create](/cli/azure/group). An Azure resource group is a logical container into which Azure resources like function apps, databases, and storage accounts are deployed and managed.
10+
Create a resource group with the [az group create](/cli/azure/group#az-group-create) command. An Azure resource group is a logical container into which Azure resources like function apps, databases, and storage accounts are deployed and managed.
1111

1212
The following example creates a resource group named `myResourceGroup`.
13-
If you are not using Cloud Shell, sign in first using `az login`.
13+
If you aren't using Cloud Shell, sign in first using `az login`.
1414

1515
```azurecli-interactive
1616
az group create --name myResourceGroup --location westeurope

includes/functions-create-storage-account.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.author: glenga
77
---
88
## Create an Azure Storage account
99

10-
Functions uses a general-purpose account in Azure Storage to maintain state and other information about your functions. Create a general-purpose storage account in the resource group you created by using the [az storage account create](/cli/azure/storage/account) command.
10+
Functions uses a general-purpose account in Azure Storage to maintain state and other information about your functions. Create a general-purpose storage account in the resource group you created by using the [az storage account create](/cli/azure/storage/account#az-storage-account-create) command.
1111

1212
In the following command, substitute a globally unique storage account name where you see the `<storage_name>` placeholder. Storage account names must be between 3 and 24 characters in length and may contain numbers and lowercase letters only.
1313

includes/functions-test-function-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ Use cURL to test the deployed function. Using the URL, including the function ke
1111

1212
![using cURL to call the function in Azure.](./media/functions-test-function-code/functions-azure-cli-function-test-curl.png)
1313

14-
You can also paste the copied URL, including the function key, in to the address of your web browser. Again, append the query string `&name=<yourname>` to the URL before you execute the request.
14+
You can also paste the copied URL, including the function key, into the address bar of your web browser. Again, append the query string `&name=<yourname>` to the URL before you execute the request.
1515

1616
![Using a web browser to call the function.](./media/functions-test-function-code/functions-azure-cli-function-test-browser.png)

0 commit comments

Comments
 (0)