Azure Docs

Queue Input Binding

The Queue input binding enables Azure Functions to read messages from an Azure Storage Queue as the function is triggered or as an input parameter.

When to use

Sample code

C# (Run.csx)
#r "Microsoft.Azure.WebJobs.Extensions.Storage"
using Microsoft.Azure.WebJobs;
public static void Run([QueueTrigger("myqueue-items")] string myQueueItem, ILogger log)
{
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
}
JavaScript (index.js)
module.exports = async function (context, myQueueItem) {
    context.log('JavaScript queue trigger function processed', myQueueItem);
};
Python (function.py)
import logging
import azure.functions as func

def main(myQueueItem: func.QueueMessage):
    logging.info('Python queue trigger function processed %s', myQueueItem.get_body().decode('utf-8'))

Configuration

Add the following binding definition to function.json:

function.json
{
  "bindings": [
    {
      "type": "queueTrigger",
      "direction": "in",
      "name": "myQueueItem",
      "queueName": "myqueue-items",
      "connection": "AzureWebJobsStorage"
    }
  ]
}

Ensure the AzureWebJobsStorage app setting points to a valid storage account connection string.

FAQ

How many messages can a function read at once?

The runtime batches messages based on function runtime and queue length. You can influence batch size with the batchSize property in host.json.

What happens if message processing fails?

The message is returned to the queue and becomes visible again after the visibility timeout. After a configurable number of retries, it is moved to the poison queue.