Skip to content

Latest commit

 

History

History
115 lines (67 loc) · 5.73 KB

functions-create-storage-queue-triggered-function.md

File metadata and controls

115 lines (67 loc) · 5.73 KB
title description services documentationcenter author manager ms.assetid ms.service ms.devlang ms.topic ms.date ms.author ms.custom
Create a function in Azure triggered by queue messages | Microsoft Docs
Use Azure Functions to create a serverless function that is invoked by a messages submitted to an Azure Storage queue.
azure-functions
na
ggailey777
jeconnoc
361da2a4-15d1-4903-bdc4-cc4b27fc3ff4
azure-functions
multiple
quickstart
10/01/2018
glenga
mvc, cc996988-fb4f-47

Create a function triggered by Azure Queue storage

Learn how to create a function that is triggered when messages are submitted to an Azure Storage queue.

View message in the logs.

Prerequisites

Create an Azure Function app

[!INCLUDE Create function app Azure portal]

Function app successfully created.

Next, you create a function in the new function app.

Create a Queue triggered function

  1. Expand your function app and click the + button next to Functions. If this is the first function in your function app, select In-portal then Continue. Otherwise, go to step three.

    Functions quickstart page in the Azure portal

  2. Choose More templates then Finish and view templates.

    Functions quickstart choose more templates

  3. In the search field, type queue and then choose the Queue trigger template.

  4. If prompted, select Install to install the Azure Storage extension any dependencies in the function app. After installation succeeds, select Continue.

    Install binding extensions

  5. Use the settings as specified in the table below the image.

    Configure the storage queue triggered function.

    Setting Suggested value Description
    Name Unique in your function app Name of this queue triggered function.
    Queue name myqueue-items Name of the queue to connect to in your Storage account.
    Storage account connection AzureWebJobStorage You can use the storage account connection already being used by your function app, or create a new one.
  6. Click Create to create your function.

Next, you connect to your Azure Storage account and create the myqueue-items storage queue.

Create the queue

  1. In your function, click Integrate, expand Documentation, and copy both Account name and Account key. You use these credentials to connect to the storage account in Azure Storage Explorer. If you have already connected your storage account, skip to step 4.

    Get the Storage account connection credentials.

  2. Run the Microsoft Azure Storage Explorer tool, click the connect icon on the left, choose Use a storage account name and key, and click Next.

    Run the Storage Account Explorer tool.

  3. Enter the Account name and Account key from step 1, click Next and then Connect.

    Enter the storage credentials and connect.

  4. Expand the attached storage account, right-click Queues, click Create Queue, type myqueue-items, and then press enter.

    Create a storage queue.

Now that you have a storage queue, you can test the function by adding a message to the queue.

Test the function

  1. Back in the Azure portal, browse to your function, expand the Logs at the bottom of the page, and make sure that log streaming isn't paused.

  2. In Storage Explorer, expand your storage account, Queues, and myqueue-items, then click Add message.

    Add a message to the queue.

  3. Type your "Hello World!" message in Message text and click OK.

  4. Wait for a few seconds, then go back to your function logs and verify that the new message has been read from the queue.

    View message in the logs.

  5. Back in Storage Explorer, click Refresh and verify that the message has been processed and is no longer in the queue.

Clean up resources

[!INCLUDE Next steps note]

Next steps

You have created a function that runs when a message is added to a storage queue.

[!INCLUDE Next steps note]

For more information about Queue storage triggers, see Azure Functions Storage queue bindings.