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
+5-37Lines changed: 5 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,20 +25,11 @@ Most bindings require a stored connection string that Functions uses to access t
25
25
26
26
Before you start this article, complete the steps in [part 1 of the Python quickstart](functions-create-first-function-python.md).
27
27
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:
> 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
40
31
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.
@@ -77,34 +68,11 @@ Next, you use the Azure CLI to view the new queue and verify that a message was
77
68
78
69
### Set the Storage account connection
79
70
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:
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.
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:
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).
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).
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:
80
82
@@ -114,7 +116,7 @@ With the custom image running in a local Docker container, verify the function a
114
116
115
117
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.
116
118
117
-
## Push the custom image to Docker Hub
119
+
## Push to Docker Hub
118
120
119
121
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.
120
122
@@ -147,7 +149,7 @@ az functionapp plan create --resource-group myResourceGroup --name myPremiumPlan
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.
> You will have to stop and then start your function app for these values to be picked up
186
188
187
-
## Verify your function
189
+
## Verify your functions
188
190
189
191
<!-- we should replace this with a CLI or API-based approach, when we get something better than REST -->
190
192
@@ -193,24 +195,24 @@ The HTTP-triggered function you created requires a [function key](functions-bind
193
195
> [!TIP]
194
196
> 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).
195
197
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.
197
199
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**.
199
201
200
-

202
+

201
203
202
-
In this URL, the function key is the `code` query parameter.
204
+
In this URL, the function key is the `code` query parameter.
203
205
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.
206
208
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.
208
210
209
-
The following example shows the response in the browser:
211
+
The following example shows the response in the browser:
210
212
211
-

213
+

212
214
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.
214
216
215
217
## Enable continuous deployment
216
218
@@ -280,6 +282,10 @@ Functions lets you connect Azure services and other resources to functions witho
280
282
281
283
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.
> When using Visual Studio, you can also use the NuGet package manager to add this package.
301
307
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.
303
309
304
310
### Add an output binding
305
311
@@ -331,7 +337,7 @@ After the binding is defined, you can use the `name` of the binding to access it
331
337
332
338
### Update the hosted container
333
339
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.
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.
349
355
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:
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.
The string returned should be the same as the message you sent to test the function.
360
+
### Query the Storage queue
367
361
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).
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:
> 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.
> 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.
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:
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).
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:
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.
0 commit comments