@azure/storage-blob

  • Version 12.10.0
  • Published
  • 6.41 MB
  • 8 dependencies
  • MIT license

Install

npm i @azure/storage-blob
yarn add @azure/storage-blob
pnpm add @azure/storage-blob

Overview

Microsoft Azure Storage SDK for JavaScript - Blob

Index

Variables

Functions

Classes

Interfaces

Enums

Type Aliases

Variables

variable logger

const logger: AzureLogger;
  • The @azure/logger configuration for this package.

variable StorageOAuthScopes

const StorageOAuthScopes: string | string[];
  • The OAuth scope to use with Azure Storage.

Functions

function generateAccountSASQueryParameters

generateAccountSASQueryParameters: (
accountSASSignatureValues: AccountSASSignatureValues,
sharedKeyCredential: StorageSharedKeyCredential
) => SASQueryParameters;
  • ONLY AVAILABLE IN NODE.JS RUNTIME.

    Generates a SASQueryParameters object which contains all SAS query parameters needed to make an actual REST request.

    Parameter accountSASSignatureValues

    Parameter sharedKeyCredential

    See Also

    • https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas

function generateBlobSASQueryParameters

generateBlobSASQueryParameters: {
(
blobSASSignatureValues: BlobSASSignatureValues,
sharedKeyCredential: StorageSharedKeyCredential
): SASQueryParameters;
(
blobSASSignatureValues: BlobSASSignatureValues,
userDelegationKey: UserDelegationKey,
accountName: string
): SASQueryParameters;
};
  • ONLY AVAILABLE IN NODE.JS RUNTIME.

    Creates an instance of SASQueryParameters.

    Only accepts required settings needed to create a SAS. For optional settings please set corresponding properties directly, such as permissions, startsOn and identifier.

    WARNING: When identifier is not provided, permissions and expiresOn are required. You MUST assign value to identifier or expiresOn & permissions manually if you initial with this constructor.

    Fill in the required details before running the following snippets.

    Example usage:

    // Generate service level SAS for a container
    const containerSAS = generateBlobSASQueryParameters({
    containerName, // Required
    permissions: ContainerSASPermissions.parse("racwdl"), // Required
    startsOn: new Date(), // Optional
    expiresOn: new Date(new Date().valueOf() + 86400), // Required. Date type
    ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // Optional
    protocol: SASProtocol.HttpsAndHttp, // Optional
    version: "2016-05-31" // Optional
    },
    sharedKeyCredential // StorageSharedKeyCredential - `new StorageSharedKeyCredential(account, accountKey)`
    ).toString();

    Example using an identifier:

    // Generate service level SAS for a container with identifier
    // startsOn & permissions are optional when identifier is provided
    const identifier = "unique-id";
    await containerClient.setAccessPolicy(undefined, [
    {
    accessPolicy: {
    expiresOn: new Date(new Date().valueOf() + 86400), // Date type
    permissions: ContainerSASPermissions.parse("racwdl").toString(),
    startsOn: new Date() // Date type
    },
    id: identifier
    }
    ]);
    const containerSAS = generateBlobSASQueryParameters(
    {
    containerName, // Required
    identifier // Required
    },
    sharedKeyCredential // StorageSharedKeyCredential - `new StorageSharedKeyCredential(account, accountKey)`
    ).toString();

    Example using a blob name:

    // Generate service level SAS for a blob
    const blobSAS = generateBlobSASQueryParameters({
    containerName, // Required
    blobName, // Required
    permissions: BlobSASPermissions.parse("racwd"), // Required
    startsOn: new Date(), // Optional
    expiresOn: new Date(new Date().valueOf() + 86400), // Required. Date type
    cacheControl: "cache-control-override", // Optional
    contentDisposition: "content-disposition-override", // Optional
    contentEncoding: "content-encoding-override", // Optional
    contentLanguage: "content-language-override", // Optional
    contentType: "content-type-override", // Optional
    ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // Optional
    protocol: SASProtocol.HttpsAndHttp, // Optional
    version: "2016-05-31" // Optional
    },
    sharedKeyCredential // StorageSharedKeyCredential - `new StorageSharedKeyCredential(account, accountKey)`
    ).toString();

    Parameter blobSASSignatureValues

    Parameter sharedKeyCredential

  • ONLY AVAILABLE IN NODE.JS RUNTIME.

    Creates an instance of SASQueryParameters. WARNING: identifier will be ignored when generating user delegation SAS, permissions and expiresOn are required.

    Example usage:

    // Generate user delegation SAS for a container
    const userDelegationKey = await blobServiceClient.getUserDelegationKey(startsOn, expiresOn);
    const containerSAS = generateBlobSASQueryParameters({
    containerName, // Required
    permissions: ContainerSASPermissions.parse("racwdl"), // Required
    startsOn, // Optional. Date type
    expiresOn, // Required. Date type
    ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // Optional
    protocol: SASProtocol.HttpsAndHttp, // Optional
    version: "2018-11-09" // Must greater than or equal to 2018-11-09 to generate user delegation SAS
    },
    userDelegationKey, // UserDelegationKey
    accountName
    ).toString();

    Parameter blobSASSignatureValues

    Parameter userDelegationKey

    Return value of blobServiceClient.getUserDelegationKey()

    Parameter accountName

function isPipelineLike

isPipelineLike: (pipeline: unknown) => pipeline is PipelineLike;
  • A helper to decide if a given argument satisfies the Pipeline contract

    Parameter pipeline

    An argument that may be a Pipeline

    Returns

    true when the argument satisfies the Pipeline contract

function newPipeline

newPipeline: (
credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,
pipelineOptions?: StoragePipelineOptions
) => Pipeline;
  • Creates a new Pipeline object with Credential provided.

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

    Parameter pipelineOptions

    Optional. Options.

    Returns

    A new Pipeline object.

Classes

class AccountSASPermissions

class AccountSASPermissions {}
  • ONLY AVAILABLE IN NODE.JS RUNTIME.

    This is a helper class to construct a string representing the permissions granted by an AccountSAS. Setting a value to true means that any SAS which uses these permissions will grant permissions for that operation. Once all the values are set, this should be serialized with toString and set as the permissions field on an AccountSASSignatureValues object. It is possible to construct the permissions string without this class, but the order of the permissions is particular and this class guarantees correctness.

property add

add: boolean;
  • Permission to add messages, table entities, and append to blobs granted.

property create

create: boolean;
  • Permission to create blobs and files granted.

property delete

delete: boolean;
  • Permission to create blobs and files granted.

property deleteVersion

deleteVersion: boolean;
  • Permission to delete versions granted.

property filter

filter: boolean;
  • Permission to filter blobs.

property list

list: boolean;
  • Permission to list blob containers, blobs, shares, directories, and files granted.

property permanentDelete

permanentDelete: boolean;
  • Specifies that Permanent Delete is permitted.

property process

process: boolean;
  • Permission to get and delete messages granted.

property read

read: boolean;
  • Permission to read resources and list queues and tables granted.

property setImmutabilityPolicy

setImmutabilityPolicy: boolean;
  • Permission to set immutability policy.

property tag

tag: boolean;
  • Specfies Tag access granted.

property update

update: boolean;
  • Permissions to update messages and table entities granted.

property write

write: boolean;
  • Permission to write resources granted.

method from

static from: (
permissionLike: AccountSASPermissionsLike
) => AccountSASPermissions;
  • Creates a AccountSASPermissions from a raw object which contains same keys as it and boolean values for them.

    Parameter permissionLike

method parse

static parse: (permissions: string) => AccountSASPermissions;
  • Parse initializes the AccountSASPermissions fields from a string.

    Parameter permissions

method toString

toString: () => string;
  • Produces the SAS permissions string for an Azure Storage account. Call this method to set AccountSASSignatureValues Permissions field.

    Using this method will guarantee the resource types are in an order accepted by the service.

    See Also

    • https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas

class AccountSASResourceTypes

class AccountSASResourceTypes {}
  • ONLY AVAILABLE IN NODE.JS RUNTIME.

    This is a helper class to construct a string representing the resources accessible by an AccountSAS. Setting a value to true means that any SAS which uses these permissions will grant access to that resource type. Once all the values are set, this should be serialized with toString and set as the resources field on an AccountSASSignatureValues object. It is possible to construct the resources string without this class, but the order of the resources is particular and this class guarantees correctness.

property container

container: boolean;
  • Permission to access container level APIs (Blob Containers, Tables, Queues, File Shares) granted.

property object

object: boolean;
  • Permission to access object level APIs (Blobs, Table Entities, Queue Messages, Files) granted.

property service

service: boolean;
  • Permission to access service level APIs granted.

method parse

static parse: (resourceTypes: string) => AccountSASResourceTypes;
  • Creates an AccountSASResourceTypes from the specified resource types string. This method will throw an Error if it encounters a character that does not correspond to a valid resource type.

    Parameter resourceTypes

method toString

toString: () => string;
  • Converts the given resource types to a string.

    See Also

    • https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas

class AccountSASServices

class AccountSASServices {}
  • ONLY AVAILABLE IN NODE.JS RUNTIME.

    This is a helper class to construct a string representing the services accessible by an AccountSAS. Setting a value to true means that any SAS which uses these permissions will grant access to that service. Once all the values are set, this should be serialized with toString and set as the services field on an AccountSASSignatureValues object. It is possible to construct the services string without this class, but the order of the services is particular and this class guarantees correctness.

property blob

blob: boolean;
  • Permission to access blob resources granted.

property file

file: boolean;
  • Permission to access file resources granted.

property queue

queue: boolean;
  • Permission to access queue resources granted.

