Skip to content

Commit b9f19fd

Browse files
committed
Initial refresh of article
1 parent d2cd565 commit b9f19fd

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

articles/azure-functions/functions-integrate-storage-queue-output-binding.md

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,63 @@
11
---
22
title: Add messages to an Azure Storage queue using Functions
3-
description: Use Azure Functions to create a serverless function that is invoked by an HTTP request and creates a message in an Azure Storage queue.
4-
5-
ms.assetid: 0b609bc0-c264-4092-8e3e-0784dcc23b5d
3+
description: Use Azure Functions to create a serverless function that's triggered by an HTTP request and creates a message in an Azure Storage queue.
4+
ms.service: azure-functions
65
ms.topic: how-to
7-
ms.date: 04/24/2020
6+
ms.date: 06/19/2024
87
ms.devlang: csharp
98
# ms.devlang: csharp, javascript
109
ms.custom: "devx-track-csharp, mvc"
1110

11+
#Customer intent: As a function developer, I want to learn how to use Azure Functions to create a serverless function that's triggered by an HTTP request so that I can create a message in an Azure Storage queue.
12+
1213
---
1314
# Add messages to an Azure Storage queue using Functions
1415

15-
In Azure Functions, input and output bindings provide a declarative way to make data from external services available to your code. In this quickstart, you use an output binding to create a message in a queue when a function is triggered by an HTTP request. You use Azure storage container to view the queue messages that your function creates.
16+
In Azure Functions, input and output bindings provide a declarative way to make data from external services available to your code. In this article, you use an output binding to create a message in a queue when an HTTP request triggers a function. You use Azure storage container to view the queue messages that your function creates.
1617

1718
## Prerequisites
1819

19-
To complete this quickstart:
20-
2120
- An Azure subscription. If you don't have one, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
2221

23-
- Follow the directions in [Create your first function from the Azure portal](./functions-get-started.md) and don't do the **Clean up resources** step. That quickstart creates the function app and function that you use here.
22+
- Follow the directions in [Create your first function from the Azure portal](./functions-get-started.md), omitting the **Clean up resources** step, to create the function app and function to use in this article.
2423

25-
## <a name="add-binding"></a>Add an output binding
24+
## Add an output binding
2625

27-
In this section, you use the portal UI to add a queue storage output binding to the function you created earlier. This binding makes it possible to write minimal code to create a message in a queue. You don't have to write code for tasks such as opening a storage connection, creating a queue, or getting a reference to a queue. The Azure Functions runtime and queue output binding take care of those tasks for you.
26+
In this section, you use the portal UI to add a queue storage output binding to the function you created in the prerequisites. This binding makes it possible to write minimal code to create a message in a queue. You don't need to write code for such tasks as opening a storage connection, creating a queue, or getting a reference to a queue. the Azure Functions runtime and queue output binding take care of those tasks for you.
2827

29-
1. In the Azure portal, open the function app page for the function app that you created in [Create your first function from the Azure portal](./functions-get-started.md). To do open the page, search for and select **Function App**. Then, select your function app.
28+
1. In the Azure portal, search for and select the function app that you created in [Create your first function from the Azure portal](./functions-get-started.md).
3029

31-
1. Select your function app, and then select the function that you created in that earlier quickstart.
30+
1. In your function app, select the function that you created.
3231

3332
1. Select **Integration**, and then select **+ Add output**.
3433

35-
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/function-create-output-binding.png" alt-text="Create an output binding for your function." border="true":::
34+
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/function-create-output-binding.png" alt-text="Screenshot that shows how to create an output binding for your function.":::
35+
36+
1. Select the **Azure Queue Storage** binding type and add the settings as specified in the table that follows this screenshot:
3637

37-
1. Select the **Azure Queue Storage** binding type, and add the settings as specified in the table that follows this screenshot:
38+
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/function-create-output-binding-details.png" alt-text="Screenshot that shows how to add a queue storage output binding to a function in the Azure portal.":::
3839

39-
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/function-create-output-binding-details.png" alt-text="Add a Queue storage output binding to a function in the Azure portal." border="true":::
40-
4140
| Setting | Suggested value | Description |
4241
| ------------ | ------- | -------------------------------------------------- |
43-
| **Message parameter name** | outputQueueItem | The name of the output binding parameter. |
44-
| **Queue name** | outqueue | The name of the queue to connect to in your Storage account. |
45-
| **Storage account connection** | AzureWebJobsStorage | You can use the storage account connection already being used by your function app, or create a new one. |
42+
| **Message parameter name** | outputQueueItem | The name of the output binding parameter. |
43+
| **Queue name** | outqueue | The name of the queue to connect to in your storage account. |
44+
| **Storage account connection** | AzureWebJobsStorage | You can use the existing storage account connection used by your function app, or create a new one. |
4645

4746
1. Select **OK** to add the binding.
4847

4948
Now that you have an output binding defined, you need to update the code to use the binding to add messages to a queue.
5049

5150
## Add code that uses the output binding
5251

