Skip to content

Commit 10d5a90

Browse files
committed
Add includes and fix steps
1 parent d7134d0 commit 10d5a90

7 files changed

+104
-72
lines changed

articles/azure-functions/functions-add-output-binding-storage-queue-python.md

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,11 @@ Most bindings require a stored connection string that Functions uses to access t
2525

2626
Before you start this article, complete the steps in [part 1 of the Python quickstart](functions-create-first-function-python.md).
2727

28-
## Download the function app settings
29-
30-
In the previous quickstart article, you created a function app in Azure, along with the required Storage account. The connection string for this account is stored securely in app settings in Azure. In this article, you write messages to a Storage queue in the same account. To connect to your Storage account when running the function locally, you must download app settings to the local.settings.json file. Run the following Azure Functions Core Tools command to download settings to local.settings.json, replacing `<APP_NAME>` with the name of your function app from the previous article:
31-
32-
```bash
33-
func azure functionapp fetch-app-settings <APP_NAME>
34-
```
28+
[!INCLUDE [functions-cloud-shell-note](../../includes/functions-cloud-shell-note.md)]
3529

36-
You might need to sign in to your Azure account.
37-
38-
> [!IMPORTANT]
39-
> Because it contains secrets, the local.settings.json file never gets published, and it should be excluded from source control.
30+
## Download the function app settings
4031

41-
You need the value `AzureWebJobsStorage`, which is the Storage account connection string. You use this connection to verify that the output binding works as expected.
32+
[!INCLUDE [functions-app-settings-download-local-cli](../../includes/functions-app-settings-download-local-cli.md)]
4233

4334
## Enable extension bundles
4435

@@ -77,34 +68,11 @@ Next, you use the Azure CLI to view the new queue and verify that a message was
7768

7869
### Set the Storage account connection
7970

80-
Open the local.settings.json file and copy the value of `AzureWebJobsStorage`, which is the Storage account connection string. Set the `AZURE_STORAGE_CONNECTION_STRING` environment variable to the connection string by using this Bash command:
81-
82-
```azurecli-interactive
83-
export AZURE_STORAGE_CONNECTION_STRING=<STORAGE_CONNECTION_STRING>
84-
```
85-
86-
When you set the connection string in the `AZURE_STORAGE_CONNECTION_STRING` environment variable, you can access your Storage account without having to provide authentication each time.
71+
[!INCLUDE [functions-storage-account-set-cli](../../includes/functions-storage-account-set-cli.md)]
8772

8873
### Query the Storage queue
8974

