Overview
Azure Queue Storage provides reliable messaging for asynchronous communication between application components. It enables you to decouple workloads, scale services, and implement robust, fault‑tolerant architectures.
Getting Started
To create a queue, you can use the Azure portal, Azure CLI, PowerShell, or any supported SDK.
# Azure CLI
az storage queue create --name myqueue --account-name mystorageaccount
Core Concepts
- Queue: A container for messages.
- Message: A UTF‑8 string up to 64 KB. Each message is invisible for a configurable visibility timeout after being retrieved.
- Poison Message: A message that fails processing repeatedly.
REST API
All operations are performed over HTTPS. Example to insert a message:
PUT https://myaccount.queue.core.windows.net/myqueue/messages?timeout=30
Content-Type: text/plain
Hello, Azure Queue!
Refer to the official REST API reference for full details.
SDK Samples
C# (.NET)
using Azure.Storage.Queues;
var queueClient = new QueueClient(connectionString, "myqueue");
await queueClient.CreateIfNotExistsAsync();
await queueClient.SendMessageAsync("Hello, World!");
Python
from azure.storage.queue import QueueServiceClient
service = QueueServiceClient.from_connection_string(conn_str)
queue = service.get_queue_client("myqueue")
queue.create_queue()
queue.send_message("Hello, Python!")
JavaScript (Node.js)
const { QueueServiceClient } = require("@azure/storage-queue");
const client = QueueServiceClient.fromConnectionString(connStr);
const queueClient = client.getQueueClient("myqueue");
await queueClient.create();
await queueClient.sendMessage("Hello, Node!");
Best Practices
- Use exponential back‑off for retry policies.
- Implement dead‑letter queues for poison messages.
- Keep messages under 32 KB when possible to reduce latency.
- Leverage Azure Managed Identities for secure authentication.
FAQ
What is the maximum size of a queue? A queue can hold an unlimited number of messages, limited only by the storage account capacity.
How long can a message be hidden? Up to 7 days (604,800 seconds) using the visibility timeout.