BlockBlobClient class

BlockBlobClient defines a set of operations applicable to block blobs.

Extends

Constructors

BlockBlobClient(string, Pipeline)

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.

BlockBlobClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, 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.

BlockBlobClient(string, string, string, StoragePipelineOptions)

Creates an instance of BlockBlobClient.

Properties

accountName
containerName

The name of the storage container the blob is associated with.

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.

name

The name of the blob.

url

Encoded URL string value.

Methods

abortCopyFromURL(string, BlobAbortCopyFromURLOptions)

Aborts a pending asynchronous Copy Blob operation, and leaves a destination blob with zero length and full metadata. Version 2012-02-12 and newer.

beginCopyFromURL(string, BlobBeginCopyFromURLOptions)

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.

commitBlockList(string[], BlockBlobCommitBlockListOptions)

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 <xref:stageBlock> operation. You can call <xref: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.

createSnapshot(BlobCreateSnapshotOptions)

Creates a read-only snapshot of a blob.

delete(BlobDeleteOptions)

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.

deleteIfExists(BlobDeleteOptions)

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.

download(number, number, BlobDownloadOptions)

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
downloadToBuffer(Buffer, number, number, 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 <xref:downloadToFile>.

downloadToBuffer(number, number, 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 <xref:downloadToFile>.

downloadToFile(string, number, number, BlobDownloadOptions)

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.

exists(BlobExistsOptions)

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.

getAppendBlobClient()

Creates a AppendBlobClient object.

getBlobLeaseClient(string)

Get a <xref:BlobLeaseClient> that manages leases on the blob.

getBlockBlobClient()

Creates a BlockBlobClient object.

getBlockList(BlockListType, BlockBlobGetBlockListOptions)

Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter.

getPageBlobClient()

Creates a PageBlobClient object.

getProperties(BlobGetPropertiesOptions)

Returns all user-defined metadata, standard HTTP properties, and system properties for the blob. It does not return the content of the blob.

getTags(BlobGetTagsOptions)

Gets the tags associated with the underlying blob.

query(string, BlockBlobQueryOptions)

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 streamToString(queryBlockBlobResponse.readableStreamBody);
console.log("Query blob content:", downloaded);

async function streamToString(readableStream) { return new Promise((resolve, reject) => { const chunks = []; readableStream.on("data", (data) => { chunks.push(data.toString()); }); readableStream.on("end", () => { resolve(chunks.join("")); }); readableStream.on("error", reject); }); }

setAccessTier(BlockBlobTier | PremiumPageBlobTier | string, BlobSetTierOptions)

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.

setHTTPHeaders(BlobHTTPHeaders, BlobSetHTTPHeadersOptions)

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.

setMetadata(Metadata, BlobSetMetadataOptions)

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.

setTags(Tags, BlobSetTagsOptions)

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 ('_').

stageBlock(string, HttpRequestBody, number, BlockBlobStageBlockOptions)

Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList.

stageBlockFromURL(string, string, number, number, BlockBlobStageBlockFromURLOptions)

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.

syncCopyFromURL(string, BlobSyncCopyFromURLOptions)

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.

undelete(BlobUndeleteOptions)

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.

upload(HttpRequestBody, number, BlockBlobUploadOptions)

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 <xref:stageBlock> and <xref:commitBlockList>. This is a non-parallel uploading method, please use <xref:uploadFile>, <xref:uploadStream> or <xref:uploadBrowserData> for better performance with concurrency uploading.

uploadBrowserData(Blob | ArrayBuffer | ArrayBufferView, BlockBlobParallelUploadOptions)

ONLY AVAILABLE IN BROWSERS. Uploads a browser Blob/File/ArrayBuffer/ArrayBufferView object to block blob.

When buffer length <= 256MB, this method will use 1 upload call to finish the upload. Otherwise, this method will call <xref:stageBlock> to upload blocks, and finally call <xref:commitBlockList> to commit the block list.

uploadFile(string, BlockBlobParallelUploadOptions)

ONLY AVAILABLE IN NODE.JS RUNTIME. Uploads a local file in blocks to a block blob.

When file size <= 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.

uploadStream(Readable, number, number, BlockBlobUploadStreamOptions)

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.
withSnapshot(string)

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.

withVersion(string)

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.

Constructor Details

BlockBlobClient(string, Pipeline)

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.

new BlockBlobClient(url: string, pipeline: Pipeline)

Parameters

url
string

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

pipeline
Pipeline

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

BlockBlobClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, 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.

new BlockBlobClient(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)

Parameters

url
string

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

credential
StorageSharedKeyCredential | AnonymousCredential | TokenCredential

Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the @azure/identity package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.

BlockBlobClient(string, string, string, StoragePipelineOptions)

Creates an instance of BlockBlobClient.

new BlockBlobClient(connectionString: string, containerName: string, blobName: string, options?: StoragePipelineOptions)

Parameters

connectionString
string

Account connection string or a SAS connection string of an Azure storage account. [ Note - Account connection string can only be used in NODE.JS runtime. ] Account connection string example - DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net SAS connection string example - BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString

containerName
string

Container name.

blobName
string

Blob name.

Property Details

accountName

accountName: string

Property Value

string

containerName

The name of the storage container the blob is associated with.

string containerName

Property Value

string

credential

Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the @azure/identity package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.

credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential

Property Value

name

The name of the blob.

string name

Property Value

string

url

Encoded URL string value.

url: string

Property Value

string

Method Details

abortCopyFromURL(string, BlobAbortCopyFromURLOptions)

Aborts a pending asynchronous Copy Blob operation, and leaves a destination blob with zero length and full metadata. Version 2012-02-12 and newer.

function abortCopyFromURL(copyId: string, options?: BlobAbortCopyFromURLOptions)

Parameters

copyId
string

Id of the Copy From URL operation.

Returns

beginCopyFromURL(string, BlobBeginCopyFromURLOptions)

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.

function beginCopyFromURL(copySource: string, options?: BlobBeginCopyFromURLOptions)

Parameters

copySource
string

url to the source Azure Blob/File.

Returns

Promise<PollerLike<PollOperationState<BlobBeginCopyFromURLResponse>, BlobBeginCopyFromURLResponse>>

commitBlockList(string[], BlockBlobCommitBlockListOptions)

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 <xref:stageBlock> operation. You can call <xref: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.

function commitBlockList(blocks: string[], options?: BlockBlobCommitBlockListOptions)

Parameters

blocks
string[]

Array of 64-byte value that is base64-encoded

Returns

Response data for the Block Blob Commit Block List operation.

createSnapshot(BlobCreateSnapshotOptions)

Creates a read-only snapshot of a blob.

function createSnapshot(options?: BlobCreateSnapshotOptions)

Parameters

Returns

delete(BlobDeleteOptions)

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.

function delete(options?: BlobDeleteOptions)

Parameters

Returns

deleteIfExists(BlobDeleteOptions)

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.

function deleteIfExists(options?: BlobDeleteOptions)

Parameters

Returns

download(number, number, BlobDownloadOptions)

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
function download(offset?: number, count?: number, options?: BlobDownloadOptions)

Parameters

offset
number
count
number

Returns

downloadToBuffer(Buffer, number, number, 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 <xref:downloadToFile>.

function downloadToBuffer(buffer: Buffer, offset?: number, count?: number, options?: BlobDownloadToBufferOptions)

Parameters

buffer
Buffer

Buffer to be fill, must have length larger than count

offset
number

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

count
number

Returns

Promise<Buffer>

downloadToBuffer(number, number, 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 <xref:downloadToFile>.

function downloadToBuffer(offset?: number, count?: number, options?: BlobDownloadToBufferOptions)

Parameters

offset
number

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

count
number

Returns

Promise<Buffer>

downloadToFile(string, number, number, BlobDownloadOptions)

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.

function downloadToFile(filePath: string, offset?: number, count?: number, options?: BlobDownloadOptions)

Parameters

filePath
string
offset
number
count
number

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.

exists(BlobExistsOptions)

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.

function exists(options?: BlobExistsOptions)

Parameters

Returns

Promise<boolean>

getAppendBlobClient()

Creates a AppendBlobClient object.

function getAppendBlobClient()

Returns

getBlobLeaseClient(string)

Get a <xref:BlobLeaseClient> that manages leases on the blob.

function getBlobLeaseClient(proposeLeaseId?: string)

Parameters

proposeLeaseId
string

Returns

A new BlobLeaseClient object for managing leases on the blob.

getBlockBlobClient()

Creates a BlockBlobClient object.

function getBlockBlobClient()

Returns

getBlockList(BlockListType, BlockBlobGetBlockListOptions)

Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter.

function getBlockList(listType: BlockListType, options?: BlockBlobGetBlockListOptions)

Parameters

listType
BlockListType

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

Returns

Response data for the Block Blob Get Block List operation.

getPageBlobClient()

Creates a PageBlobClient object.

function getPageBlobClient()

Returns

getProperties(BlobGetPropertiesOptions)

Returns all user-defined metadata, standard HTTP properties, and system properties for the blob. It does not return the content of the blob.

function getProperties(options?: BlobGetPropertiesOptions)

Parameters

Returns

getTags(BlobGetTagsOptions)

Gets the tags associated with the underlying blob.

function getTags(options?: BlobGetTagsOptions)

Parameters

Returns

query(string, BlockBlobQueryOptions)

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 streamToString(queryBlockBlobResponse.readableStreamBody);
console.log("Query blob content:", downloaded);

async function streamToString(readableStream) { return new Promise((resolve, reject) => { const chunks = []; readableStream.on("data", (data) => { chunks.push(data.toString()); }); readableStream.on("end", () => { resolve(chunks.join("")); }); readableStream.on("error", reject); }); }

function query(query: string, options?: BlockBlobQueryOptions)

Parameters

query
string

Returns

setAccessTier(BlockBlobTier | PremiumPageBlobTier | string, BlobSetTierOptions)

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.

function setAccessTier(tier: BlockBlobTier | PremiumPageBlobTier | string, options?: BlobSetTierOptions)

Parameters

tier
BlockBlobTier | PremiumPageBlobTier | string

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

Returns

setHTTPHeaders(BlobHTTPHeaders, BlobSetHTTPHeadersOptions)

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.

function setHTTPHeaders(blobHTTPHeaders?: BlobHTTPHeaders, options?: BlobSetHTTPHeadersOptions)

Parameters

blobHTTPHeaders
BlobHTTPHeaders

Returns

setMetadata(Metadata, BlobSetMetadataOptions)

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.

function setMetadata(metadata?: Metadata, options?: BlobSetMetadataOptions)

Parameters

metadata
Metadata

Returns

setTags(Tags, BlobSetTagsOptions)

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 ('_').

function setTags(tags: Tags, options?: BlobSetTagsOptions)

Parameters

tags
Tags

Returns

stageBlock(string, HttpRequestBody, number, BlockBlobStageBlockOptions)

Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList.

function stageBlock(blockId: string, body: HttpRequestBody, contentLength: number, options?: BlockBlobStageBlockOptions)

Parameters

blockId
string

A 64-byte value that is base64-encoded

body
HttpRequestBody

Data to upload to the staging area.

contentLength
number

Number of bytes to upload.

Returns

Response data for the Block Blob Stage Block operation.

stageBlockFromURL(string, string, number, number, BlockBlobStageBlockFromURLOptions)

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.

function stageBlockFromURL(blockId: string, sourceURL: string, offset?: number, count?: number, options?: BlockBlobStageBlockFromURLOptions)

Parameters

blockId
string

A 64-byte value that is base64-encoded

sourceURL
string

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=

offset
number
count
number

Returns

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

syncCopyFromURL(string, BlobSyncCopyFromURLOptions)

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.

function syncCopyFromURL(copySource: string, options?: BlobSyncCopyFromURLOptions)

Parameters

copySource
string

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

Returns

undelete(BlobUndeleteOptions)

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.

function undelete(options?: BlobUndeleteOptions)

Parameters

Returns

upload(HttpRequestBody, number, BlockBlobUploadOptions)

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 <xref:stageBlock> and <xref:commitBlockList>. This is a non-parallel uploading method, please use <xref:uploadFile>, <xref:uploadStream> or <xref:uploadBrowserData> for better performance with concurrency uploading.

function upload(body: HttpRequestBody, contentLength: number, options?: BlockBlobUploadOptions)

Parameters

body
HttpRequestBody

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

contentLength
number

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

Returns

Response data for the Block Blob Upload operation.

uploadBrowserData(Blob | ArrayBuffer | ArrayBufferView, BlockBlobParallelUploadOptions)

ONLY AVAILABLE IN BROWSERS. Uploads a browser Blob/File/ArrayBuffer/ArrayBufferView object to block blob.

When buffer length <= 256MB, this method will use 1 upload call to finish the upload. Otherwise, this method will call <xref:stageBlock> to upload blocks, and finally call <xref:commitBlockList> to commit the block list.

function uploadBrowserData(browserData: Blob | ArrayBuffer | ArrayBufferView, options?: BlockBlobParallelUploadOptions)

Parameters

browserData
Blob | ArrayBuffer | ArrayBufferView

Blob, File, ArrayBuffer or ArrayBufferView

Returns

Response data for the Blob Upload operation.

uploadFile(string, BlockBlobParallelUploadOptions)

ONLY AVAILABLE IN NODE.JS RUNTIME. Uploads a local file in blocks to a block blob.

When file size <= 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.

function uploadFile(filePath: string, options?: BlockBlobParallelUploadOptions)

Parameters

filePath
string

Full path of local file

Returns

Response data for the Blob Upload operation.

uploadStream(Readable, number, number, BlockBlobUploadStreamOptions)

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.
function uploadStream(stream: Readable, bufferSize?: number, maxConcurrency?: number, options?: BlockBlobUploadStreamOptions)

Parameters

stream
Readable

Node.js Readable stream

bufferSize
number

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

maxConcurrency
number

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

Returns

Response data for the Blob Upload operation.

withSnapshot(string)

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.

function withSnapshot(snapshot: string)

Parameters

snapshot
string

The snapshot timestamp.

Returns

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

withVersion(string)

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.

function withVersion(versionId: string)

Parameters

versionId
string

The versionId.

Returns

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