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

Hierarchy

Index

Constructors

constructor

Properties

accountName

accountName: string

credential

credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential

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.

memberof

StorageClient

Protected isHttps

isHttps: boolean
memberof

StorageClient

Protected storageClientContext

storageClientContext: StorageClientContext

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

memberof

StorageClient

url

url: string

Encoded URL string value.

memberof

StorageClient

Methods

createContainer

deleteContainer

getAccountInfo

getBlobBatchClient

getContainerClient

  • Creates a ContainerClient object

    memberof

    BlobServiceClient

    Example usage:

    const containerClient = blobServiceClient.getContainerClient("<container name>");

    Parameters

    • containerName: string

      A container name

    Returns ContainerClient

    A new ContainerClient object for the given container name.

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 using for await syntax:

    let i = 1;
    for await (const container of blobServiceClient.listContainers()) {
      console.log(`Container ${i++}: ${container.name}`);
    }

    Example using iter.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 using 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 using paging with a marker:

    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