Azure Storage Queue Reference
This document provides reference information for the Azure Storage Queue REST API. Azure Queues is a service that allows you to store large numbers of messages that can be accessed from anywhere in the world via HTTP or HTTPS.
The Queue service supports the following operations:
- Managing queues
- Managing messages within queues
- Implementing shared access signatures for delegated access to queues and messages
The Queue service uses a simple REST API that exposes endpoints for these operations. You can interact with the Queue service using any HTTP client.
Queues
A queue is a collection of messages. The Queue service provides operations for creating, listing, and deleting queues. The base URI for a queue is:
https://.queue.core.windows.net/
Queue Operations
Operation | HTTP Method | Description |
---|---|---|
Create Queue | PUT |
Creates a new queue within the specified storage account. |
Get Queue Metadata | GET |
Retrieves the metadata for a queue. |
List Queues | GET |
Lists all queues associated with the specified storage account. |
Delete Queue | DELETE |
Deletes a specified queue and all the messages it contains. |
Set Queue Metadata | PUT |
Sets metadata on a queue. |
Get Queue ACL | GET |
Retrieves the Access Control List (ACL) for a queue. |
Set Queue ACL | PUT |
Sets the Access Control List (ACL) for a queue. |
Create Queue
The PUT
operation creates a new queue. If a queue with the same name already exists, the operation fails with status code 409 Conflict
.
PUT /{queue-name} HTTP/1.1
Authorization: SharedKey MyAccount:X0a/vSgE0E0u3Wd30o+40K3M/GzQ2T/i1rNl58o5rU4=
Date: Mon, 27 Jul 2009 17:40:37 GMT
Content-Length: 0
x-ms-version: 2009-09-19
Delete Queue
The DELETE
operation deletes a queue and all messages it contains. Once deleted, the queue cannot be recovered.
DELETE /{queue-name} HTTP/1.1
Authorization: SharedKey MyAccount:X0a/vSgE0E0u3Wd30o+40K3M/GzQ2T/i1rNl58o5rU4=
Date: Mon, 27 Jul 2009 17:40:37 GMT
Content-Length: 0
x-ms-version: 2009-09-19
Messages
Operations on messages include enqueueing, dequeuing, peeking, updating, and deleting. The base URI for messages within a queue is:
https://.queue.core.windows.net//messages
Message Operations
Operation | HTTP Method | Description |
---|---|---|
Enqueue Message | POST |
Adds a new message to the back of a queue. |
Dequeue Messages | GET |
Retrieves one or more messages from the front of a queue. |
Peek Messages | GET |
Retrieves one or more messages from the front of a queue, but does not make them invisible. |
Update Message | PUT |
Updates the visibility timeout for a specific message. |
Clear Messages | DELETE |
Deletes all messages from a queue. |
Enqueue Message
The POST
operation adds a message to the queue. The message body can be any string or binary data.
POST /{queue-name}/messages HTTP/1.1
Authorization: SharedKey MyAccount:X0a/vSgE0E0u3Wd30o+40K3M/GzQ2T/i1rNl58o5rU4=
Date: Mon, 27 Jul 2009 17:40:37 GMT
Content-Length: 24
x-ms-version: 2009-09-19
This is the message text.
Dequeue Messages
The GET
operation retrieves one or more messages from the front of the queue. A message that is dequeued becomes invisible for a specified period (visibility timeout) and can then be re-processed if not deleted.
GET /{queue-name}/messages?numofmessages=5&visibilitytimeout=30 HTTP/1.1
Authorization: SharedKey MyAccount:X0a/vSgE0E0u3Wd30o+40K3M/GzQ2T/i1rNl58o5rU4=
Date: Mon, 27 Jul 2009 17:40:37 GMT
x-ms-version: 2009-09-19
Shared Access Signatures (SAS)
Shared Access Signatures (SAS) provide a secure way to delegate access to Azure Storage resources, such as queues, without sharing your account access key.
Key Concepts
- Delegated Access: Allows clients to access queues or messages with permissions defined by a SAS token, rather than the account key.
- Permissions: You can grant specific permissions (e.g., Read, Write, List, Add, Process) to a SAS token.
- Expiry: SAS tokens have an expiration time, after which they become invalid.
Generating a SAS Token
SAS tokens are typically generated by the account owner using the Azure SDKs or Azure CLI. The REST API allows you to define the parameters for a SAS when generating it, or to manage existing SAS policies.