Microsoft.Azure.WebJobs.Extensions.Storage.Queues 5.3.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage.Queues --version 5.3.0
NuGet\Install-Package Microsoft.Azure.WebJobs.Extensions.Storage.Queues -Version 5.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage.Queues" Version="5.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.Azure.WebJobs.Extensions.Storage.Queues --version 5.3.0
#r "nuget: Microsoft.Azure.WebJobs.Extensions.Storage.Queues, 5.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.Azure.WebJobs.Extensions.Storage.Queues as a Cake Addin
#addin nuget:?package=Microsoft.Azure.WebJobs.Extensions.Storage.Queues&version=5.3.0

// Install Microsoft.Azure.WebJobs.Extensions.Storage.Queues as a Cake Tool
#tool nuget:?package=Microsoft.Azure.WebJobs.Extensions.Storage.Queues&version=5.3.0

Azure WebJobs Storage Queues client library for .NET

This extension provides functionality for accessing Azure Storage Queues in Azure Functions.

Getting started

Install the package

Install the Storage Queues extension with NuGet:

dotnet add package Azure.WebJobs.Extensions.Storage.Queues

Prerequisites

You need an Azure subscription and a Storage Account to use this package.

To create a new Storage Account, you can use the Azure Portal, Azure PowerShell, or the Azure CLI. Here's an example using the Azure CLI:

az storage account create --name <your-resource-name> --resource-group <your-resource-group-name> --location westus --sku Standard_LRS

Authenticate the client

In order for the extension to access Queues, you will need the connection string which can be found in the Azure Portal or by using the Azure CLI snippet below.

az storage account show-connection-string -g <your-resource-group-name> -n <your-resource-name>

The connection string can be supplied through AzureWebJobsStorage app setting.

Key concepts

Using Queue trigger

The queue storage trigger runs a function as messages are added to Azure Queue storage.

Please follow the tutorial to learn about how to listen to queues in Azure Functions.

Using Queue binding

Azure Functions can create new Azure Queue storage messages by setting up an output binding.

Please follow the binding tutorial to learn about using this extension for producing messages into queues in Azure Functions.

Examples

Listening to queue

The following set of examples shows how to receive and react to messages that are being added to the queue.

Binding queue message to string
public static class QueueTriggerFunction_String
{
    [FunctionName("QueueTriggerFunction")]
    public static void Run(
        [QueueTrigger("sample-queue")] string message,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue, content={content}", message);
    }
}
Binding queue message to BinaryData
public static class QueueTriggerFunction_BinaryData
{
    [FunctionName("QueueTriggerFunction")]
    public static void Run(
        [QueueTrigger("sample-queue")] BinaryData message,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue, content={content}", message.ToString());
    }
}
Binding queue message to QueueMessage
public static class QueueTriggerFunction_QueueMessage
{
    [FunctionName("QueueTriggerFunction")]
    public static void Run(
        [QueueTrigger("sample-queue")] QueueMessage message,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue, content={content}", message.Body.ToString());
    }
}
Binding queue message to custom type
public static class QueueTriggerFunction_CustomObject
{
    public class CustomMessage
    {
        public string Content { get; set; }
    }

    [FunctionName("QueueTriggerFunction")]
    public static void Run(
        [QueueTrigger("sample-queue")] CustomMessage message,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue, content={content}", message.Content);
    }
}
Binding queue message to JObject
public static class QueueTriggerFunction_JObject
{
    [FunctionName("QueueTriggerFunction")]
    public static void Run(
        [QueueTrigger("sample-queue")] JObject message,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue, content={content}", message["content"]);
    }
}

Publishing messages to queue

The following set of examples shows how to add messages to queue by using Queue attribute.

The QueueTrigger is used just for sample completeness, i.e. any other trigger mechanism can be used instead.