90-
You can use the [`az storage queue list`](/cli/azure/storage/queue#az-storage-queue-list) command to view the Storage queues in your account, as in the following example:
91-
92-
```azurecli-interactive
93-
az storage queue list --output tsv
94-
```
95-
96-
The output from this command includes a queue named `outqueue`, which is the queue that was created when the function ran.
97-
98-
Next, use the [`az storage message peek`](/cli/azure/storage/message#az-storage-message-peek) command to view the messages in this queue, as in this example:
99-
100-
```azurecli-interactive
101-
echo `echo $(az storage message peek --queue-name outqueue -o tsv --query '[].{Message:content}') | base64 --decode`
102-
```
103-
104-
The string returned should be the same as the message you sent to test the function.
105-
106-
> [!NOTE]
107-
> The previous example decodes the returned string from base64. This is because the Queue storage bindings write to and read from Azure Storage as [base64 strings](functions-bindings-storage-queue.md#encoding).
75+
[!INCLUDE [functions-query-storage-cli](../../includes/functions-query-storage-cli.md)]
10876

10977
Now it's time to republish the updated function app to Azure.
11078

articles/azure-functions/functions-create-function-linux-custom-image.md

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ You can also use the [Azure Cloud Shell](https://shell.azure.com/bash).
4848

4949
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
5050

51-
## Create the local function app project
51+
[!INCLUDE [functions-cloud-shell-note](../../includes/functions-cloud-shell-note.md)]
52+
53+
## Create the local project
5254

5355
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).
5456

@@ -74,7 +76,7 @@ cd MyFunctionProj
7476

7577
[!INCLUDE [functions-run-function-test-local](../../includes/functions-run-function-test-local.md)]
7678

77-
## Build the image from the Docker file
79+
## Build from the Docker file
7880

7981
Take a look at the _Dockerfile_ in the root folder of the project. This file describes the environment that is required to run the function app on Linux. The following example is a Dockerfile that creates a container that runs a function app on the JavaScript (Node.js) worker runtime:
8082

@@ -114,7 +116,7 @@ With the custom image running in a local Docker container, verify the function a
114116
115117
After you have verified the function app in the container, stop the execution. Now, you can push the custom image to your Docker Hub account.
116118

117-
## Push the custom image to Docker Hub
119+
## Push to Docker Hub
118120

119121
A registry is an application that hosts images and provides services image and container services. To share your image, you must push it to a registry. Docker Hub is a registry for Docker images that allows you to host your own repositories, either public or private.
120122

@@ -147,7 +149,7 @@ az functionapp plan create --resource-group myResourceGroup --name myPremiumPlan
147149
--location WestUS --number-of-workers 1 --sku EP1 --is-linux
148150
```
149151

150-
## Create a function app from the custom image
152+
## Create an app from the image
151153

152154
The function app manages the execution of your functions in your hosting plan. Create a function app from a Docker Hub image by using the [az functionapp create](/cli/azure/functionapp#az-functionapp-create) command.
153155

@@ -184,7 +186,7 @@ AzureWebJobsStorage=$storageConnectionString
184186
>
185187
> You will have to stop and then start your function app for these values to be picked up
186188
187-
## Verify your function
189+
## Verify your functions
188190

189191
<!-- we should replace this with a CLI or API-based approach, when we get something better than REST -->
190192

@@ -193,24 +195,24 @@ The HTTP-triggered function you created requires a [function key](functions-bind
193195
> [!TIP]
194196
> You can also obtain your function keys by using the [Key management APIs](https://github.com/Azure/azure-functions-host/wiki/Key-management-API), which requires you to present a [bearer token for authentication](/cli/azure/account#az-account-get-access-token).
195197
196-
1. Locate your new function app in the [Azure portal] by typing your function app name in the **Search** box at the top of the page and selecting the **App Service** resource.
198+
Locate your new function app in the [Azure portal] by typing your function app name in the **Search** box at the top of the page and selecting the **App Service** resource.
197199

198-
1. Select the **MyHttpTrigger** function, select **</> Get function URL** > **default (Function key)** > **Copy**.
200+
Select the **MyHttpTrigger** function, select **</> Get function URL** > **default (Function key)** > **Copy**.
199201

200-
![Copy the function URL from the Azure portal](./media/functions-create-function-linux-custom-image/functions-portal-get-url-key.png)
202+
![Copy the function URL from the Azure portal](./media/functions-create-function-linux-custom-image/functions-portal-get-url-key.png)
201203

202-
In this URL, the function key is the `code` query parameter.
204+
In this URL, the function key is the `code` query parameter.
203205

204-
> [!NOTE]
205-
> Because your function app is deployed as a container, you can't make changes to your function code in the portal. You must instead update the project in local container and republish it to Azure.
206+
> [!NOTE]
207+
> Because your function app is deployed as a container, you can't make changes to your function code in the portal. You must instead update the project in local container and republish it to Azure.
206208
207-
1. Paste the function URL into your browser's address bar. Add the query string value `&name=<yourname>` to the end of this URL and press the `Enter` key on your keyboard to execute the request. You should see the response returned by the function displayed in the browser.
209+
Paste the function URL into your browser's address bar. Add the query string value `&name=<yourname>` to the end of this URL and press the `Enter` key on your keyboard to execute the request. You should see the response returned by the function displayed in the browser.
208210

209-
The following example shows the response in the browser:
211+
The following example shows the response in the browser:
210212

211-
![Function response in the browser.](./media/functions-create-function-linux-custom-image/function-app-browser-testing.png)
213+
![Function response in the browser.](./media/functions-create-function-linux-custom-image/function-app-browser-testing.png)
212214

213-
The request URL includes a key that is required, by default, to access your function over HTTP.
215+
The request URL includes a key that is required, by default, to access your function over HTTP.
214216

215217
## Enable continuous deployment
216218

@@ -280,6 +282,10 @@ Functions lets you connect Azure services and other resources to functions witho
280282

281283
This section shows you how to integrate your function with an Azure Storage queue. The output binding that you add to this function writes data from an HTTP request to a message in the queue.
282284

285+
### Download the function app settings
286+
287+
[!INCLUDE [functions-app-settings-download-local-cli](../../includes/functions-app-settings-download-local-cli.md)]
288+
283289
### Enable extension bundles
284290

285291
Because you are using a Queue storage output binding, you must have the Storage bindings extension installed before you run the project.
@@ -299,7 +305,7 @@ dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage --version 3.0.4
299305
> [!TIP]
300306
> When using Visual Studio, you can also use the NuGet package manager to add this package.
301307
302-
Now, you can add a the Storage output binding to your project.
308+
Now, you can add a Storage output binding to your project.
303309

304310
### Add an output binding
305311

@@ -331,7 +337,7 @@ After the binding is defined, you can use the `name` of the binding to access it
331337

332338
### Update the hosted container
333339

334-
In the root folder, run the [docker build](https://docs.docker.com/engine/reference/commandline/build/) command again, and this time update the version in the tag to `v1.0.2`. Aas before, replace `<docker-id>` with your Docker Hub account ID.
340+
In the root folder, run the [docker build](https://docs.docker.com/engine/reference/commandline/build/) command again, and this time update the version in the tag to `v1.0.2`. As before, replace `<docker-id>` with your Docker Hub account ID.
335341

336342
```bash
337343
docker build --tag <docker-id>/mydockerimage:v1.0.0 .
@@ -347,32 +353,19 @@ docker push <docker-id>/mydockerimage:v1.0.0
347353

348354
Use the same URL as before from the browser to trigger your function. You should see the same response. However, this time the string that you pass as the `name` parameter is written to the `outqueue` storage queue.
349355

350-
### Query the Storage queue
351-
352-
You can use the [`az storage queue list`](/cli/azure/storage/queue#az-storage-queue-list) command to view the Storage queues in your account, as in the following example:
356+
### Set the Storage account connection
353357

354-
```azurecli-interactive
355-
az storage queue list --output tsv
356-
```
358+
[!INCLUDE [functions-storage-account-set-cli](../../includes/functions-storage-account-set-cli.md)]
357359

358-
The output from this command includes a queue named `outqueue`, which is the queue that was created when the function ran.
359-
360-
Next, use the [`az storage message peek`](/cli/azure/storage/message#az-storage-message-peek) command to view the messages in this queue, as in the following example.
361-
362-
```azurecli-interactive
363-
echo `echo $(az storage message peek --queue-name outqueue -o tsv --query '[].{Message:content}') | base64 --decode`
364-
```
365-
366-
The string returned should be the same as the message you sent to test the function.
360+
### Query the Storage queue
367361

368-
> [!NOTE]
369-
> The previous example decodes the returned string from base64. This is because the Queue storage bindings write to and read from Azure Storage as [base64 strings](functions-bindings-storage-queue.md#encoding).
362+
[!INCLUDE [functions-query-storage-cli](../../includes/functions-query-storage-cli.md)]
370363

371364
[!INCLUDE [functions-cleanup-resources](../../includes/functions-cleanup-resources.md)]
372365

373366
## Next steps
374367

375-
Now that you have successfully deployed your container to a function app in Azure, consider reading more about the following:
368+
Now that you have successfully deployed your custom container to a function app in Azure, consider reading more about the following topics:
376369

377370
+ [Monitoring functions](functions-monitoring.md)
378371
+ [Scale and hosting options](functions-scale.md)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
author: ggailey777
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 09/26/2019
6+
ms.author: glenga
7+
---
8+
9+
You've already created a function app in Azure, along with the required Storage account. The connection string for this account is stored securely in app settings in Azure. In this article, you write messages to a Storage queue in the same account. To connect to your Storage account when running the function locally, you must download app settings to the local.settings.json file. Run the following Azure Functions Core Tools command to download settings to local.settings.json, replacing `<APP_NAME>` with the name of your function app from the previous article:
10+
11+
```bash
12+
func azure functionapp fetch-app-settings <APP_NAME>
13+
```
14+
15+
You might need to sign in to your Azure account.
16+
17+
> [!IMPORTANT]
18+
> Because it contains secrets, the local.settings.json file never gets published, and it should be excluded from source control.
19+
20+
You need the value `AzureWebJobsStorage`, which is the Storage account connection string. You use this connection to verify that the output binding works as expected.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
author: ggailey777
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 09/26/2019
6+
ms.author: glenga
7+
---
8+
9+
> [!NOTE]
10+
> Azure CLI commands in this article work in Bash and are verified to run in [Azure CLoud Shell](../articles/cloud-shell/overview.md). You must modify them to run in a local Windows command prompt.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
author: ggailey777
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 09/26/2019
6+
ms.author: glenga
7+
---
8+
9+
You can use the [`az storage queue list`](/cli/azure/storage/queue#az-storage-queue-list) command to view the Storage queues in your account, as in the following example:
10+
11+
```azurecli-interactive
12+
az storage queue list --output tsv
13+
```
14+
15+
The output from this command includes a queue named `outqueue`, which is the queue that was created when the function ran.
16+
17+
Next, use the [`az storage message peek`](/cli/azure/storage/message#az-storage-message-peek) command to view the messages in this queue, as in this example:
18+
19+
```azurecli-interactive
20+
echo `echo $(az storage message peek --queue-name outqueue -o tsv --query '[].{Message:content}') | base64 --decode`
21+
```
22+
23+
The string returned should be the same as the message you sent to test the function.
24+
25+
> [!NOTE]
26+
> The previous example decodes the returned string from base64. This is because the Queue storage bindings write to and read from Azure Storage as [base64 strings](functions-bindings-storage-queue.md#encoding).
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
author: ggailey777
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 09/26/2019
6+
ms.author: glenga
7+
---
8+
9+
Open the local.settings.json file and copy the value of `AzureWebJobsStorage`, which is the Storage account connection string. Set the `AZURE_STORAGE_CONNECTION_STRING` environment variable to the connection string by using this Bash command:
10+
11+
```azurecli-interactive
12+
AZURE_STORAGE_CONNECTION_STRING="<STORAGE_CONNECTION_STRING>"
13+
```
14+
15+
When you set the connection string in the `AZURE_STORAGE_CONNECTION_STRING` environment variable, you can access your Storage account without having to provide authentication each time.
18.9 KB
Loading

0 commit comments

Comments
 (0)