Package version:
Creates an instance of QueueClient.
Account connection string or a SAS connection string of an Azure storage account.
[ Note - Account connection string can only be used in NODE.JS runtime. ]
Account connection string example -
DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net
SAS connection string example -
BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString
Queue name.
Optional
options: StoragePipelineOptionsOptions to configure the HTTP pipeline.
Creates an instance of QueueClient.
A URL string pointing to Azure Storage queue, such as "https://myaccount.queue.core.windows.net/myqueue". You can append a SAS if using AnonymousCredential, such as "https://myaccount.queue.core.windows.net/myqueue?sasString".
Optional
credential: anySuch as AnonymousCredential, StorageSharedKeyCredential or any credential from the @azure/identity
package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
Optional
options: StoragePipelineOptionsOptions to configure the HTTP pipeline.
Creates an instance of QueueClient.
A URL string pointing to Azure Storage queue, such as "https://myaccount.queue.core.windows.net/myqueue". You can append a SAS if using AnonymousCredential, such as "https://myaccount.queue.core.windows.net/myqueue?sasString".
Call newPipeline() to create a default pipeline, or provide a customized pipeline.
Readonly
accountProtected
Readonly
storageStorageClientContext is a reference to protocol layer operations entry, which is generated by AutoRest generator.
Readonly
urlURL string value.
Clear deletes all messages from a queue.
Options to clear messages operation.
Response data for the clear messages operation.
Creates a new queue under the specified account.
Options to Queue create operation.
Response 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.
Options to Queue delete operation.
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.
Id of the message.
A valid pop receipt value returned from an earlier call to the receive messages or update message operation.
Options to delete message operation.
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.
options to Exists operation.
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.
Optional parameters.
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.
Optional parameters.
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".
Options to Queue get access policy operation.
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.
Options to Queue get properties operation.
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.
Options to peek messages operation.
Response 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.
Options to receive messages operation.
Response 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
Options to send messages operation.
Response 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
queueAcl: {}Options to Queue set access policy operation.
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.
Optional
metadata: MetadataIf no metadata provided, all existing metadata will be removed.
Options to Queue set metadata operation.
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.
Id of the message
A valid pop receipt value returned from an earlier call to the receive messages or update message operation.
Optional
message: stringMessage to update. If this parameter is undefined, then the content of the message won't be updated.
Optional
visibilityTimeout: numberSpecifies the new visibility timeout value, in seconds, relative to server time. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. A message can be updated until it has been deleted or has expired.
Options to update message operation.
Response data for the update message operation.
A QueueClient represents a URL to an Azure Storage Queue's messages allowing you to manipulate its messages.