Publishing message as string
public static class QueueSenderFunction_String_Return
{
    [FunctionName("QueueFunction")]
    [return: Queue("sample-queue-2")]
    public static string Run(
        [QueueTrigger("sample-queue-1")] string message,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue-1, content={content}", message);
        logger.LogInformation("Dispatching message to sample-queue-2");
        return message;
    }
}
Publishing message as BinaryData
public static class QueueSenderFunction_BinaryData_Return
{
    [FunctionName("QueueFunction")]
    [return: Queue("sample-queue-2")]
    public static BinaryData Run(
        [QueueTrigger("sample-queue-1")] BinaryData message,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue-1, content={content}", message.ToString());
        logger.LogInformation("Dispatching message to sample-queue-2");
        return message;
    }
}
Publishing message as QueueMessage
public static class QueueSenderFunction_QueueMessage_Return
{
    [FunctionName("QueueFunction")]
    [return: Queue("sample-queue-2")]
    public static QueueMessage Run(
        [QueueTrigger("sample-queue-1")] QueueMessage message,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue-1, content={content}", message.Body.ToString());
        logger.LogInformation("Dispatching message to sample-queue-2");
        return message;
    }
}
Publishing message as custom type through out parameter
public static class QueueSenderFunction_CustomObject_OutParamter
{
    public class CustomMessage
    {
        public string Content { get; set; }
    }

    [FunctionName("QueueFunction")]
    public static void Run(
        [QueueTrigger("sample-queue-1")] CustomMessage incomingMessage,
        [Queue("sample-queue-2")] out CustomMessage outgoingMessage,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue-1, content={content}", incomingMessage.Content);
        logger.LogInformation("Dispatching message to sample-queue-2");
        outgoingMessage = incomingMessage;
    }
}
Publishing message as custom type through collector
public static class QueueSenderFunction_CustomObject_Collector
{
    public class CustomMessage
    {
        public string Content { get; set; }
    }

    [FunctionName("QueueFunction")]
    public static void Run(
        [QueueTrigger("sample-queue-1")] CustomMessage incomingMessage,
        [Queue("sample-queue-2")] ICollector<CustomMessage> collector,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue-1, content={content}", incomingMessage.Content);
        logger.LogInformation("Dispatching message to sample-queue-2");
        collector.Add(incomingMessage);
    }
}

Accessing queue properties

public static class Function_BindingToQueueClient
{
    [FunctionName("QueueFunction")]
    public static async Task Run(
        [QueueTrigger("sample-queue")] string message,
        [Queue("sample-queue")] QueueClient queueClient,
        ILogger logger)
    {
        logger.LogInformation("Received message from sample-queue, content={content}", message);
        QueueProperties queueProperties = await queueClient.GetPropertiesAsync();
        logger.LogInformation("There are approximatelly {count} messages", queueProperties.ApproximateMessagesCount);
    }
}

Configuring the extension

Please refer to sample functions app.

Troubleshooting

Please refer to Monitor Azure Functions for troubleshooting guidance.

Next steps

Read the introduction to Azure Function or creating an Azure Function guide.

Contributing

See the Storage CONTRIBUTING.md for details on building, testing, and contributing to this library.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Microsoft.Azure.WebJobs.Extensions.Storage.Queues:

Package Downloads
Microsoft.Azure.WebJobs.Extensions.Storage The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

This extension adds bindings for Storage

SimpleMessageBus.Dispatch

SimpleMessageBus is a system for making applications more reliable and responsive to users by processing potentially long-running tasks out-of-band from the user's main workflow. It is designed to run either on-prem, or in the Microsoft Cloud, making it suitable for any application, and able to grow as your needs do.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Microsoft.Azure.WebJobs.Extensions.Storage.Queues:

Repository Stars
Azure-Samples/Serverless-microservices-reference-architecture
This reference architecture walks you through the decision-making process involved in designing, developing, and delivering a serverless application using a microservices architecture through hands-on instructions for configuring and deploying all of the architecture's components along the way. The goal is to provide practical hands-on experience in working with several Azure services and the technologies that effectively use them in a cohesive and unified way to build a serverless-based microservices architecture.
Azure/azure-functions-kafka-extension
Kafka extension for Azure Functions
Version Downloads Last updated
5.3.0 475 4/19/2024
5.3.0-beta.1 91 4/16/2024
5.2.1 280,915 12/12/2023
5.2.0 115,868 9/25/2023
5.1.3 2,548,347 6/26/2023
5.1.2 778,547 4/28/2023
5.1.1 403,329 3/24/2023
5.1.0 376,493 2/22/2023
5.1.0-beta.1 1,772 2/8/2023
5.0.1 5,702,225 5/3/2022
5.0.0 5,149,897 10/26/2021
5.0.0-beta.5 119,635 7/9/2021
5.0.0-beta.4 35,218 5/18/2021
5.0.0-beta.3 14,100 3/10/2021
5.0.0-beta.2 20,154 2/10/2021
5.0.0-beta.1 32,294 11/10/2020