Azure Queue Storage Reference
This section provides detailed reference documentation for Azure Queue Storage, a service that stores large numbers of messages that can be accessed from anywhere in the world. Queue storage is used to build applications that decouple components and rely on asynchronous processing.
Introduction to Queue Storage
Azure Queue Storage is a service for storing large numbers of messages that can be accessed from anywhere in the world via HTTP or HTTPS. A queue message is typically composed of a string value that is up to 64 KB in size. Queue Storage is used to build applications that decouple components and rely on asynchronous processing.
Key features include:
- Scalability: Handles millions of messages.
- Reliability: Messages are persisted until processed.
- Accessibility: Accessible via REST APIs and SDKs across various languages.
- Cost-effective: Optimized for high-throughput messaging scenarios.
Core Concepts
Understanding these concepts is crucial when working with Azure Queue Storage:
Queues
A queue is a collection of messages. Each queue must have a unique name within a storage account. Queue names are case-insensitive and follow specific naming conventions.
Messages
A message is a data item stored in a queue. Messages are typically small strings (up to 64KB). Each message has an ID and a value. Messages can have a visibility timeout, which controls when they become visible again after being dequeued.
Message Visibility
When a message is dequeued, it becomes invisible for a specified period (visibility timeout). If the message is not deleted within this timeout, it becomes visible again and can be dequeued by another client. This mechanism ensures that messages are processed reliably.
Message Lifecycle
A message goes through several states: added, enqueued, dequeued (becomes invisible), processed, and then deleted. If a message is processed successfully, it should be deleted from the queue. If processing fails, it can be left to become visible again.
REST API Reference
Azure Queue Storage exposes a robust REST API for managing queues and messages.
Queues - Create
Creates a new queue under the specified account.
Parameters:
Name | Type | Description |
---|---|---|
x-ms-version | String | Specifies the version of the REST API. Required. |
Authorization | String | Specifies the authorization header. Required. |
Date | String | Specifies the date and time of the request. Required. |
Responses:
201 Created: Queue created successfully.
409 Conflict: Queue with the specified name already exists.
Messages - Put
Adds a new message to the specified queue.
Parameters:
Name | Type | Description |
---|---|---|
x-ms-version | String | Specifies the version of the REST API. Required. |
x-ms-visibilitytimeout | Integer | Specifies the visibility timeout in seconds. Optional. |
content-length | Integer | The length of the request body. Required. |
Authorization | String | Specifies the authorization header. Required. |
Date | String | Specifies the date and time of the request. Required. |
Request Body:
<QueueMessage>
<MessageText>Your message content here</MessageText>
</QueueMessage>
Responses:
204 No Content: Message added successfully.
Messages - Get
Retrieves one or more messages from the queue. The messages are made invisible until the visibility timeout expires or they are explicitly deleted.
Parameters:
Name | Type | Description |
---|---|---|
x-ms-version | String | Specifies the version of the REST API. Required. |
numofmessages | Integer | Specifies the number of messages to retrieve (1-32). Optional. |
visibilitytimeout | Integer | Specifies the visibility timeout in seconds. Optional. |
Authorization | String | Specifies the authorization header. Required. |
Date | String | Specifies the date and time of the request. Required. |
Responses:
200 OK: Messages retrieved successfully.
<QueueMessagesList>
<QueueMessage>
<MessageId>...</MessageId>
<InsertionTime>...</InsertionTime>
<ExpirationTime>...</ExpirationTime>
<PopReceipt>...</PopReceipt>
<DequeueCount>...</DequeueCount>
<MessageText>...</MessageText>
</QueueMessage>
...
</QueueMessagesList>
Messages - Delete
Deletes a specific message from the queue.
Parameters:
Name | Type | Description |
---|---|---|
messageid | String | The ID of the message to delete. Required. |
popreceipt | String | The pop receipt associated with the message. Required. |
x-ms-version | String | Specifies the version of the REST API. Required. |
Authorization | String | Specifies the authorization header. Required. |
Date | String | Specifies the date and time of the request. Required. |
Responses:
204 No Content: Message deleted successfully.
SDK Reference
Azure Queue Storage is supported by various SDKs. Here are links to the relevant SDK documentation:
- Azure SDK for .NET - Queue Storage
- Azure SDK for Java - Queue Storage
- Azure SDK for Python - Queue Storage
- Azure SDK for JavaScript - Queue Storage
- Azure SDK for Go - Queue Storage
These SDKs provide a higher-level abstraction for interacting with Queue Storage, simplifying common operations.
Code Samples
Explore these code samples to see Azure Queue Storage in action: