Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QueueServiceClient

Package version

A QueueServiceClient represents a URL to the Azure Storage Queue service allowing you to manipulate queues.

export

Hierarchy

Index

Constructors

constructor

  • Creates an instance of QueueServiceClient.

    memberof

    QueueServiceClient

    Example using DefaultAzureCredential from @azure/identity:

    const account = "<account>";
    
    const credential = new DefaultAzureCredential();
    
    const queueServiceClient = new QueueServiceClient(
      `https://${account}.queue.core.windows.net`,
      credential
    }

    Example using an account name/key:

    const account = "<account>";
    
    const sharedKeyCredential = new StorageSharedKeyCredential(account, "<account key>");
    
    const queueServiceClient = new QueueServiceClient(
      `https://${account}.queue.core.windows.net`,
      sharedKeyCredential,
      {
        retryOptions: { maxTries: 4 }, // Retry options
        telemetry: { value: "BasicSample/V11.0.0" } // Customized telemetry string
      }
    );

    Parameters

    Returns QueueServiceClient

  • Creates an instance of QueueServiceClient.

    memberof

    QueueServiceClient

    Parameters

    Returns QueueServiceClient

Properties

accountName

accountName: string

Protected storageClientContext

storageClientContext: StorageClientContext

StorageClientContext is a reference to protocol layer operations entry, which is generated by AutoRest generator.

memberof

StorageClient

url

url: string

URL string value.

memberof

StorageClient

Methods

createQueue

deleteQueue

generateAccountSasUrl

  • Only available for QueueServiceClient constructed with a shared key credential.

    Generates an account 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.

    see

    https://docs.microsoft.com/en-us/rest/api/storageservices/create-account-sas

    memberof

    QueueServiceClient

    Parameters

    • Optional expiresOn: Date

      Optional. The time at which the shared access signature becomes invalid. Default to an hour later if not specified.

    • Default value permissions: AccountSASPermissions = AccountSASPermissions.parse("r")
    • Default value resourceTypes: string = "sco"
    • Default value options: ServiceGenerateAccountSasUrlOptions = {}

    Returns string

    An account SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.

getProperties

getQueueClient

  • Creates a QueueClient object.

    memberof

    QueueServiceClient

    Example usage:

    const queueClient = queueServiceClient.getQueueClient("<new queue name>");
    const createQueueResponse = await queueClient.create();

    Parameters

    • queueName: string

    Returns QueueClient

    a new QueueClient

getStatistics

listQueues

  • Returns an async iterable iterator to list all the queues under the specified account.

    .byPage() returns an async iterable iterator to list the queues in pages.

    Example using for await syntax:

    let i = 1;
    for await (const item of queueServiceClient.listQueues()) {
      console.log(`Queue${i}: ${item.name}`);
      i++;
    }

    Example using iter.next():

    let i = 1;
    let iterator = queueServiceClient.listQueues();
    let item = await iterator.next();
    while (!item.done) {
      console.log(`Queue${i}: ${iterator.value.name}`);
      i++;
      item = await iterator.next();
    }

    Example using byPage():

    // passing optional maxPageSize in the page settings
    let i = 1;
    for await (const item2 of queueServiceClient.listQueues().byPage({ maxPageSize: 20 })) {
      if (item2.queueItems) {
        for (const queueItem of item2.queueItems) {
          console.log(`Queue${i}: ${queueItem.name}`);
          i++;
        }
      }
    }

    Example using paging with a marker:

    let i = 1;
    let iterator = queueServiceClient.listQueues().byPage({ maxPageSize: 2 });
    let item = (await iterator.next()).value;
    
    // Prints 2 queue names
    if (item.queueItems) {
      for (const queueItem of item.queueItems) {
        console.log(`Queue${i}: ${queueItem.name}`);
        i++;
      }
    }
    // Gets next marker
    let marker = item.continuationToken;
    
    // Passing next marker as continuationToken
    iterator = queueServiceClient.listQueues().byPage({ continuationToken: marker, maxPageSize: 10 });
    item = (await iterator.next()).value;
    
    // Prints 10 queue names
    if (item.queueItems) {
      for (const queueItem of item.queueItems) {
        console.log(`Queue${i}: ${queueItem.name}`);
        i++;
      }
    }
    memberof

    QueueServiceClient

    Parameters

    Returns PagedAsyncIterableIterator<QueueItem, ServiceListQueuesSegmentResponse>

    An asyncIterableIterator that supports paging.

setProperties

Static fromConnectionString

  • Creates an instance of QueueServiceClient.

    memberof

    QueueServiceClient

    Parameters

    • connectionString: string

      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

    • Optional options: StoragePipelineOptions

    Returns QueueServiceClient

    A new QueueServiceClient object from the given connection string.

Generated using TypeDoc