property table

table: boolean;
  • Permission to access table resources granted.

method parse

static parse: (services: string) => AccountSASServices;
  • Creates an AccountSASServices from the specified services string. This method will throw an Error if it encounters a character that does not correspond to a valid service.

    Parameter services

method toString

toString: () => string;
  • Converts the given services to a string.

class AnonymousCredential

class AnonymousCredential extends Credential_2 {}
  • AnonymousCredential provides a credentialPolicyCreator member used to create AnonymousCredentialPolicy objects. AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources or for use with Shared Access Signatures (SAS).

method create

create: (
nextPolicy: RequestPolicy,
options: RequestPolicyOptions
) => AnonymousCredentialPolicy;

class AnonymousCredentialPolicy

class AnonymousCredentialPolicy extends CredentialPolicy {}
  • AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources or for use with Shared Access Signatures (SAS).

constructor

constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions);
  • Creates an instance of AnonymousCredentialPolicy.

    Parameter nextPolicy

    Parameter options

class AppendBlobClient

class AppendBlobClient extends BlobClient {}
  • AppendBlobClient defines a set of operations applicable to append blobs.

constructor

constructor(
connectionString: string,
containerName: string,
blobName: string,
options?: StoragePipelineOptions
);
  • Creates an instance of AppendBlobClient.

    Parameter connectionString

    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

    Parameter containerName

    Container name.

    Parameter blobName

    Blob name.

    Parameter options

    Optional. Options to configure the HTTP pipeline.

constructor

constructor(url: string, credential: any, options?: StoragePipelineOptions);
  • Creates an instance of AppendBlobClient. This method accepts an encoded URL or non-encoded URL pointing to an append blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

    Parameter url

    A URL string pointing to Azure Storage append blob, such as "https://myaccount.blob.core.windows.net/mycontainer/appendblob". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer/appendblob?sasString". This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. However, if a blob name includes ? or %, blob name must be encoded in the URL. Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".

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

    Parameter options

    Optional. Options to configure the HTTP pipeline.

constructor

constructor(url: string, pipeline: PipelineLike);
  • Creates an instance of AppendBlobClient. This method accepts an encoded URL or non-encoded URL pointing to an append blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

    Parameter url

    A URL string pointing to Azure Storage append blob, such as "https://myaccount.blob.core.windows.net/mycontainer/appendblob". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer/appendblob?sasString". This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. However, if a blob name includes ? or %, blob name must be encoded in the URL. Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".

    Parameter pipeline

    Call newPipeline() to create a default pipeline, or provide a customized pipeline.

method appendBlock

appendBlock: (
body: HttpRequestBody,
contentLength: number,
options?: AppendBlobAppendBlockOptions
) => Promise<AppendBlobAppendBlockResponse>;
  • Commits a new block of data to the end of the existing append blob.

    Parameter body

    Data to be appended.

    Parameter contentLength

    Length of the body in bytes.

    Parameter options

    Options to the Append Block operation.

    Example usage:

    const content = "Hello World!";
    // Create a new append blob and append data to the blob.
    const newAppendBlobClient = containerClient.getAppendBlobClient("<blob name>");
    await newAppendBlobClient.create();
    await newAppendBlobClient.appendBlock(content, content.length);
    // Append data to an existing append blob.
    const existingAppendBlobClient = containerClient.getAppendBlobClient("<blob name>");
    await existingAppendBlobClient.appendBlock(content, content.length);

    See Also

    • https://docs.microsoft.com/rest/api/storageservices/append-block

method appendBlockFromURL

appendBlockFromURL: (
sourceURL: string,
sourceOffset: number,
count: number,
options?: AppendBlobAppendBlockFromURLOptions
) => Promise<AppendBlobAppendBlockFromUrlResponse>;
  • The Append Block operation commits a new block of data to the end of an existing append blob where the contents are read from a source url.

    Parameter sourceURL

    The url to the blob that will be the source of the copy. A source blob in the same storage account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob must either be public or must be authenticated via a shared access signature. If the source blob is public, no authentication is required to perform the operation.

    Parameter sourceOffset

    Offset in source to be appended

    Parameter count

    Number of bytes to be appended as a block

    Parameter options

    See Also

    • https://docs.microsoft.com/en-us/rest/api/storageservices/append-block-from-url

method create

create: (options?: AppendBlobCreateOptions) => Promise<AppendBlobCreateResponse>;
  • Creates a 0-length append blob. Call AppendBlock to append data to an append blob.

    Parameter options

    Options to the Append Block Create operation.

    Example usage:

    const appendBlobClient = containerClient.getAppendBlobClient("<blob name>");
    await appendBlobClient.create();

    See Also

    • https://docs.microsoft.com/rest/api/storageservices/put-blob

method createIfNotExists

createIfNotExists: (
options?: AppendBlobCreateIfNotExistsOptions
) => Promise<AppendBlobCreateIfNotExistsResponse>;
  • Creates a 0-length append blob. Call AppendBlock to append data to an append blob. If the blob with the same name already exists, the content of the existing blob will remain unchanged.

    Parameter options

    See Also

    • https://docs.microsoft.com/rest/api/storageservices/put-blob

method seal

seal: (
options?: AppendBlobSealOptions
) => Promise<AppendBlobAppendBlockResponse>;
  • Seals the append blob, making it read only.

    Parameter options

method withSnapshot

withSnapshot: (snapshot: string) => AppendBlobClient;
  • Creates a new AppendBlobClient object identical to the source but with the specified snapshot timestamp. Provide "" will remove the snapshot and return a Client to the base blob.

    Parameter snapshot

    The snapshot timestamp.

    Returns

    A new AppendBlobClient object identical to the source but with the specified snapshot timestamp.

class BlobBatch

class BlobBatch {}
  • A BlobBatch represents an aggregated set of operations on blobs. Currently, only delete and setAccessTier are supported.

constructor

