Skip to content

Latest commit

 

History

History
102 lines (82 loc) · 4.45 KB

File metadata and controls

102 lines (82 loc) · 4.45 KB

Azure Storage Queues client library for .NET

Server Version: 2018-11-09

Azure Queue storage is a service for storing large numbers of messages that can be accessed from anywhere in the world via authenticated calls using HTTP or HTTPS. A single queue message can be up to 64 KB in size, and a queue can contain millions of messages, up to the total capacity limit of a storage account.

Source code | Package (NuGet) | API reference documentation | Product documentation

Getting started

Install the package

Install the Azure Storage Queues client library for .NET with NuGet:

Install-Package Azure.Storage.Queues

Prerequisites: You must have an Azure subscription, and a Storage Account to use this package.

To create a Storage Account, you can use the Azure Portal, Azure PowerShell or Azure CLI:

Key concepts

Common uses of Queue storage include:

  • Creating a backlog of work to process asynchronously
  • Passing messages between different parts of a distributed application

Examples

Create a queue

string connectionString = <connection_string>;
var service = new QueueServiceClient(connectionString);
var queue = service.GetQueueClient("myqueue");

await queue.CreateAsync();

Enqueue messages

string connectionString = <connection_string>;
var service = new QueueServiceClient(connectionString);
var queue = service.GetQueueClient("myqueue");

var messages = queue.GetMessagesClient();
await messages.EnqueueAsync("Start using Azure");
await messages.EnqueueAsync("Get started with Queues");

Dequeue messages

string connectionString = <connection_string>;
var service = new QueueServiceClient(connectionString);
var queue = service.GetQueueClient("myqueue");

var messages = queue.GetMessagesClient();
response = await messages.DequeueAsync();
foreach (var message in response.Value)
{
    Console.WriteLine(message.MessageText);
}

Troubleshooting

All Azure Storage Queue service operations will throw a StorageRequestFailedException on failure with helpful ErrorCodes.

Next steps

Get started with our Queue samples.

Contributing

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 https://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.

Impressions