Azure Functions

Serverless Compute for Cloud and Edge

Azure Functions Queue Input Bindings

Queue input bindings enable your Azure Functions to read messages from Azure Storage Queues. When a function is triggered by a queue message, the binding automatically retrieves the message and makes its content available to your function code.

How it Works

When you define a queue input binding, you specify the name of the queue to read from. Azure Functions runtime monitors the specified queue. When a new message arrives, the runtime retrieves it. For input bindings, the function code receives the message content. For trigger bindings, the message content is the primary event data that starts function execution. If your function is triggered by a queue message, you can also use an input binding to retrieve additional messages or even a specific message from the same queue or a different queue.

Supported Queue Types

Azure Functions supports input bindings for:

Configuration

Queue input bindings are configured in the function.json file (for JavaScript, Python, and other non-.NET languages) or through attributes in your code (for C# and other .NET languages).

function.json Example (JavaScript/TypeScript)

{
  "scriptFile": "index.js",
  "bindings": [
    {
      "name": "myQueueItem",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "myqueue-items",
      "connection": "AzureWebJobsStorage"
    },
    {
      "name": "queueMessage",
      "type": "queue",
      "direction": "in",
      "queueName": "another-input-queue",
      "connection": "AzureWebJobsStorage",
      "accessRights": "peek"
    }
  ]
}

.NET Attribute Example (C#)

using Microsoft.Azure.Functions.Worker;
using Azure.Storage.Queues.Models;

public static class QueueInputFunction
{
    [Function("QueueInputFunction")]
    public static void Run(
        [QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")] string myQueueItem,
        [Queue("another-input-queue", Connection = "AzureWebJobsStorage", AccessRights = QueueAccessRights.Peek)] QueueMessage queueMessage)
    {
        Console.WriteLine($"Trigger function processed: {myQueueItem}");
        Console.WriteLine($"Input binding message: {queueMessage.MessageText}");
    }
}

Binding Parameters

Here are the key properties for configuring a queue input binding:

Property Description Required
type Must be set to queue for an input binding. Yes
direction Must be set to in for an input binding. Yes
name The name of the variable in your function code that will hold the queue message content. Yes
queueName The name of the storage queue to read from. Yes
connection The name of an app setting that contains the storage account connection string. Defaults to AzureWebJobsStorage. No
accessRights Specifies the access rights for the queue. For input bindings, typically peek is sufficient if you only need to read the message without dequeuing it immediately. Other options include none. read is also implicitly supported for input bindings. Defaults to none (meaning the message is not deleted after processing by this binding). No

Data Types

The content of the queue message can be bound to various data types in your function code:

Important: When using a queue input binding, the message is not automatically deleted from the queue after your function processes it. If you want the message to be removed, you must explicitly handle that within your function code (e.g., by using a queue output binding to delete it or by manually managing invisibility timeouts and deletions). The peek access right ensures the message is only read, not dequeued.

Advanced Scenarios

By leveraging queue input bindings, you can efficiently integrate your Azure Functions with Azure Storage Queues, building robust and scalable messaging-driven applications.