Azure Queue Storage Reference

Azure Storage Queue Storage REST API SDK

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

PUT /{accountName}/queues/{queueName}

Creates a new queue under the specified account.

Parameters:

NameTypeDescription
x-ms-versionStringSpecifies the version of the REST API. Required.
AuthorizationStringSpecifies the authorization header. Required.
DateStringSpecifies 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

POST /{accountName}/queues/{queueName}/messages

Adds a new message to the specified queue.

Parameters:

NameTypeDescription
x-ms-versionStringSpecifies the version of the REST API. Required.
x-ms-visibilitytimeoutIntegerSpecifies the visibility timeout in seconds. Optional.
content-lengthIntegerThe length of the request body. Required.
AuthorizationStringSpecifies the authorization header. Required.
DateStringSpecifies 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

GET /{accountName}/queues/{queueName}/messages

Retrieves one or more messages from the queue. The messages are made invisible until the visibility timeout expires or they are explicitly deleted.

Parameters:

NameTypeDescription
x-ms-versionStringSpecifies the version of the REST API. Required.
numofmessagesIntegerSpecifies the number of messages to retrieve (1-32). Optional.
visibilitytimeoutIntegerSpecifies the visibility timeout in seconds. Optional.
AuthorizationStringSpecifies the authorization header. Required.
DateStringSpecifies 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

DELETE /{accountName}/queues/{queueName}/messages/{messageid}?popreceipt={popreceipt}

Deletes a specific message from the queue.

Parameters:

NameTypeDescription
messageidStringThe ID of the message to delete. Required.
popreceiptStringThe pop receipt associated with the message. Required.
x-ms-versionStringSpecifies the version of the REST API. Required.
AuthorizationStringSpecifies the authorization header. Required.
DateStringSpecifies 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:

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: