Please go through the following article to understand about Azure Functions.

Introduction

This article is an extension to one my previous article Azure Functions – Create Generic Webhook Trigger.

As discussed in the previous article, any Azure Function app Function can just have one trigger, but it can have multiple outputs. In our previous article, we have learnt how to send response as an output to whoever is calling the Webhook.

In this article, we will learn how to add a new output (Queue using Queue Trigger) to the Generic Webhook.

Let’s navigate to the Function App created in the previous article and navigate to the Integrate tab as shown below.

1_IntegrateTa

Clicking on the New Output button will open the list of Outputs shown below.

2_SelectOutput

Our goal of this article is to create a message in the Queue when the Webhook is triggered. So, select Azure Queue Storage as the output and click on Select button as shown in the above screen capture.

Once you click on select button of the above step, the following Azure Queue Storage output window will be opened where you can configure the following.

  1. The Storage account where you Queue gets created.
  2. The name of the Queue service in which the message would be saved.
  3. The name of the Queue binding parameter that you can use Azure Function app Function.

3_QueueProperties

Please note that the Queue named outqueue will be created automatically in the Storage Account that you have selected in the Storage Account connection.

Click Save to save the changes. You are now done with configuring the Queue output bindings. It’s now the time to update the Function App code that lets us to add the message to the Queue.

Navigate to the Develop tab and make the following changes.

  • Add a parameter IAsyncCollector<string> outputQueueItem
  • Add the line of code outputQueueItem.AddAsync($”Hello {data.first} {data.last}!”); to the Run function.

Below is the screen capture the complete code after making the above changes.

4_Develop

Copy the Function URL and switch to Postman app and send a request with a valid JSON body as shown below. You can refer Azure Functions – Create Generic Webhook Trigger on how to send a request using postman.

Hold on! Before making the test request, let’s navigate to the Storage Account and view the Queue Service blade as shown below.

5_EmptyStorageAccount

Please note that currently there are no Queue items in the Storage Account.

Let’s switch back and create a test request using Postman a shown below.

6_Postman

Now, navigate to the Storage Account’s Queue Service and click on the refresh button of the Queue Service blade. You can now view a new Queue item as shown below.

7_Queue

As of this writing, you cannot view the content of the Queue Item from the Azure Management Portal. Let’s open Azure Storage Explorer to view the contents of the Queue as shown below.

8_StorageExplorer

That’s it. We have created a Queue Binding and added a new Queue item when a Webhook is trigger.

Summary:

We have learnt the following in this article.

  • Created and configured Azure Queue Storage output trigger
  • Invoked the Azure Queue trigger from the Webhook trigger

Viewed the contents of the Queue using Azure Storage Explorer.