53-
In this section, you add code that writes a message to the output queue. The message includes the value that is passed to the HTTP trigger in the query string. For example, if the query string includes `name=Azure`, the queue message will be *Name passed to the function: Azure*.
52+
In this section, you add code that writes a message to the output queue. The message includes the value passed to the HTTP trigger in the query string. For example, if the query string includes `name=Azure`, the queue message is *Name passed to the function: Azure*.
5453

5554
1. In your function, select **Code + Test** to display the function code in the editor.
5655

57-
1. Update the function code depending on your function language:
56+
1. Update the function code, according to your function language:
5857

5958
# [C\#](#tab/csharp)
6059

61-
Add an **outputQueueItem** parameter to the method signature as shown in the following example.
60+
Add an **outputQueueItem** parameter to the method signature as shown in the following example:
6261

6362
```cs
6463
public static async Task<IActionResult> Run(HttpRequest req,
@@ -68,15 +67,15 @@ In this section, you add code that writes a message to the output queue. The mes
6867
}
6968
```
7069

71-
In the body of the function just before the `return` statement, add code that uses the parameter to create a queue message.
70+
In the body of the function, just before the `return` statement, add code that uses the parameter to create a queue message:
7271

7372
```cs
7473
outputQueueItem.Add("Name passed to the function: " + name);
7574
```
7675

7776
# [JavaScript](#tab/nodejs)
7877

79-
Add code that uses the output binding on the `context.bindings` object to create a queue message.
78+
To create a queue message, add code that uses the output binding on the `context.bindings` object:
8079

8180
```javascript
8281
context.bindings.outputQueueItem = "Name passed to the function: " +
@@ -85,45 +84,47 @@ In this section, you add code that writes a message to the output queue. The mes
8584

8685
---
8786

88-
1. Select **Save** to save changes.
87+
1. Select **Save** to save your changes.
8988

9089
## Test the function
9190

9291
1. After the code changes are saved, select **Test**.
93-
1. Confirm that your test matches the image below and select **Run**.
9492

95-
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/functions-test-run-function.png" alt-text="Test the queue storage binding in the Azure portal." border="true":::
93+
1. Confirm that your test matches this screenshot, and then select **Run**.
9694

97-
Notice that the **Request body** contains the `name` value *Azure*. This value appears in the queue message that is created when the function is invoked.
98-
99-
As an alternative to selecting **Run** here, you can call the function by entering a URL in a browser and specifying the `name` value in the query string. The browser method is shown in the [previous quickstart](./functions-get-started.md).
95+
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/functions-test-run-function.png" alt-text="Screenshot that shows how to test the queue storage binding in the Azure portal.":::
10096

101-
1. Check the logs to make sure that the function succeeded.
97+
Notice that the **Request body** contains the `name` value *Azure*. This value appears in the queue message created when the function is invoked.
10298

103-
A new queue named **outqueue** is created in your Storage account by the Functions runtime when the output binding is first used. You'll use storage account to verify that the queue and a message in it were created.
99+
As an alternative to selecting **Run**, you can call the function by entering a URL in a browser and specifying the `name` value in the query string. The browser method is shown in [Create your first function from the Azure portal](./functions-get-started.md).
104100

105-
### Find the storage account connected to AzureWebJobsStorage
101+
1. Check the logs to make sure that the function succeeded.
102+
103+
A new queue named **outqueue** is created in your storage account by the Functions runtime when the output binding is first used. You use storage account to verify that the queue and a message in it were created.
106104

105+
### Find the storage account connected to AzureWebJobsStorage
107106

108-
1. Go to your function app and select **Configuration**.
107+
1. In your function app, expand **Settings**, and then select **Environment variables**.
109108

110-
1. Under **Application settings**, select **AzureWebJobsStorage**.
109+
1. In the **App settings** tab, select **AzureWebJobsStorage**.
111110

112-
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/function-find-storage-account.png" alt-text="Screenshot shows the Configuration page with AzureWebJobsStorage selected." border="true":::
111+
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/function-find-storage-account.png" alt-text="Screenshot that shows the Configuration page with AzureWebJobsStorage selected.":::
113112

114113
1. Locate and make note of the account name.
115114

116-
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/function-storage-account-name.png" alt-text="Locate the storage account connected to AzureWebJobsStorage." border="true":::
115+
:::image type="content" source="./media/functions-integrate-storage-queue-output-binding/function-storage-account-name.png" alt-text="Screenshot that shows how to locate the storage account connected to AzureWebJobsStorage.":::
117116

118117
### Examine the output queue
119118

120-
1. In the resource group for your function app, select the storage account that you're using for this quickstart.
119+
1. In the resource group for your function app, select the storage account that you're using.
121120

122-
1. Under **Queue service**, select **Queues** and select the queue named **outqueue**.
121+
1. Under **Queue service**, select **Queues**, and select the queue named **outqueue**.
123122

124123
The queue contains the message that the queue output binding created when you ran the HTTP-triggered function. If you invoked the function with the default `name` value of *Azure*, the queue message is *Name passed to the function: Azure*.
125124

126-
1. Run the function again, and you'll see a new message appear in the queue.
125+
1. Run the function again.
126+
127+
A new message appears in the queue.
127128

128129
## Clean up resources
129130

0 commit comments

Comments
 (0)