constructor();

    method deleteBlob

    deleteBlob: {
    (
    url: string,
    credential:
    | StorageSharedKeyCredential
    | AnonymousCredential
    | TokenCredential,
    options?: BlobDeleteOptions
    ): Promise<void>;
    (blobClient: BlobClient, options?: BlobDeleteOptions): Promise<void>;
    };
    • The deleteBlob operation marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Only one kind of operation is allowed per batch request.

      Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time. See [delete operation details](https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob). The operation will be authenticated and authorized with specified credential. See [blob batch authorization details](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).

      Parameter url

      The url of the blob resource to delete.

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

      Parameter options

    • The deleteBlob operation marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Only one kind of operation is allowed per batch request.

      Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time. See [delete operation details](https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob). The operation will be authenticated and authorized with specified credential. See [blob batch authorization details](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).

      Parameter blobClient

      The BlobClient.

      Parameter options

    method getHttpRequestBody

    getHttpRequestBody: () => string;
    • Get assembled HTTP request body for sub requests.

    method getMultiPartContentType

    getMultiPartContentType: () => string;
    • Get the value of Content-Type for a batch request. The value must be multipart/mixed with a batch boundary. Example: multipart/mixed; boundary=batch_a81786c8-e301-4e42-a729-a32ca24ae252

    method getSubRequests

    getSubRequests: () => Map<number, BatchSubRequest>;
    • Get sub requests that are added into the batch request.

    method setBlobAccessTier

    setBlobAccessTier: {
    (
    url: string,
    credential:
    | StorageSharedKeyCredential
    | AnonymousCredential
    | TokenCredential,
    tier: AccessTier,
    options?: BlobSetTierOptions
    ): Promise<void>;
    (
    blobClient: BlobClient,
    tier: AccessTier,
    options?: BlobSetTierOptions
    ): Promise<void>;
    };
    • The setBlobAccessTier operation sets the tier on a blob. The operation is allowed on block blobs in a blob storage or general purpose v2 account. Only one kind of operation is allowed per batch request.

      A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag. For detailed information about block blob level tiering see [hot, cool, and archive access tiers](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers). The operation will be authenticated and authorized with specified credential. See [blob batch authorization details](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).

      Parameter url

      The url of the blob resource to delete.

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

      Parameter tier

      Parameter options

    • The setBlobAccessTier operation sets the tier on a blob. The operation is allowed on block blobs in a blob storage or general purpose v2 account. Only one kind of operation is allowed per batch request.

      A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag. For detailed information about block blob level tiering see [hot, cool, and archive access tiers](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers). The operation will be authenticated and authorized with specified credential. See [blob batch authorization details](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).

      Parameter blobClient

      The BlobClient.

      Parameter tier

      Parameter options

    class BlobBatchClient

    class BlobBatchClient {}
    • A BlobBatchClient allows you to make batched requests to the Azure Storage Blob service.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch

    constructor

    constructor(url: string, credential?: any, options?: StoragePipelineOptions);
    • Creates an instance of BlobBatchClient.

      Parameter url

      A url pointing to Azure Storage blob service, such as "https://myaccount.blob.core.windows.net". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".

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

      Parameter options

      Options to configure the HTTP pipeline.

    constructor

    constructor(url: string, pipeline: PipelineLike);
    • Creates an instance of BlobBatchClient.

      Parameter url

      A url pointing to Azure Storage blob service, such as "https://myaccount.blob.core.windows.net". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".

      Parameter pipeline

      Call newPipeline() to create a default pipeline, or provide a customized pipeline.

    method createBatch

    createBatch: () => BlobBatch;
    • Creates a BlobBatch. A BlobBatch represents an aggregated set of operations on blobs.

    method deleteBlobs

    deleteBlobs: {
    (
    urls: string[],
    credential:
    | StorageSharedKeyCredential
    | AnonymousCredential
    | TokenCredential,
    options?: BlobDeleteOptions
    ): Promise<BlobBatchDeleteBlobsResponse>;
    (
    blobClients: BlobClient[],
    options?: BlobDeleteOptions
    ): Promise<BlobBatchSubmitBatchResponse>;
    };
    • Create multiple delete operations to mark the specified blobs or snapshots for deletion. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time. See [delete operation details](https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob). The operations will be authenticated and authorized with specified credential. See [blob batch authorization details](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).

      Parameter urls

      The urls of the blob resources to delete.

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

      Parameter options

    • Create multiple delete operations to mark the specified blobs or snapshots for deletion. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time. See [delete operation details](https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob). The operation(subrequest) will be authenticated and authorized with specified credential. See [blob batch authorization details](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).

      Parameter blobClients

      The BlobClients for the blobs to delete.

      Parameter options

    method setBlobsAccessTier

    setBlobsAccessTier: {
    (
    urls: string[],
    credential:
    | StorageSharedKeyCredential
    | AnonymousCredential
    | TokenCredential,
    tier: AccessTier,
    options?: BlobSetTierOptions
    ): Promise<BlobBatchSetBlobsAccessTierResponse>;
    (
    blobClients: BlobClient[],
    tier: AccessTier,
    options?: BlobSetTierOptions
    ): Promise<BlobBatchSubmitBatchResponse>;
    };
    • Create multiple set tier operations to set the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag. See [set blob tier details](https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier). The operation(subrequest) will be authenticated and authorized with specified credential.See [blob batch authorization details](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).

      Parameter urls

      The urls of the blob resource to delete.

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

      Parameter tier

      Parameter options

    • Create multiple set tier operations to set the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag. See [set blob tier details](https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier). The operation(subrequest) will be authenticated and authorized with specified credential.See [blob batch authorization details](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).

      Parameter blobClients

      The BlobClients for the blobs which should have a new tier set.

      Parameter tier

      Parameter options

    method submitBatch

    submitBatch: (
    batchRequest: BlobBatch,
    options?: BlobBatchSubmitBatchOptionalParams
    ) => Promise<BlobBatchSubmitBatchResponse>;
    • Submit batch request which consists of multiple subrequests.

      Get blobBatchClient and other details before running the snippets. blobServiceClient.getBlobBatchClient() gives the blobBatchClient

      Example usage:

      let batchRequest = new BlobBatch();
      await batchRequest.deleteBlob(urlInString0, credential0);
      await batchRequest.deleteBlob(urlInString1, credential1, {
      deleteSnapshots: "include"
      });
      const batchResp = await blobBatchClient.submitBatch(batchRequest);
      console.log(batchResp.subResponsesSucceededCount);

      Example using a lease:

      let batchRequest = new BlobBatch();
      await batchRequest.setBlobAccessTier(blockBlobClient0, "Cool");
      await batchRequest.setBlobAccessTier(blockBlobClient1, "Cool", {
      conditions: { leaseId: leaseId }
      });
      const batchResp = await blobBatchClient.submitBatch(batchRequest);
      console.log(batchResp.subResponsesSucceededCount);

      Parameter batchRequest

      A set of Delete or SetTier operations.

      Parameter options

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch

    class BlobClient

    class BlobClient extends StorageClient {}
    • A BlobClient represents a URL to an Azure Storage blob; the blob may be a block blob, append blob, or page blob.

    constructor

    constructor(
    connectionString: string,
    containerName: string,
    blobName: string,
    options?: StoragePipelineOptions
    );
    • Creates an instance of BlobClient from connection string.

      Parameter connectionString

      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

      Parameter containerName

      Container name.

      Parameter blobName

      Blob name.

      Parameter options

      Optional. Options to configure the HTTP pipeline.

    constructor

    constructor(url: string, credential?: any, options?: StoragePipelineOptions);
    • Creates an instance of BlobClient. This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

      Parameter url

      A Client string pointing to Azure Storage blob service, such as "https://myaccount.blob.core.windows.net". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".

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

      Parameter options

      Optional. Options to configure the HTTP pipeline.

    constructor

    constructor(url: string, pipeline: PipelineLike);
    • Creates an instance of BlobClient. This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

      Parameter url

      A URL string pointing to Azure Storage blob, such as "https://myaccount.blob.core.windows.net/mycontainer/blob". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer/blob?sasString". This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. However, if a blob name includes ? or %, blob name must be encoded in the URL. Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".

      Parameter pipeline

      Call newPipeline() to create a default pipeline, or provide a customized pipeline.

    property containerName

    readonly containerName: string;
    • The name of the storage container the blob is associated with.

    property name

    readonly name: string;
    • The name of the blob.

    method abortCopyFromURL

    abortCopyFromURL: (
    copyId: string,
    options?: BlobAbortCopyFromURLOptions
    ) => Promise<BlobAbortCopyFromURLResponse>;
    • Aborts a pending asynchronous Copy Blob operation, and leaves a destination blob with zero length and full metadata. Version 2012-02-12 and newer.

      Parameter copyId

      Id of the Copy From URL operation.

      Parameter options

      Optional options to the Blob Abort Copy From URL operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/abort-copy-blob

    method beginCopyFromURL

    beginCopyFromURL: (
    copySource: string,
    options?: BlobBeginCopyFromURLOptions
    ) => Promise<
    PollerLike<
    PollOperationState<BlobBeginCopyFromURLResponse>,
    BlobBeginCopyFromURLResponse
    >
    >;
    • Asynchronously copies a blob to a destination within the storage account. This method returns a long running operation poller that allows you to wait indefinitely until the copy is completed. You can also cancel a copy before it is completed by calling cancelOperation on the poller. Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

      In version 2012-02-12 and later, the source for a Copy Blob operation can be a committed blob in any Azure storage account. Beginning with version 2015-02-21, the source for a Copy Blob operation can be an Azure file in any Azure storage account. Only storage accounts created on or after June 7th, 2012 allow the Copy Blob operation to copy from another storage account.

      Parameter copySource

      url to the source Azure Blob/File.

      Parameter options

      Optional options to the Blob Start Copy From URL operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob

        Example using automatic polling:

        const copyPoller = await blobClient.beginCopyFromURL('url');
        const result = await copyPoller.pollUntilDone();

        Example using manual polling:

        const copyPoller = await blobClient.beginCopyFromURL('url');
        while (!poller.isDone()) {
        await poller.poll();
        }
        const result = copyPoller.getResult();

        Example using progress updates:

        const copyPoller = await blobClient.beginCopyFromURL('url', {
        onProgress(state) {
        console.log(`Progress: ${state.copyProgress}`);
        }
        });
        const result = await copyPoller.pollUntilDone();

        Example using a changing polling interval (default 15 seconds):

        const copyPoller = await blobClient.beginCopyFromURL('url', {
        intervalInMs: 1000 // poll blob every 1 second for copy progress
        });
        const result = await copyPoller.pollUntilDone();

        Example using copy cancellation:

        const copyPoller = await blobClient.beginCopyFromURL('url');
        // cancel operation after starting it.
        try {
        await copyPoller.cancelOperation();
        // calls to get the result now throw PollerCancelledError
        await copyPoller.getResult();
        } catch (err) {
        if (err.name === 'PollerCancelledError') {
        console.log('The copy was cancelled.');
        }
        }

    method createSnapshot

    createSnapshot: (
    options?: BlobCreateSnapshotOptions
    ) => Promise<BlobCreateSnapshotResponse>;
    • Creates a read-only snapshot of a blob.

      Parameter options

      Optional options to the Blob Create Snapshot operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/snapshot-blob

    method delete

    delete: (options?: BlobDeleteOptions) => Promise<BlobDeleteResponse>;
    • Marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the Delete Blob operation.

      Parameter options

      Optional options to Blob Delete operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob

    method deleteIfExists

    deleteIfExists: (
    options?: BlobDeleteOptions
    ) => Promise<BlobDeleteIfExistsResponse>;
    • Marks the specified blob or snapshot for deletion if it exists. The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the Delete Blob operation.

      Parameter options

      Optional options to Blob Delete operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob

    method deleteImmutabilityPolicy

    deleteImmutabilityPolicy: (
    options?: BlobDeleteImmutabilityPolicyOptions
    ) => Promise<BlobDeleteImmutabilityPolicyResponse>;
    • Delete the immutablility policy on the blob.

      Parameter options

      Optional options to delete immutability policy on the blob.

    method download

    download: (
    offset?: number,
    count?: number,
    options?: BlobDownloadOptions
    ) => Promise<BlobDownloadResponseParsed>;
    • Reads or downloads a blob from the system, including its metadata and properties. You can also call Get Blob to read a snapshot.

      * In Node.js, data returns in a Readable stream readableStreamBody * In browsers, data returns in a promise blobBody

      Parameter offset

      From which position of the blob to download, greater than or equal to 0

      Parameter count

      How much data to be downloaded, greater than 0. Will download to the end when undefined

      Parameter options

      Optional options to Blob Download operation.

      Example usage (Node.js):

      // Download and convert a blob to a string
      const downloadBlockBlobResponse = await blobClient.download();
      const downloaded = await streamToBuffer(downloadBlockBlobResponse.readableStreamBody);
      console.log("Downloaded blob content:", downloaded.toString());
      async function streamToBuffer(readableStream) {
      return new Promise((resolve, reject) => {
      const chunks = [];
      readableStream.on("data", (data) => {
      chunks.push(data instanceof Buffer ? data : Buffer.from(data));
      });
      readableStream.on("end", () => {
      resolve(Buffer.concat(chunks));
      });
      readableStream.on("error", reject);
      });
      }

      Example usage (browser):

      // Download and convert a blob to a string
      const downloadBlockBlobResponse = await blobClient.download();
      const downloaded = await blobToString(await downloadBlockBlobResponse.blobBody);
      console.log(
      "Downloaded blob content",
      downloaded
      );
      async function blobToString(blob: Blob): Promise<string> {
      const fileReader = new FileReader();
      return new Promise<string>((resolve, reject) => {
      fileReader.onloadend = (ev: any) => {
      resolve(ev.target!.result);
      };
      fileReader.onerror = reject;
      fileReader.readAsText(blob);
      });
      }

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob

    method downloadToBuffer

    downloadToBuffer: {
    (
    offset?: number,
    count?: number,
    options?: BlobDownloadToBufferOptions
    ): Promise<Buffer>;
    (
    buffer: Buffer,
    offset?: number,
    count?: number,
    options?: BlobDownloadToBufferOptions
    ): Promise<Buffer>;
    };
    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Downloads an Azure Blob in parallel to a buffer. Offset and count are optional, downloads the entire blob if they are not provided.

      Warning: Buffers can only support files up to about one gigabyte on 32-bit systems or about two gigabytes on 64-bit systems due to limitations of Node.js/V8. For blobs larger than this size, consider downloadToFile.

      Parameter offset

      From which position of the block blob to download(in bytes)

      Parameter count

      How much data(in bytes) to be downloaded. Will download to the end when passing undefined

      Parameter options

      BlobDownloadToBufferOptions

    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Downloads an Azure Blob in parallel to a buffer. Offset and count are optional, downloads the entire blob if they are not provided.

      Warning: Buffers can only support files up to about one gigabyte on 32-bit systems or about two gigabytes on 64-bit systems due to limitations of Node.js/V8. For blobs larger than this size, consider downloadToFile.

      Parameter buffer

      Buffer to be fill, must have length larger than count

      Parameter offset

      From which position of the block blob to download(in bytes)

      Parameter count

      How much data(in bytes) to be downloaded. Will download to the end when passing undefined

      Parameter options

      BlobDownloadToBufferOptions

    method downloadToFile

    downloadToFile: (
    filePath: string,
    offset?: number,
    count?: number,
    options?: BlobDownloadOptions
    ) => Promise<BlobDownloadResponseParsed>;
    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Downloads an Azure Blob to a local file. Fails if the the given file path already exits. Offset and count are optional, pass 0 and undefined respectively to download the entire blob.

      Parameter filePath

      Parameter offset

      From which position of the block blob to download.

      Parameter count

      How much data to be downloaded. Will download to the end when passing undefined.

      Parameter options

      Options to Blob download options.

      Returns

      The response data for blob download operation, but with readableStreamBody set to undefined since its content is already read and written into a local file at the specified path.

    method exists

    exists: (options?: BlobExistsOptions) => Promise<boolean>;
    • Returns true if the Azure blob resource represented by this client exists; false otherwise.

      NOTE: use this function with care since an existing blob might be deleted by other clients or applications. Vice versa new blobs might be added by other clients or applications after this function completes.

      Parameter options

      options to Exists operation.

    method generateSasUrl

    generateSasUrl: (options: BlobGenerateSasUrlOptions) => Promise<string>;
    • Only available for BlobClient constructed with a shared key credential.

      Generates a Blob 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.

      Parameter options

      Optional parameters.

      Returns

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

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas

    method getAppendBlobClient

    getAppendBlobClient: () => AppendBlobClient;
    • Creates a AppendBlobClient object.

    method getBlobLeaseClient

    getBlobLeaseClient: (proposeLeaseId?: string) => BlobLeaseClient;
    • Get a BlobLeaseClient that manages leases on the blob.

      Parameter proposeLeaseId

      Initial proposed lease Id.

      Returns

      A new BlobLeaseClient object for managing leases on the blob.

    method getBlockBlobClient

    getBlockBlobClient: () => BlockBlobClient;
    • Creates a BlockBlobClient object.

    method getPageBlobClient

    getPageBlobClient: () => PageBlobClient;
    • Creates a PageBlobClient object.

    method getProperties

    getProperties: (
    options?: BlobGetPropertiesOptions
    ) => Promise<BlobGetPropertiesResponse>;
    • Returns all user-defined metadata, standard HTTP properties, and system properties for the blob. It does not return the content of the blob.

      Parameter options

      Optional options to Get Properties operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-properties

        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 methods of ContainerClient that list blobs using the includeMetadata option, which will retain their original casing.

    method getTags

    getTags: (options?: BlobGetTagsOptions) => Promise<BlobGetTagsResponse>;
    • Gets the tags associated with the underlying blob.

      Parameter options

    method setAccessTier

    setAccessTier: (
    tier: BlockBlobTier | PremiumPageBlobTier | string,
    options?: BlobSetTierOptions
    ) => Promise<BlobSetTierResponse>;
    • Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag.

      Parameter tier

      The tier to be set on the blob. Valid values are Hot, Cool, or Archive.

      Parameter options

      Optional options to the Blob Set Tier operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier

    method setHTTPHeaders

    setHTTPHeaders: (
    blobHTTPHeaders?: BlobHTTPHeaders,
    options?: BlobSetHTTPHeadersOptions
    ) => Promise<BlobSetHTTPHeadersResponse>;
    • Sets system properties on the blob.

      If no value provided, or no value provided for the specified blob HTTP headers, these blob HTTP headers without a value will be cleared.

      Parameter blobHTTPHeaders

      If no value provided, or no value provided for the specified blob HTTP headers, these blob HTTP headers without a value will be cleared. A common header to set is blobContentType enabling the browser to provide functionality based on file type.

      Parameter options

      Optional options to Blob Set HTTP Headers operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-properties

    method setImmutabilityPolicy

    setImmutabilityPolicy: (
    immutabilityPolicy: BlobImmutabilityPolicy,
    options?: BlobSetImmutabilityPolicyOptions
    ) => Promise<BlobSetImmutabilityPolicyResponse>;
    • Set immutablility policy on the blob.

      Parameter options

      Optional options to set immutability policy on the blob.

    method setLegalHold

    setLegalHold: (
    legalHoldEnabled: boolean,
    options?: BlobSetLegalHoldOptions
    ) => Promise<BlobSetLegalHoldResponse>;
    • Set legal hold on the blob.

      Parameter options

      Optional options to set legal hold on the blob.

    method setMetadata

    setMetadata: (
    metadata?: Metadata,
    options?: BlobSetMetadataOptions
    ) => Promise<BlobSetMetadataResponse>;
    • Sets user-defined metadata for the specified blob as one or more name-value pairs.

      If no option provided, or no metadata defined in the parameter, the blob metadata will be removed.

      Parameter metadata

      Replace existing metadata with this value. If no value provided the existing metadata will be removed.

      Parameter options

      Optional options to Set Metadata operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-metadata

    method setTags

    setTags: (
    tags: Tags,
    options?: BlobSetTagsOptions
    ) => Promise<BlobSetTagsResponse>;
    • Sets tags on the underlying blob. A blob can have up to 10 tags. Tag keys must be between 1 and 128 characters. Tag values must be between 0 and 256 characters. Valid tag key and value characters include lower and upper case letters, digits (0-9), space (' '), plus ('+'), minus ('-'), period ('.'), foward slash ('/'), colon (':'), equals ('='), and underscore ('_').

      Parameter tags

      Parameter options

    method syncCopyFromURL

    syncCopyFromURL: (
    copySource: string,
    options?: BlobSyncCopyFromURLOptions
    ) => Promise<BlobCopyFromURLResponse>;
    • The synchronous Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response until the copy is complete.

      Parameter copySource

      The source URL to copy from, Shared Access Signature(SAS) maybe needed for authentication

      Parameter options

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob-from-url

    method undelete

    undelete: (options?: BlobUndeleteOptions) => Promise<BlobUndeleteResponse>;
    • Restores the contents and metadata of soft deleted blob and any associated soft deleted snapshots. Undelete Blob is supported only on version 2017-07-29 or later.

      Parameter options

      Optional options to Blob Undelete operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob

    method withSnapshot

    withSnapshot: (snapshot: string) => BlobClient;
    • Creates a new BlobClient object identical to the source but with the specified snapshot timestamp. Provide "" will remove the snapshot and return a Client to the base blob.

      Parameter snapshot

      The snapshot timestamp.

      Returns

      A new BlobClient object identical to the source but with the specified snapshot timestamp

    method withVersion

    withVersion: (versionId: string) => BlobClient;
    • Creates a new BlobClient object pointing to a version of this blob. Provide "" will remove the versionId and return a Client to the base blob.

      Parameter versionId

      The versionId.

      Returns

      A new BlobClient object pointing to the version of this blob.

    class BlobLeaseClient

    class BlobLeaseClient {}

    constructor

    constructor(client: BlobClient | ContainerClient, leaseId?: string);
    • Creates an instance of BlobLeaseClient.

      Parameter client

      The client to make the lease operation requests.

      Parameter leaseId

      Initial proposed lease id.

    property leaseId

    readonly leaseId: string;
    • Gets the lease Id.

      Modifiers

      • @readonly

    property url

    readonly url: string;
    • Gets the url.

      Modifiers

      • @readonly

    method acquireLease

    acquireLease: (
    duration: number,
    options?: LeaseOperationOptions
    ) => Promise<LeaseOperationResponse>;
    • Establishes and manages a lock on a container for delete operations, or on a blob for write and delete operations. The lock duration can be 15 to 60 seconds, or can be infinite.

      Parameter duration

      Must be between 15 to 60 seconds, or infinite (-1)

      Parameter options

      option to configure lease management operations.

      Returns

      Response data for acquire lease operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container and

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

    method breakLease

    breakLease: (
    breakPeriod: number,
    options?: LeaseOperationOptions
    ) => Promise<LeaseOperationResponse>;
    • To end the lease but ensure that another client cannot acquire a new lease until the current lease period has expired.

      Parameter breakPeriod

      Break period

      Parameter options

      Optional options to configure lease management operations.

      Returns

      Response data for break lease operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container and

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

    method changeLease

    changeLease: (
    proposedLeaseId: string,
    options?: LeaseOperationOptions
    ) => Promise<LeaseOperationResponse>;
    • To change the ID of the lease.

      Parameter proposedLeaseId

      the proposed new lease Id.

      Parameter options

      option to configure lease management operations.

      Returns

      Response data for change lease operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container and

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

    method releaseLease

    releaseLease: (
    options?: LeaseOperationOptions
    ) => Promise<LeaseOperationResponse>;
    • To free the lease if it is no longer needed so that another client may immediately acquire a lease against the container or the blob.

      Parameter options

      option to configure lease management operations.

      Returns

      Response data for release lease operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container and

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

    method renewLease

    renewLease: (options?: LeaseOperationOptions) => Promise<Lease>;
    • To renew the lease.

      Parameter options

      Optional option to configure lease management operations.

      Returns

      Response data for renew lease operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container and

      • https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

    class BlobSASPermissions

    class BlobSASPermissions {}
    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      This is a helper class to construct a string representing the permissions granted by a ServiceSAS to a blob. Setting a value to true means that any SAS which uses these permissions will grant permissions for that operation. Once all the values are set, this should be serialized with toString and set as the permissions field on a BlobSASSignatureValues object. It is possible to construct the permissions string without this class, but the order of the permissions is particular and this class guarantees correctness.

    property add

    add: boolean;
    • Specifies Add access granted.

    property create

    create: boolean;
    • Specifies Create access granted.

    property delete

    delete: boolean;
    • Specifies Delete access granted.

    property deleteVersion

    deleteVersion: boolean;
    • Specifies Delete version access granted.

    property execute

    execute: boolean;
    • Specifies Execute access granted.

    property move

    move: boolean;
    • Specifies Move access granted.

    property permanentDelete

    permanentDelete: boolean;
    • Specifies that Permanent Delete is permitted.

    property read

    read: boolean;
    • Specifies Read access granted.

    property setImmutabilityPolicy

    setImmutabilityPolicy: boolean;
    • Specifies SetImmutabilityPolicy access granted.

    property tag

    tag: boolean;
    • Specfies Tag access granted.

    property write

    write: boolean;
    • Specifies Write access granted.

    method from

    static from: (permissionLike: BlobSASPermissionsLike) => BlobSASPermissions;
    • Creates a BlobSASPermissions from a raw object which contains same keys as it and boolean values for them.

      Parameter permissionLike

    method parse

    static parse: (permissions: string) => BlobSASPermissions;
    • Creates a BlobSASPermissions from the specified permissions string. This method will throw an Error if it encounters a character that does not correspond to a valid permission.

      Parameter permissions

    method toString

    toString: () => string;
    • Converts the given permissions to a string. Using this method will guarantee the permissions are in an order accepted by the service.

      Returns

      A string which represents the BlobSASPermissions

    class BlobServiceClient

    class BlobServiceClient extends StorageClient {}
    • A BlobServiceClient represents a Client to the Azure Storage Blob service allowing you to manipulate blob containers.

    constructor

    constructor(url: string, credential?: any, options?: StoragePipelineOptions);
    • Creates an instance of BlobServiceClient.

      Parameter url

      A Client string pointing to Azure Storage blob service, such as "https://myaccount.blob.core.windows.net". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".

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

      Parameter options

      Optional. Options to configure the HTTP pipeline.

      Example using DefaultAzureCredential from @azure/identity:

      const account = "<storage account name>";
      const defaultAzureCredential = new DefaultAzureCredential();
      const blobServiceClient = new BlobServiceClient(
      `https://${account}.blob.core.windows.net`,
      defaultAzureCredential
      );

      Example using an account name/key:

      const account = "<storage account name>"
      const sharedKeyCredential = new StorageSharedKeyCredential(account, "<account key>");
      const blobServiceClient = new BlobServiceClient(
      `https://${account}.blob.core.windows.net`,
      sharedKeyCredential
      );

    constructor

    constructor(url: string, pipeline: PipelineLike);
    • Creates an instance of BlobServiceClient.

      Parameter url

      A Client string pointing to Azure Storage blob service, such as "https://myaccount.blob.core.windows.net". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".

      Parameter pipeline

      Call newPipeline() to create a default pipeline, or provide a customized pipeline.

    method createContainer

    createContainer: (
    containerName: string,
    options?: ContainerCreateOptions
    ) => Promise<{
    containerClient: ContainerClient;
    containerCreateResponse: ContainerCreateResponse;
    }>;
    • Create a Blob container.

      Parameter containerName

      Name of the container to create.

      Parameter options

      Options to configure Container Create operation.

      Returns

      Container creation response and the corresponding container client.

    method deleteContainer

    deleteContainer: (
    containerName: string,
    options?: ContainerDeleteMethodOptions
    ) => Promise<ContainerDeleteResponse>;
    • Deletes a Blob container.

      Parameter containerName

      Name of the container to delete.

      Parameter options

      Options to configure Container Delete operation.

      Returns

      Container deletion response.

    method findBlobsByTags

    findBlobsByTags: (
    tagFilterSqlExpression: string,
    options?: ServiceFindBlobByTagsOptions
    ) => PagedAsyncIterableIterator<
    FilterBlobItem,
    ServiceFindBlobsByTagsSegmentResponse
    >;
    • Returns an async iterable iterator to find all blobs with specified tag under the specified account.

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

      Parameter tagFilterSqlExpression

      The where parameter enables the caller to query blobs whose tags match a given expression. The given expression must evaluate to true for a blob to be returned in the results. The[OData - ABNF] filter syntax rule defines the formal grammar for the value of the where query parameter; however, only a subset of the OData filter syntax is supported in the Blob service.

      Parameter options

      Options to find blobs by tags.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties

        Example using for await syntax:

        let i = 1;
        for await (const blob of blobServiceClient.findBlobsByTags("tagkey='tagvalue'")) {
        console.log(`Blob ${i++}: ${container.name}`);
        }

        Example using iter.next():

        let i = 1;
        const iter = blobServiceClient.findBlobsByTags("tagkey='tagvalue'");
        let blobItem = await iter.next();
        while (!blobItem.done) {
        console.log(`Blob ${i++}: ${blobItem.value.name}`);
        blobItem = await iter.next();
        }

        Example using byPage():

        // passing optional maxPageSize in the page settings
        let i = 1;
        for await (const response of blobServiceClient.findBlobsByTags("tagkey='tagvalue'").byPage({ maxPageSize: 20 })) {
        if (response.blobs) {
        for (const blob of response.blobs) {
        console.log(`Blob ${i++}: ${blob.name}`);
        }
        }
        }

        Example using paging with a marker:

        let i = 1;
        let iterator = blobServiceClient.findBlobsByTags("tagkey='tagvalue'").byPage({ maxPageSize: 2 });
        let response = (await iterator.next()).value;
        // Prints 2 blob names
        if (response.blobs) {
        for (const blob of response.blobs) {
        console.log(`Blob ${i++}: ${blob.name}`);
        }
        }
        // Gets next marker
        let marker = response.continuationToken;
        // Passing next marker as continuationToken
        iterator = blobServiceClient
        .findBlobsByTags("tagkey='tagvalue'")
        .byPage({ continuationToken: marker, maxPageSize: 10 });
        response = (await iterator.next()).value;
        // Prints blob names
        if (response.blobs) {
        for (const blob of response.blobs) {
        console.log(`Blob ${i++}: ${blob.name}`);
        }
        }

    method fromConnectionString

    static fromConnectionString: (
    connectionString: string,
    options?: StoragePipelineOptions
    ) => BlobServiceClient;
    • Creates an instance of BlobServiceClient from connection string.

      Parameter connectionString

      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

      Parameter options

      Optional. Options to configure the HTTP pipeline.

    method generateAccountSasUrl

    generateAccountSasUrl: (
    expiresOn?: Date,
    permissions?: AccountSASPermissions,
    resourceTypes?: string,
    options?: ServiceGenerateAccountSasUrlOptions
    ) => string;
    • Only available for BlobServiceClient constructed with a shared key credential.

      Generates a Blob 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.

      Parameter expiresOn

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

      Parameter permissions

      Specifies the list of permissions to be associated with the SAS.

      Parameter resourceTypes

      Specifies the resource types associated with the shared access signature.

      Parameter options

      Optional parameters.

      Returns

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

      See Also

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

    method getAccountInfo

    getAccountInfo: (
    options?: ServiceGetAccountInfoOptions
    ) => Promise<ServiceGetAccountInfoResponse>;
    • The Get Account Information operation returns the sku name and account kind for the specified account. The Get Account Information operation is available on service versions beginning with version 2018-03-28.

      Parameter options

      Options to the Service Get Account Info operation.

      Returns

      Response data for the Service Get Account Info operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/get-account-information

    method getBlobBatchClient

    getBlobBatchClient: () => BlobBatchClient;
    • Creates a BlobBatchClient object to conduct batch operations.

      Returns

      A new BlobBatchClient object for this service.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch

    method getContainerClient

    getContainerClient: (containerName: string) => ContainerClient;
    • Creates a ContainerClient object

      Parameter containerName

      A container name

      Returns

      A new ContainerClient object for the given container name.

      Example usage:

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

    method getProperties

    getProperties: (
    options?: ServiceGetPropertiesOptions
    ) => Promise<ServiceGetPropertiesResponse>;
    • Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules.

      Parameter options

      Options to the Service Get Properties operation.

      Returns

      Response data for the Service Get Properties operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties

    method getStatistics

    getStatistics: (
    options?: ServiceGetStatisticsOptions
    ) => Promise<ServiceGetStatisticsResponse>;
    • Retrieves statistics related to replication for the Blob service. It is only available on the secondary location endpoint when read-access geo-redundant replication is enabled for the storage account.

      Parameter options

      Options to the Service Get Statistics operation.

      Returns

      Response data for the Service Get Statistics operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-service-stats

    method getUserDelegationKey

    getUserDelegationKey: (
    startsOn: Date,
    expiresOn: Date,
    options?: ServiceGetUserDelegationKeyOptions
    ) => Promise<ServiceGetUserDelegationKeyResponse>;
    • ONLY AVAILABLE WHEN USING BEARER TOKEN AUTHENTICATION (TokenCredential).

      Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token authentication.

      Parameter startsOn

      The start time for the user delegation SAS. Must be within 7 days of the current time

      Parameter expiresOn

      The end time for the user delegation SAS. Must be within 7 days of the current time

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/get-user-delegation-key

    method listContainers

    listContainers: (
    options?: ServiceListContainersOptions
    ) => PagedAsyncIterableIterator<
    ContainerItem,
    ServiceListContainersSegmentResponse
    >;
    • 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}`);
      }
      }

      Parameter options

      Options to list containers.

      Returns

      An asyncIterableIterator that supports paging.

    method setProperties

    setProperties: (
    properties: BlobServiceProperties,
    options?: ServiceSetPropertiesOptions
    ) => Promise<ServiceSetPropertiesResponse>;
    • Sets properties for a storage account’s Blob service endpoint, including properties for Storage Analytics, CORS (Cross-Origin Resource Sharing) rules and soft delete settings.

      Parameter properties

      Parameter options

      Options to the Service Set Properties operation.

      Returns

      Response data for the Service Set Properties operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-service-properties

    method undeleteContainer

    undeleteContainer: (
    deletedContainerName: string,
    deletedContainerVersion: string,
    options?: ServiceUndeleteContainerOptions
    ) => Promise<{
    containerClient: ContainerClient;
    containerUndeleteResponse: ContainerUndeleteResponse;
    }>;
    • Restore a previously deleted Blob container. This API is only functional if Container Soft Delete is enabled for the storage account associated with the container.

      Parameter deletedContainerName

      Name of the previously deleted container.

      Parameter deletedContainerVersion

      Version of the previously deleted container, used to uniquely identify the deleted container.

      Parameter options

      Options to configure Container Restore operation.

      Returns

      Container deletion response.

    class BlockBlobClient

    class BlockBlobClient extends BlobClient {}
    • BlockBlobClient defines a set of operations applicable to block blobs.

    constructor

    constructor(
    connectionString: string,
    containerName: string,
    blobName: string,
    options?: StoragePipelineOptions
    );
    • Creates an instance of BlockBlobClient.

      Parameter connectionString

      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

      Parameter containerName

      Container name.

      Parameter blobName

      Blob name.

      Parameter options

      Optional. Options to configure the HTTP pipeline.

    constructor

    constructor(url: string, credential?: any, options?: StoragePipelineOptions);
    • Creates an instance of BlockBlobClient. This method accepts an encoded URL or non-encoded URL pointing to a block blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

      Parameter url

      A URL string pointing to Azure Storage block blob, such as "https://myaccount.blob.core.windows.net/mycontainer/blockblob". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer/blockblob?sasString". This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. However, if a blob name includes ? or %, blob name must be encoded in the URL. Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".

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

      Parameter options

      Optional. Options to configure the HTTP pipeline.

    constructor

    constructor(url: string, pipeline: PipelineLike);
    • Creates an instance of BlockBlobClient. This method accepts an encoded URL or non-encoded URL pointing to a block blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

      Parameter url

      A URL string pointing to Azure Storage block blob, such as "https://myaccount.blob.core.windows.net/mycontainer/blockblob". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer/blockblob?sasString". This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. However, if a blob name includes ? or %, blob name must be encoded in the URL. Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".

      Parameter pipeline

      Call newPipeline() to create a default pipeline, or provide a customized pipeline.

    method commitBlockList

    commitBlockList: (
    blocks: string[],
    options?: BlockBlobCommitBlockListOptions
    ) => Promise<BlockBlobCommitBlockListResponse>;
    • Writes a blob by specifying the list of block IDs that make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and existing blocks together. Any blocks not specified in the block list and permanently deleted.

      Parameter blocks

      Array of 64-byte value that is base64-encoded

      Parameter options

      Options to the Block Blob Commit Block List operation.

      Returns

      Response data for the Block Blob Commit Block List operation.

      See Also

      • https://docs.microsoft.com/rest/api/storageservices/put-block-list

    method getBlockList

    getBlockList: (
    listType: BlockListType,
    options?: BlockBlobGetBlockListOptions
    ) => Promise<BlockBlobGetBlockListResponse>;
    • Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter.

      Parameter listType

      Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both lists together.

      Parameter options

      Options to the Block Blob Get Block List operation.

      Returns

      Response data for the Block Blob Get Block List operation.

      See Also

      • https://docs.microsoft.com/rest/api/storageservices/get-block-list

    method query

    query: (
    query: string,
    options?: BlockBlobQueryOptions
    ) => Promise<BlobDownloadResponseModel>;
    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Quick query for a JSON or CSV formatted blob.

      Example usage (Node.js):

      // Query and convert a blob to a string
      const queryBlockBlobResponse = await blockBlobClient.query("select * from BlobStorage");
      const downloaded = (await streamToBuffer(queryBlockBlobResponse.readableStreamBody)).toString();
      console.log("Query blob content:", downloaded);
      async function streamToBuffer(readableStream) {
      return new Promise((resolve, reject) => {
      const chunks = [];
      readableStream.on("data", (data) => {
      chunks.push(data instanceof Buffer ? data : Buffer.from(data));
      });
      readableStream.on("end", () => {
      resolve(Buffer.concat(chunks));
      });
      readableStream.on("error", reject);
      });
      }

      Parameter query

      Parameter options

    method stageBlock

    stageBlock: (
    blockId: string,
    body: HttpRequestBody,
    contentLength: number,
    options?: BlockBlobStageBlockOptions
    ) => Promise<BlockBlobStageBlockResponse>;
    • Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList.

      Parameter blockId

      A 64-byte value that is base64-encoded

      Parameter body

      Data to upload to the staging area.

      Parameter contentLength

      Number of bytes to upload.

      Parameter options

      Options to the Block Blob Stage Block operation.

      Returns

      Response data for the Block Blob Stage Block operation.

      See Also

      • https://docs.microsoft.com/rest/api/storageservices/put-block

    method stageBlockFromURL

    stageBlockFromURL: (
    blockId: string,
    sourceURL: string,
    offset?: number,
    count?: number,
    options?: BlockBlobStageBlockFromURLOptions
    ) => Promise<BlockBlobStageBlockFromURLResponse>;
    • The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are read from a URL. This API is available starting in version 2018-03-28.

      Parameter blockId

      A 64-byte value that is base64-encoded

      Parameter sourceURL

      Specifies the URL of the blob. The value may be a URL of up to 2 KB in length that specifies a blob. The value should be URL-encoded as it would appear in a request URI. The source blob must either be public or must be authenticated via a shared access signature. If the source blob is public, no authentication is required to perform the operation. Here are some examples of source object URLs: - https://myaccount.blob.core.windows.net/mycontainer/myblob - https://myaccount.blob.core.windows.net/mycontainer/myblob?snapshot=

      Parameter offset

      From which position of the blob to download, greater than or equal to 0

      Parameter count

      How much data to be downloaded, greater than 0. Will download to the end when undefined

      Parameter options

      Options to the Block Blob Stage Block From URL operation.

      Returns

      Response data for the Block Blob Stage Block From URL operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/put-block-from-url

    method syncUploadFromURL

    syncUploadFromURL: (
    sourceURL: string,
    options?: BlockBlobSyncUploadFromURLOptions
    ) => Promise<BlockBlobPutBlobFromUrlResponse>;
    • Creates a new Block Blob where the contents of the blob are read from a given URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial updates to a block blob’s contents using a source URL, use stageBlockFromURL and commitBlockList.

      Parameter sourceURL

      Specifies the URL of the blob. The value may be a URL of up to 2 KB in length that specifies a blob. The value should be URL-encoded as it would appear in a request URI. The source blob must either be public or must be authenticated via a shared access signature. If the source blob is public, no authentication is required to perform the operation. Here are some examples of source object URLs: - https://myaccount.blob.core.windows.net/mycontainer/myblob - https://myaccount.blob.core.windows.net/mycontainer/myblob?snapshot=

      Parameter options

      Optional parameters.

    method upload

    upload: (
    body: HttpRequestBody,
    contentLength: number,
    options?: BlockBlobUploadOptions
    ) => Promise<BlockBlobUploadResponse>;
    • Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use stageBlock and commitBlockList.

      This is a non-parallel uploading method, please use uploadFile, uploadStream or uploadBrowserData for better performance with concurrency uploading.

      Parameter body

      Blob, string, ArrayBuffer, ArrayBufferView or a function which returns a new Readable stream whose offset is from data source beginning.

      Parameter contentLength

      Length of body in bytes. Use Buffer.byteLength() to calculate body length for a string including non non-Base64/Hex-encoded characters.

      Parameter options

      Options to the Block Blob Upload operation.

      Returns

      Response data for the Block Blob Upload operation.

      Example usage:

      const content = "Hello world!";
      const uploadBlobResponse = await blockBlobClient.upload(content, content.length);

      See Also

      • https://docs.microsoft.com/rest/api/storageservices/put-blob

    method uploadBrowserData

    uploadBrowserData: (
    browserData: Blob | ArrayBuffer | ArrayBufferView,
    options?: BlockBlobParallelUploadOptions
    ) => Promise<BlobUploadCommonResponse>;
    • ONLY AVAILABLE IN BROWSERS.

      Uploads a browser Blob/File/ArrayBuffer/ArrayBufferView object to block blob.

      When buffer length lesser than or equal to 256MB, this method will use 1 upload call to finish the upload. Otherwise, this method will call stageBlock to upload blocks, and finally call commitBlockList to commit the block list.

      A common BlockBlobParallelUploadOptions.blobHTTPHeaders option to set is blobContentType, enabling the browser to provide functionality based on file type.

      Parameter browserData

      Blob, File, ArrayBuffer or ArrayBufferView

      Parameter options

      Options to upload browser data.

      Returns

      Response data for the Blob Upload operation.

      Deprecated

      Use uploadData instead.

    method uploadData

    uploadData: (
    data: Buffer | Blob | ArrayBuffer | ArrayBufferView,
    options?: BlockBlobParallelUploadOptions
    ) => Promise<BlobUploadCommonResponse>;

    method uploadFile

    uploadFile: (
    filePath: string,
    options?: BlockBlobParallelUploadOptions
    ) => Promise<BlobUploadCommonResponse>;
    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Uploads a local file in blocks to a block blob.

      When file size lesser than or equal to 256MB, this method will use 1 upload call to finish the upload. Otherwise, this method will call stageBlock to upload blocks, and finally call commitBlockList to commit the block list.

      Parameter filePath

      Full path of local file

      Parameter options

      Options to Upload to Block Blob operation.

      Returns

      Response data for the Blob Upload operation.

    method uploadStream

    uploadStream: (
    stream: Readable,
    bufferSize?: number,
    maxConcurrency?: number,
    options?: BlockBlobUploadStreamOptions
    ) => Promise<BlobUploadCommonResponse>;
    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Uploads a Node.js Readable stream into block blob.

      PERFORMANCE IMPROVEMENT TIPS: * Input stream highWaterMark is better to set a same value with bufferSize parameter, which will avoid Buffer.concat() operations.

      Parameter stream

      Node.js Readable stream

      Parameter bufferSize

      Size of every buffer allocated, also the block size in the uploaded block blob. Default value is 8MB

      Parameter maxConcurrency

      Max concurrency indicates the max number of buffers that can be allocated, positive correlation with max uploading concurrency. Default value is 5

      Parameter options

      Options to Upload Stream to Block Blob operation.

      Returns

      Response data for the Blob Upload operation.

    method withSnapshot

    withSnapshot: (snapshot: string) => BlockBlobClient;
    • Creates a new BlockBlobClient object identical to the source but with the specified snapshot timestamp. Provide "" will remove the snapshot and return a URL to the base blob.

      Parameter snapshot

      The snapshot timestamp.

      Returns

      A new BlockBlobClient object identical to the source but with the specified snapshot timestamp.

    class ContainerClient

    class ContainerClient extends StorageClient {}
    • A ContainerClient represents a URL to the Azure Storage container allowing you to manipulate its blobs.

    constructor

    constructor(
    connectionString: string,
    containerName: string,
    options?: StoragePipelineOptions
    );
    • Creates an instance of ContainerClient.

      Parameter connectionString

      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

      Parameter containerName

      Container name.

      Parameter options

      Optional. Options to configure the HTTP pipeline.

    constructor

    constructor(url: string, credential?: any, options?: StoragePipelineOptions);
    • Creates an instance of ContainerClient. This method accepts an URL pointing to a container. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

      Parameter url

      A URL string pointing to Azure Storage container, such as "https://myaccount.blob.core.windows.net/mycontainer". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer?sasString".

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

      Parameter options

      Optional. Options to configure the HTTP pipeline.

    constructor

    constructor(url: string, pipeline: PipelineLike);
    • Creates an instance of ContainerClient. This method accepts an URL pointing to a container. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

      Parameter url

      A URL string pointing to Azure Storage container, such as "https://myaccount.blob.core.windows.net/mycontainer". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer?sasString".

      Parameter pipeline

      Call newPipeline() to create a default pipeline, or provide a customized pipeline.

    property containerName

    readonly containerName: string;
    • The name of the container.

    method create

    create: (options?: ContainerCreateOptions) => Promise<ContainerCreateResponse>;
    • Creates a new container under the specified account. If the container with the same name already exists, the operation fails.

      Parameter options

      Options to Container Create operation.

      Example usage:

      const containerClient = blobServiceClient.getContainerClient("<container name>");
      const createContainerResponse = await containerClient.create();
      console.log("Container was created successfully", createContainerResponse.requestId);

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/create-container

    method createIfNotExists

    createIfNotExists: (
    options?: ContainerCreateOptions
    ) => Promise<ContainerCreateIfNotExistsResponse>;
    • Creates a new container under the specified account. If the container with the same name already exists, it is not changed.

      Parameter options

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/create-container

    method delete

    delete: (
    options?: ContainerDeleteMethodOptions
    ) => Promise<ContainerDeleteResponse>;
    • Marks the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection.

      Parameter options

      Options to Container Delete operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/delete-container

    method deleteBlob

    deleteBlob: (
    blobName: string,
    options?: ContainerDeleteBlobOptions
    ) => Promise<BlobDeleteResponse>;
    • Marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the Delete Blob operation.

      Parameter blobName

      Parameter options

      Options to Blob Delete operation.

      Returns

      Block blob deletion response data.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob

    method deleteIfExists

    deleteIfExists: (
    options?: ContainerDeleteMethodOptions
    ) => Promise<ContainerDeleteIfExistsResponse>;
    • Marks the specified container for deletion if it exists. The container and any blobs contained within it are later deleted during garbage collection.

      Parameter options

      Options to Container Delete operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/delete-container

    method exists

    exists: (options?: ContainerExistsOptions) => Promise<boolean>;
    • Returns true if the Azure container resource represented by this client exists; false otherwise.

      NOTE: use this function with care since an existing container might be deleted by other clients or applications. Vice versa new containers with the same name might be added by other clients or applications after this function completes.

      Parameter options

    method findBlobsByTags

    findBlobsByTags: (
    tagFilterSqlExpression: string,
    options?: ContainerFindBlobByTagsOptions
    ) => PagedAsyncIterableIterator<
    FilterBlobItem,
    ContainerFindBlobsByTagsSegmentResponse
    >;
    • Returns an async iterable iterator to find all blobs with specified tag under the specified container.

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

      Example using for await syntax:

      let i = 1;
      for await (const blob of containerClient.findBlobsByTags("tagkey='tagvalue'")) {
      console.log(`Blob ${i++}: ${blob.name}`);
      }

      Example using iter.next():

      let i = 1;
      const iter = containerClient.findBlobsByTags("tagkey='tagvalue'");
      let blobItem = await iter.next();
      while (!blobItem.done) {
      console.log(`Blob ${i++}: ${blobItem.value.name}`);
      blobItem = await iter.next();
      }

      Example using byPage():

      // passing optional maxPageSize in the page settings
      let i = 1;
      for await (const response of containerClient.findBlobsByTags("tagkey='tagvalue'").byPage({ maxPageSize: 20 })) {
      if (response.blobs) {
      for (const blob of response.blobs) {
      console.log(`Blob ${i++}: ${blob.name}`);
      }
      }
      }

      Example using paging with a marker:

      let i = 1;
      let iterator = containerClient.findBlobsByTags("tagkey='tagvalue'").byPage({ maxPageSize: 2 });
      let response = (await iterator.next()).value;
      // Prints 2 blob names
      if (response.blobs) {
      for (const blob of response.blobs) {
      console.log(`Blob ${i++}: ${blob.name}`);
      }
      }
      // Gets next marker
      let marker = response.continuationToken;
      // Passing next marker as continuationToken
      iterator = containerClient
      .findBlobsByTags("tagkey='tagvalue'")
      .byPage({ continuationToken: marker, maxPageSize: 10 });
      response = (await iterator.next()).value;
      // Prints blob names
      if (response.blobs) {
      for (const blob of response.blobs) {
      console.log(`Blob ${i++}: ${blob.name}`);
      }
      }

      Parameter tagFilterSqlExpression

      The where parameter enables the caller to query blobs whose tags match a given expression. The given expression must evaluate to true for a blob to be returned in the results. The[OData - ABNF] filter syntax rule defines the formal grammar for the value of the where query parameter; however, only a subset of the OData filter syntax is supported in the Blob service.

      Parameter options

      Options to find blobs by tags.

    method generateSasUrl

    generateSasUrl: (options: ContainerGenerateSasUrlOptions) => Promise<string>;
    • Only available for ContainerClient constructed with a shared key credential.

      Generates a Blob Container 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.

      Parameter options

      Optional parameters.

      Returns

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

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas

    method getAccessPolicy

    getAccessPolicy: (
    options?: ContainerGetAccessPolicyOptions
    ) => Promise<ContainerGetAccessPolicyResponse>;
    • Gets the permissions for the specified container. The permissions indicate whether container data may be accessed publicly.

      WARNING: JavaScript Date will potentially lose precision when parsing startsOn and expiresOn strings. For example, new Date("2018-12-31T03:44:23.8827891Z").toISOString() will get "2018-12-31T03:44:23.882Z".

      Parameter options

      Options to Container Get Access Policy operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/get-container-acl

    method getAppendBlobClient

    getAppendBlobClient: (blobName: string) => AppendBlobClient;

    method getBlobBatchClient

    getBlobBatchClient: () => BlobBatchClient;
    • Creates a BlobBatchClient object to conduct batch operations.

      Returns

      A new BlobBatchClient object for this container.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch

    method getBlobClient

    getBlobClient: (blobName: string) => BlobClient;
    • Creates a BlobClient

      Parameter blobName

      A blob name

      Returns

      A new BlobClient object for the given blob name.

    method getBlobLeaseClient

    getBlobLeaseClient: (proposeLeaseId?: string) => BlobLeaseClient;
    • Get a BlobLeaseClient that manages leases on the container.

      Parameter proposeLeaseId

      Initial proposed lease Id.

      Returns

      A new BlobLeaseClient object for managing leases on the container.

    method getBlockBlobClient

    getBlockBlobClient: (blobName: string) => BlockBlobClient;
    • Creates a BlockBlobClient

      Parameter blobName

      A block blob name

      Example usage:

      const content = "Hello world!";
      const blockBlobClient = containerClient.getBlockBlobClient("<blob name>");
      const uploadBlobResponse = await blockBlobClient.upload(content, content.length);

    method getPageBlobClient

    getPageBlobClient: (blobName: string) => PageBlobClient;

    method getProperties

    getProperties: (
    options?: ContainerGetPropertiesOptions
    ) => Promise<ContainerGetPropertiesResponse>;
    • Returns all user-defined metadata and system properties for the specified container. The data returned does not include the container's list of blobs.

      Parameter options

      Options to Container Get Properties operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/get-container-properties

        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 listContainers method of BlobServiceClient using the includeMetadata option, which will retain their original casing.

    method listBlobsByHierarchy

    listBlobsByHierarchy: (
    delimiter: string,
    options?: ContainerListBlobsOptions
    ) => PagedAsyncIterableIterator<
    ({ kind: 'prefix' } & BlobPrefix) | ({ kind: 'blob' } & BlobItem),
    ContainerListBlobHierarchySegmentResponse
    >;
    • Returns an async iterable iterator to list all the blobs by hierarchy. under the specified account.

      .byPage() returns an async iterable iterator to list the blobs by hierarchy in pages.

      Example using for await syntax:

      for await (const item of containerClient.listBlobsByHierarchy("/")) {
      if (item.kind === "prefix") {
      console.log(`\tBlobPrefix: ${item.name}`);
      } else {
      console.log(`\tBlobItem: name - ${item.name}`);
      }
      }

      Example using iter.next():

      let iter = containerClient.listBlobsByHierarchy("/", { prefix: "prefix1/" });
      let entity = await iter.next();
      while (!entity.done) {
      let item = entity.value;
      if (item.kind === "prefix") {
      console.log(`\tBlobPrefix: ${item.name}`);
      } else {
      console.log(`\tBlobItem: name - ${item.name}`);
      }
      entity = await iter.next();
      }

      Example using byPage():

      console.log("Listing blobs by hierarchy by page");
      for await (const response of containerClient.listBlobsByHierarchy("/").byPage()) {
      const segment = response.segment;
      if (segment.blobPrefixes) {
      for (const prefix of segment.blobPrefixes) {
      console.log(`\tBlobPrefix: ${prefix.name}`);
      }
      }
      for (const blob of response.segment.blobItems) {
      console.log(`\tBlobItem: name - ${blob.name}`);
      }
      }

      Example using paging with a max page size:

      console.log("Listing blobs by hierarchy by page, specifying a prefix and a max page size");
      let i = 1;
      for await (const response of containerClient
      .listBlobsByHierarchy("/", { prefix: "prefix2/sub1/" })
      .byPage({ maxPageSize: 2 })) {
      console.log(`Page ${i++}`);
      const segment = response.segment;
      if (segment.blobPrefixes) {
      for (const prefix of segment.blobPrefixes) {
      console.log(`\tBlobPrefix: ${prefix.name}`);
      }
      }
      for (const blob of response.segment.blobItems) {
      console.log(`\tBlobItem: name - ${blob.name}`);
      }
      }

      Parameter delimiter

      The character or string used to define the virtual hierarchy

      Parameter options

      Options to list blobs operation.

    method listBlobsFlat

    listBlobsFlat: (
    options?: ContainerListBlobsOptions
    ) => PagedAsyncIterableIterator<BlobItem, ContainerListBlobFlatSegmentResponse>;
    • Returns an async iterable iterator to list all the blobs under the specified account.

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

      Example using for await syntax:

      // Get the containerClient before you run these snippets,
      // Can be obtained from `blobServiceClient.getContainerClient("<your-container-name>");`
      let i = 1;
      for await (const blob of containerClient.listBlobsFlat()) {
      console.log(`Blob ${i++}: ${blob.name}`);
      }

      Example using iter.next():

      let i = 1;
      let iter = containerClient.listBlobsFlat();
      let blobItem = await iter.next();
      while (!blobItem.done) {
      console.log(`Blob ${i++}: ${blobItem.value.name}`);
      blobItem = await iter.next();
      }

      Example using byPage():

      // passing optional maxPageSize in the page settings
      let i = 1;
      for await (const response of containerClient.listBlobsFlat().byPage({ maxPageSize: 20 })) {
      for (const blob of response.segment.blobItems) {
      console.log(`Blob ${i++}: ${blob.name}`);
      }
      }

      Example using paging with a marker:

      let i = 1;
      let iterator = containerClient.listBlobsFlat().byPage({ maxPageSize: 2 });
      let response = (await iterator.next()).value;
      // Prints 2 blob names
      for (const blob of response.segment.blobItems) {
      console.log(`Blob ${i++}: ${blob.name}`);
      }
      // Gets next marker
      let marker = response.continuationToken;
      // Passing next marker as continuationToken
      iterator = containerClient.listBlobsFlat().byPage({ continuationToken: marker, maxPageSize: 10 });
      response = (await iterator.next()).value;
      // Prints 10 blob names
      for (const blob of response.segment.blobItems) {
      console.log(`Blob ${i++}: ${blob.name}`);
      }

      Parameter options

      Options to list blobs.

      Returns

      An asyncIterableIterator that supports paging.

    method setAccessPolicy

    setAccessPolicy: (
    access?: PublicAccessType,
    containerAcl?: SignedIdentifier[],
    options?: ContainerSetAccessPolicyOptions
    ) => Promise<ContainerSetAccessPolicyResponse>;
    • Sets the permissions for the specified container. The permissions indicate whether blobs in a container may be accessed publicly.

      When you set permissions for a container, the existing permissions are replaced. If no access or containerAcl provided, the existing container ACL will be removed.

      When you establish a stored access policy on a container, it may take up to 30 seconds to take effect. During this interval, a shared access signature that is associated with the stored access policy will fail with status code 403 (Forbidden), until the access policy becomes active.

      Parameter access

      The level of public access to data in the container.

      Parameter containerAcl

      Array of elements each having a unique Id and details of the access policy.

      Parameter options

      Options to Container Set Access Policy operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/set-container-acl

    method setMetadata

    setMetadata: (
    metadata?: Metadata,
    options?: ContainerSetMetadataOptions
    ) => Promise<ContainerSetMetadataResponse>;
    • Sets one or more user-defined name-value pairs for the specified container.

      If no option provided, or no metadata defined in the parameter, the container metadata will be removed.

      Parameter metadata

      Replace existing metadata with this value. If no value provided the existing metadata will be removed.

      Parameter options

      Options to Container Set Metadata operation.

      See Also

      • https://docs.microsoft.com/en-us/rest/api/storageservices/set-container-metadata

    method uploadBlockBlob

    uploadBlockBlob: (
    blobName: string,
    body: HttpRequestBody,
    contentLength: number,
    options?: BlockBlobUploadOptions
    ) => Promise<{
    blockBlobClient: BlockBlobClient;
    response: BlockBlobUploadResponse;
    }>;
    • Creates a new block blob, or updates the content of an existing block blob.

      Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use BlockBlobClient.stageBlock and BlockBlobClient.commitBlockList.

      This is a non-parallel uploading method, please use BlockBlobClient.uploadFile, BlockBlobClient.uploadStream or BlockBlobClient.uploadBrowserData for better performance with concurrency uploading.

      Parameter blobName

      Name of the block blob to create or update.

      Parameter body

      Blob, string, ArrayBuffer, ArrayBufferView or a function which returns a new Readable stream whose offset is from data source beginning.

      Parameter contentLength

      Length of body in bytes. Use Buffer.byteLength() to calculate body length for a string including non non-Base64/Hex-encoded characters.

      Parameter options

      Options to configure the Block Blob Upload operation.

      Returns

      Block Blob upload response data and the corresponding BlockBlobClient instance.

      See Also

      • https://docs.microsoft.com/rest/api/storageservices/put-blob

    class ContainerSASPermissions

    class ContainerSASPermissions {}
    </