The name of the queue.
URL string value.
Clear deletes all messages from a queue.
Response data for the clear messages operation.
Creates a new queue under the specified account.
Optional_options: QueueCreateOptionsResponse data for the Queue create operation.
Example usage:
import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";
const account = "<account>";
const queueServiceClient = new QueueServiceClient(
`https://${account}.queue.core.windows.net`,
new DefaultAzureCredential(),
);
const queueName = "<valid queue name>";
const queueClient = queueServiceClient.getQueueClient(queueName);
const createQueueResponse = await queueClient.create();
console.log(
`Created queue ${queueName} successfully, service assigned request Id: ${createQueueResponse.requestId}`,
);
Creates a new queue under the specified account if it doesn't already exist. If the queue already exists, it is not changed.
Deletes the specified queue permanently.
Response data for the Queue delete operation.
Example usage:
import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";
const account = "<account>";
const queueServiceClient = new QueueServiceClient(
`https://${account}.queue.core.windows.net`,
new DefaultAzureCredential(),
);
const queueName = "<valid queue name>";
const queueClient = queueServiceClient.getQueueClient(queueName);
const deleteQueueResponse = await queueClient.delete();
console.log(
`Deleted queue successfully, service assigned request Id: ${deleteQueueResponse.requestId}`,
);
Deletes the specified queue permanently if it exists.
deleteMessage permanently removes the specified message from its queue.
Response data for the delete message operation.
Returns true if the specified queue exists; false otherwise.
NOTE: use this function with care since an existing queue might be deleted by other clients or applications. Vice versa new queues might be added by other clients or applications after this function completes.
Only available for QueueClient constructed with a shared key credential.
Generates string to sign for a Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the shared key credential of the client.
The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
Only available for QueueClient constructed with a shared key credential.
Generates a Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the shared key credential of the client.
The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
Gets details about any stored access policies specified on the queue that may be used with Shared Access Signatures.
WARNING: JavaScript Date will potential lost precision when parsing start and expiry string. For example, new Date("2018-12-31T03:44:23.8827891Z").toISOString() will get "2018-12-31T03:44:23.882Z".
Response data for the Queue get access policy operation.
Gets all user-defined metadata and system properties for the specified queue. Metadata is associated with the queue as name-values pairs.
Response data for the Queue get properties operation.
https://learn.microsoft.com/rest/api/storageservices/get-queue-metadata
WARNING: The metadata object returned in the response will have its keys in lowercase, even if
they originally contained uppercase characters. This differs from the metadata keys returned by
the listQueues method of QueueServiceClient using the includeMetadata option, which
will retain their original casing.
peekMessages retrieves one or more messages from the front of the queue but does not alter the visibility of the message.
Optional_options: QueuePeekMessagesOptionsResponse data for the peek messages operation.
Example usage:
import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";
const account = "<account>";
const queueServiceClient = new QueueServiceClient(
`https://${account}.queue.core.windows.net`,
new DefaultAzureCredential(),
);
const queueName = "<valid queue name>";
const queueClient = queueServiceClient.getQueueClient(queueName);
const peekMessagesResponse = await queueClient.peekMessages();
console.log(`The peeked message is: ${peekMessagesResponse.peekedMessageItems[0].messageText}`);
receiveMessages retrieves one or more messages from the front of the queue.
Optional_options: QueueReceiveMessageOptionsResponse data for the receive messages operation.
Example usage:
import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";
const account = "<account>";
const queueServiceClient = new QueueServiceClient(
`https://${account}.queue.core.windows.net`,
new DefaultAzureCredential(),
);
const queueName = "<valid queue name>";
const queueClient = queueServiceClient.getQueueClient(queueName);
const response = await queueClient.receiveMessages();
if (response.receivedMessageItems.length === 1) {
const receivedMessageItem = response.receivedMessageItems[0];
console.log(`Processing & deleting message with content: ${receivedMessageItem.messageText}`);
const deleteMessageResponse = await queueClient.deleteMessage(
receivedMessageItem.messageId,
receivedMessageItem.popReceipt,
);
console.log(
`Delete message successfully, service assigned request Id: ${deleteMessageResponse.requestId}`,
);
}
sendMessage adds a new message to the back of a queue. The visibility timeout specifies how long the message should be invisible to Dequeue and Peek operations. The message content is up to 64KB in size, and must be in a format that can be included in an XML request with UTF-8 encoding. To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.
Text of the message to send
Optional_options: QueueSendMessageOptionsResponse data for the send messages operation.
Example usage:
import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";
const account = "<account>";
const queueServiceClient = new QueueServiceClient(
`https://${account}.queue.core.windows.net`,
new DefaultAzureCredential(),
);
const queueName = "<valid queue name>";
const queueClient = queueServiceClient.getQueueClient(queueName);
// Send a message into the queue using the sendMessage method.
const sendMessageResponse = await queueClient.sendMessage("Hello World!");
console.log(
`Sent message successfully, service assigned message Id: ${sendMessageResponse.messageId}, service assigned request Id: ${sendMessageResponse.requestId}`,
);
Sets stored access policies for the queue that may be used with Shared Access Signatures.
Optional_identifiers: SignedIdentifier[]Response data for the Queue set access policy operation.
Sets one or more user-defined name-value pairs for the specified queue.
If no option provided, or no metadata defined in the option parameter, the queue metadata will be removed.
Response data for the Queue set metadata operation.
Update changes a message's visibility timeout and contents. The message content is up to 64KB in size, and must be in a format that can be included in an XML request with UTF-8 encoding. To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.
Response data for the update message operation.
An in-memory mock of the Azure QueueClient. It uses a Map to simulate queue storage and correctly implements the QueueClient interface.
Example