Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BlobServiceClient

Package version

A BlobServiceClient represents a Client to the Azure Storage Blob service allowing you to manipulate blob containers.

export
class

BlobServiceClient

Hierarchy

Index

Constructors

constructor

Properties

accountName

accountName: string

credential

Such 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.

type

{StorageSharedKeyCredential | AnonymousCredential | TokenCredential}

memberof

StorageClient

Protected isHttps

isHttps: boolean
type

{boolean}

memberof

StorageClient

Protected storageClientContext

storageClientContext: StorageClientContext

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

type

{StorageClientContext}

memberof

StorageClient

url

url: string

Encoded URL string value.

type

{string}

memberof

StorageClient

Methods

createContainer

deleteContainer

getAccountInfo

getBlobBatchClient

getContainerClient

getProperties

getStatistics

getUserDelegationKey

listContainers

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

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

    example
      let i = 1;
      for await (const container of blobServiceClient.listContainers()) {
        console.log(`Container ${i++}: ${container.name}`);
      }
    example
      // Generator syntax .next()
      let i = 1;
      const iter = blobServiceClient.listContainers();
      let containerItem = await iter.next();
      while (!containerItem.done) {
        console.log(`Container ${i++}: ${containerItem.value.name}`);
        containerItem = await iter.next();
      }
    example
      // Example for .byPage()
      // passing optional maxPageSize in the page settings
      let i = 1;
      for await (const response of blobServiceClient.listContainers().byPage({ maxPageSize: 20 })) {
        if (response.containerItems) {
          for (const container of response.containerItems) {
            console.log(`Container ${i++}: ${container.name}`);
          }
        }
      }
    example
      // Passing marker as an argument (similar to the previous example)
      let i = 1;
      let iterator = blobServiceClient.listContainers().byPage({ maxPageSize: 2 });
      let response = (await iterator.next()).value;
      // Prints 2 container names
      if (response.containerItems) {
        for (const container of response.containerItems) {
          console.log(`Container ${i++}: ${container.name}`);
        }
      }
      // Gets next marker
      let marker = response.continuationToken;
      // Passing next marker as continuationToken
      iterator = blobServiceClient
        .listContainers()
        .byPage({ continuationToken: marker, maxPageSize: 10 });
      response = (await iterator.next()).value;
      // Prints 10 container names
      if (response.containerItems) {
        for (const container of response.containerItems) {
           console.log(`Container ${i++}: ${container.name}`);
        }
      }
    memberof

    BlobServiceClient

    Parameters

    Returns PagedAsyncIterableIterator<ContainerItem, ServiceListContainersSegmentResponse>

    An asyncIterableIterator that supports paging.

setProperties

Static fromConnectionString

  • Creates an instance of BlobServiceClient from connection string.

    memberof

    BlobServiceClient

    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 BlobServiceClient

Generated using TypeDoc