PageBlobClient defines a set of operations applicable to page blobs.
Properties containerNameThe name of the storage container the blob is associated with.
nameThe name of the blob.
Inherited Properties accountName credentialSuch 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.
Encoded URL string value.
Methods clearPages(number, number, PageBlobClearPagesOptions)Frees the specified pages from the page blob.
See https://learn.microsoft.com/rest/api/storageservices/put-page
create(number, PageBlobCreateOptions)Creates a page blob of the specified length. Call uploadPages to upload data data to a page blob.
See https://learn.microsoft.com/rest/api/storageservices/put-blob
createIfNotExists(number, PageBlobCreateIfNotExistsOptions)Creates a page blob of the specified length. Call uploadPages to upload data data to a page blob. If the blob with the same name already exists, the content of the existing blob will remain unchanged.
See https://learn.microsoft.com/rest/api/storageservices/put-blob
getPageRanges(number, number, PageBlobGetPageRangesOptions)Returns the list of valid page ranges for a page blob or snapshot of a page blob.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
getPageRangesDiff(number, number, string, PageBlobGetPageRangesDiffOptions)Gets the collection of page ranges that differ between a specified snapshot and this page blob.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
getPageRangesDiffForManagedDisks(number, number, string, PageBlobGetPageRangesDiffOptions)Gets the collection of page ranges that differ between a specified snapshot and this page blob for managed disks.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
listPageRanges(number, number, PageBlobListPageRangesOptions)Returns an async iterable iterator to list of page ranges for a page blob.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
.byPage() returns an async iterable iterator to list of page ranges for a page blob.
Example using for await
syntax:
// Get the pageBlobClient before you run these snippets,
// Can be obtained from `blobServiceClient.getContainerClient("<your-container-name>").getPageBlobClient("<your-blob-name>");`
let i = 1;
for await (const pageRange of pageBlobClient.listPageRanges()) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
Example using iter.next()
:
let i = 1;
let iter = pageBlobClient.listPageRanges();
let pageRangeItem = await iter.next();
while (!pageRangeItem.done) {
console.log(`Page range ${i++}: ${pageRangeItem.value.start} - ${pageRangeItem.value.end}, IsClear: ${pageRangeItem.value.isClear}`);
pageRangeItem = await iter.next();
}
Example using byPage()
:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const response of pageBlobClient.listPageRanges().byPage({ maxPageSize: 20 })) {
for (const pageRange of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
}
Example using paging with a marker:
let i = 1;
let iterator = pageBlobClient.listPageRanges().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
// Prints 2 page ranges
for (const pageRange of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = pageBlobClient.listPageRanges().byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;
// Prints 10 page ranges
for (const blob of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
listPageRangesDiff(number, number, string, PageBlobListPageRangesDiffOptions)
Returns an async iterable iterator to list of page ranges that differ between a specified snapshot and this page blob.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
.byPage() returns an async iterable iterator to list of page ranges that differ between a specified snapshot and this page blob.
Example using for await
syntax:
// Get the pageBlobClient before you run these snippets,
// Can be obtained from `blobServiceClient.getContainerClient("<your-container-name>").getPageBlobClient("<your-blob-name>");`
let i = 1;
for await (const pageRange of pageBlobClient.listPageRangesDiff()) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
Example using iter.next()
:
let i = 1;
let iter = pageBlobClient.listPageRangesDiff();
let pageRangeItem = await iter.next();
while (!pageRangeItem.done) {
console.log(`Page range ${i++}: ${pageRangeItem.value.start} - ${pageRangeItem.value.end}, IsClear: ${pageRangeItem.value.isClear}`);
pageRangeItem = await iter.next();
}
Example using byPage()
:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const response of pageBlobClient.listPageRangesDiff().byPage({ maxPageSize: 20 })) {
for (const pageRange of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
}
Example using paging with a marker:
let i = 1;
let iterator = pageBlobClient.listPageRangesDiff().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
// Prints 2 page ranges
for (const pageRange of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = pageBlobClient.listPageRangesDiff().byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;
// Prints 10 page ranges
for (const blob of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
resize(number, PageBlobResizeOptions)
Resizes the page blob to the specified size (which must be a multiple of 512).
See https://learn.microsoft.com/rest/api/storageservices/set-blob-properties
startCopyIncremental(string, PageBlobStartCopyIncrementalOptions)Begins an operation to start an incremental copy from one page blob's snapshot to this page blob. The snapshot is copied such that only the differential changes between the previously copied snapshot are transferred to the destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as usual.
See https://learn.microsoft.com/rest/api/storageservices/incremental-copy-blob See https://learn.microsoft.com/en-us/azure/virtual-machines/windows/incremental-snapshots
updateSequenceNumber(SequenceNumberActionType, number, PageBlobUpdateSequenceNumberOptions)Sets a page blob's sequence number.
See https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-properties
uploadPages(RequestBodyType, number, number, PageBlobUploadPagesOptions)Writes 1 or more pages to the page blob. The start and end offsets must be a multiple of 512.
See https://learn.microsoft.com/rest/api/storageservices/put-page
uploadPagesFromURL(string, number, number, number, PageBlobUploadPagesFromURLOptions)The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL.
See https://learn.microsoft.com/en-us/rest/api/storageservices/put-page-from-url
withSnapshot(string)Creates a new PageBlobClient object identical to the source but with the specified snapshot timestamp. Provide "" will remove the snapshot and return a Client to the base blob.
Inherited 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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/abort-copy-blob
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.
See https://learn.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.');
}
}
createSnapshot(BlobCreateSnapshotOptions)
Creates a read-only snapshot of a blob.
See https://learn.microsoft.com/en-us/rest/api/storageservices/snapshot-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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/delete-blob
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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/delete-blob
deleteImmutabilityPolicy(BlobDeleteImmutabilityPolicyOptions)Delete the immutablility policy on the blob.
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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob
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 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 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.
generateSasStringToSign(BlobGenerateSasUrlOptions)Only available for BlobClient constructed with a shared key credential.
Generates string to sign for 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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas
generateSasUrl(BlobGenerateSasUrlOptions)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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas
generateUserDelegationSasStringToSign(BlobGenerateSasUrlOptions, UserDelegationKey)Only available for BlobClient constructed with a shared key credential.
Generates string to sign for a Blob Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the input user delegation key.
See https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas
generateUserDelegationSasUrl(BlobGenerateSasUrlOptions, UserDelegationKey)Generates a Blob Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the input user delegation key.
See https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas
getAccountInfo(BlobGetAccountInfoOptions)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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/get-account-information
getAppendBlobClient()Creates a AppendBlobClient object.
getBlobLeaseClient(string)Get a BlobLeaseClient that manages leases on the blob.
getBlockBlobClient()Creates a BlockBlobClient object.
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.
See https://learn.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.
Gets the tags associated with the underlying blob.
setAccessTier(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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-tier
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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-properties
setImmutabilityPolicy(BlobImmutabilityPolicy, BlobSetImmutabilityPolicyOptions)Set immutability policy on the blob.
setLegalHold(boolean, BlobSetLegalHoldOptions)Set legal hold on the blob.
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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-metadata
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 ('_').
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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/copy-blob-from-url
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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/undelete-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 PageBlobClient(string, PipelineLike)Creates an instance of PageBlobClient.
new PageBlobClient(url: string, pipeline: PipelineLike)
Parameters
string
A URL string pointing to Azure Storage page blob, such as "https://myaccount.blob.core.windows.net/mycontainer/pageblob". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer/pageblob?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".
Call newPipeline() to create a default pipeline, or provide a customized pipeline.
PageBlobClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions)Creates an instance of PageBlobClient. 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.
new PageBlobClient(url: string, credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)
Parameters
string
A Client string pointing to Azure Storage page blob, such as "https://myaccount.blob.core.windows.net/mycontainer/pageblob". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer/pageblob?sasString".
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.
Creates an instance of PageBlobClient.
new PageBlobClient(connectionString: string, containerName: string, blobName: string, options?: StoragePipelineOptions)
Parameters
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
string
Container name.
string
Blob name.
Property Details containerNameThe name of the storage container the blob is associated with.
string containerName
Property Value
string
nameThe name of the blob.
string name
Property Value
string
Inherited Property Details credentialSuch 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
StorageSharedKeyCredential | AnonymousCredential | TokenCredential
Inherited From BlobClient.credential
urlEncoded URL string value.
url: string
Property Value
string
Inherited From BlobClient.url
Method Details clearPages(number, number, PageBlobClearPagesOptions)Frees the specified pages from the page blob.
See https://learn.microsoft.com/rest/api/storageservices/put-page
function clearPages(offset?: number, count?: number, options?: PageBlobClearPagesOptions): Promise<PageBlobClearPagesResponse>
Parameters
number
Starting byte position of the pages to clear.
number
Number of bytes to clear.
ReturnsPromise<PageBlobClearPagesResponse>
Response data for the Page Blob Clear Pages operation.
create(number, PageBlobCreateOptions) createIfNotExists(number, PageBlobCreateIfNotExistsOptions)Creates a page blob of the specified length. Call uploadPages to upload data data to a page blob. If the blob with the same name already exists, the content of the existing blob will remain unchanged.
See https://learn.microsoft.com/rest/api/storageservices/put-blob
function createIfNotExists(size: number, options?: PageBlobCreateIfNotExistsOptions): Promise<PageBlobCreateIfNotExistsResponse>
Parameters
number
size of the page blob.
ReturnsPromise<PageBlobCreateIfNotExistsResponse>
Returns the list of valid page ranges for a page blob or snapshot of a page blob.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
function getPageRanges(offset?: number, count?: number, options?: PageBlobGetPageRangesOptions): Promise<PageBlobGetPageRangesResponse>
Parameters
number
Starting byte position of the page ranges.
number
Number of bytes to get.
ReturnsPromise<PageBlobGetPageRangesResponse>
Response data for the Page Blob Get Ranges operation.
Gets the collection of page ranges that differ between a specified snapshot and this page blob.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
function getPageRangesDiff(offset: number, count: number, prevSnapshot: string, options?: PageBlobGetPageRangesDiffOptions): Promise<PageBlobGetPageRangesDiffResponse>
Parameters
number
Starting byte position of the page blob
number
Number of bytes to get ranges diff.
string
Timestamp of snapshot to retrieve the difference.
ReturnsPromise<PageBlobGetPageRangesDiffResponse>
Response data for the Page Blob Get Page Range Diff operation.
Gets the collection of page ranges that differ between a specified snapshot and this page blob for managed disks.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
function getPageRangesDiffForManagedDisks(offset: number, count: number, prevSnapshotUrl: string, options?: PageBlobGetPageRangesDiffOptions): Promise<PageBlobGetPageRangesDiffResponse>
Parameters
number
Starting byte position of the page blob
number
Number of bytes to get ranges diff.
string
URL of snapshot to retrieve the difference.
ReturnsPromise<PageBlobGetPageRangesDiffResponse>
Response data for the Page Blob Get Page Range Diff operation.
Returns an async iterable iterator to list of page ranges for a page blob.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
.byPage() returns an async iterable iterator to list of page ranges for a page blob.
Example using for await
syntax:
// Get the pageBlobClient before you run these snippets,
// Can be obtained from `blobServiceClient.getContainerClient("<your-container-name>").getPageBlobClient("<your-blob-name>");`
let i = 1;
for await (const pageRange of pageBlobClient.listPageRanges()) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
Example using iter.next()
:
let i = 1;
let iter = pageBlobClient.listPageRanges();
let pageRangeItem = await iter.next();
while (!pageRangeItem.done) {
console.log(`Page range ${i++}: ${pageRangeItem.value.start} - ${pageRangeItem.value.end}, IsClear: ${pageRangeItem.value.isClear}`);
pageRangeItem = await iter.next();
}
Example using byPage()
:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const response of pageBlobClient.listPageRanges().byPage({ maxPageSize: 20 })) {
for (const pageRange of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
}
Example using paging with a marker:
let i = 1;
let iterator = pageBlobClient.listPageRanges().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
// Prints 2 page ranges
for (const pageRange of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = pageBlobClient.listPageRanges().byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;
// Prints 10 page ranges
for (const blob of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
function listPageRanges(offset?: number, count?: number, options?: PageBlobListPageRangesOptions): PagedAsyncIterableIterator<PageRangeInfo, PageBlobGetPageRangesResponseModel, PageSettings>
Parameters
number
Starting byte position of the page ranges.
number
Number of bytes to get.
ReturnsPagedAsyncIterableIterator<PageRangeInfo, PageBlobGetPageRangesResponseModel, PageSettings>
An asyncIterableIterator that supports paging.
Returns an async iterable iterator to list of page ranges that differ between a specified snapshot and this page blob.
See https://learn.microsoft.com/rest/api/storageservices/get-page-ranges
.byPage() returns an async iterable iterator to list of page ranges that differ between a specified snapshot and this page blob.
Example using for await
syntax:
// Get the pageBlobClient before you run these snippets,
// Can be obtained from `blobServiceClient.getContainerClient("<your-container-name>").getPageBlobClient("<your-blob-name>");`
let i = 1;
for await (const pageRange of pageBlobClient.listPageRangesDiff()) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
Example using iter.next()
:
let i = 1;
let iter = pageBlobClient.listPageRangesDiff();
let pageRangeItem = await iter.next();
while (!pageRangeItem.done) {
console.log(`Page range ${i++}: ${pageRangeItem.value.start} - ${pageRangeItem.value.end}, IsClear: ${pageRangeItem.value.isClear}`);
pageRangeItem = await iter.next();
}
Example using byPage()
:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const response of pageBlobClient.listPageRangesDiff().byPage({ maxPageSize: 20 })) {
for (const pageRange of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
}
Example using paging with a marker:
let i = 1;
let iterator = pageBlobClient.listPageRangesDiff().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
// Prints 2 page ranges
for (const pageRange of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = pageBlobClient.listPageRangesDiff().byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;
// Prints 10 page ranges
for (const blob of response) {
console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
}
function listPageRangesDiff(offset: number, count: number, prevSnapshot: string, options?: PageBlobListPageRangesDiffOptions): PagedAsyncIterableIterator<PageRangeInfo, PageBlobGetPageRangesDiffResponseModel, PageSettings>
Parameters
number
Starting byte position of the page ranges.
number
Number of bytes to get.
string
Timestamp of snapshot to retrieve the difference.
ReturnsPagedAsyncIterableIterator<PageRangeInfo, PageBlobGetPageRangesDiffResponseModel, PageSettings>
An asyncIterableIterator that supports paging.
resize(number, PageBlobResizeOptions) startCopyIncremental(string, PageBlobStartCopyIncrementalOptions) updateSequenceNumber(SequenceNumberActionType, number, PageBlobUpdateSequenceNumberOptions) uploadPages(RequestBodyType, number, number, PageBlobUploadPagesOptions)Writes 1 or more pages to the page blob. The start and end offsets must be a multiple of 512.
See https://learn.microsoft.com/rest/api/storageservices/put-page
function uploadPages(body: RequestBodyType, offset: number, count: number, options?: PageBlobUploadPagesOptions): Promise<PageBlobUploadPagesResponse>
Parameters
number
Offset of destination page blob
number
Content length of the body, also number of bytes to be uploaded
ReturnsPromise<PageBlobUploadPagesResponse>
Response data for the Page Blob Upload Pages operation.
uploadPagesFromURL(string, number, number, number, PageBlobUploadPagesFromURLOptions)The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL.
See https://learn.microsoft.com/en-us/rest/api/storageservices/put-page-from-url
function uploadPagesFromURL(sourceURL: string, sourceOffset: number, destOffset: number, count: number, options?: PageBlobUploadPagesFromURLOptions): Promise<PageBlobUploadPagesFromURLResponse>
Parameters
string
Specify a URL to the copy source, Shared Access Signature(SAS) maybe needed for authentication
number
The source offset to copy from. Pass 0 to copy from the beginning of source page blob
number
Offset of destination page blob
number
Number of bytes to be uploaded from source page blob
ReturnsPromise<PageBlobUploadPagesFromURLResponse>
withSnapshot(string)Creates a new PageBlobClient object identical to the source but with the specified snapshot timestamp. Provide "" will remove the snapshot and return a Client to the base blob.
function withSnapshot(snapshot: string): PageBlobClient
Parameters
string
The snapshot timestamp.
ReturnsA new PageBlobClient object identical to the source but with the specified snapshot timestamp.
Inherited Method Details abortCopyFromURL(string, BlobAbortCopyFromURLOptions) 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.
See https://learn.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.');
}
}
function beginCopyFromURL(copySource: string, options?: BlobBeginCopyFromURLOptions): Promise<PollerLikeWithCancellation<PollOperationState<BlobBeginCopyFromURLResponse>, BlobBeginCopyFromURLResponse>>
Parameters
string
url to the source Azure Blob/File.
ReturnsPromise<PollerLikeWithCancellation<PollOperationState<BlobBeginCopyFromURLResponse>, BlobBeginCopyFromURLResponse>>
Inherited From BlobClient.beginCopyFromURL
createSnapshot(BlobCreateSnapshotOptions) delete(BlobDeleteOptions) deleteIfExists(BlobDeleteOptions) deleteImmutabilityPolicy(BlobDeleteImmutabilityPolicyOptions) 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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob
function download(offset?: number, count?: number, options?: BlobDownloadOptions): Promise<BlobDownloadResponseParsed>
Parameters
number
From which position of the blob to download, greater than or equal to 0
number
How much data to be downloaded, greater than 0. Will download to the end when undefined
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(typeof data === "string" ? Buffer.from(data) : 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);
});
}
Returns
Promise<BlobDownloadResponseParsed>
Inherited From BlobClient.download
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 downloadToFile.
function downloadToBuffer(buffer: Buffer, offset?: number, count?: number, options?: BlobDownloadToBufferOptions): Promise<Buffer>
Parameters
Buffer
Buffer to be fill, must have length larger than count
number
From which position of the block blob to download(in bytes)
number
How much data(in bytes) to be downloaded. Will download to the end when passing undefined
ReturnsPromise<Buffer>
Inherited From BlobClient.downloadToBuffer
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 downloadToFile.
function downloadToBuffer(offset?: number, count?: number, options?: BlobDownloadToBufferOptions): Promise<Buffer>
Parameters
number
From which position of the block blob to download(in bytes)
number
How much data(in bytes) to be downloaded. Will download to the end when passing undefined
ReturnsPromise<Buffer>
Inherited From BlobClient.downloadToBuffer
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): Promise<BlobDownloadResponseParsed>
Parameters
number
From which position of the block blob to download.
number
How much data to be downloaded. Will download to the end when passing undefined.
ReturnsPromise<BlobDownloadResponseParsed>
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.
Inherited From BlobClient.downloadToFile
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): Promise<boolean>
Parameters Returns
Promise<boolean>
Inherited From BlobClient.exists
generateSasStringToSign(BlobGenerateSasUrlOptions)Only available for BlobClient constructed with a shared key credential.
Generates string to sign for 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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas
function generateSasStringToSign(options: BlobGenerateSasUrlOptions): string
Parameters Returns
string
The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
Inherited From BlobClient.generateSasStringToSign
generateSasUrl(BlobGenerateSasUrlOptions)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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas
function generateSasUrl(options: BlobGenerateSasUrlOptions): Promise<string>
Parameters Returns
Promise<string>
The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
Inherited From BlobClient.generateSasUrl
generateUserDelegationSasStringToSign(BlobGenerateSasUrlOptions, UserDelegationKey)Only available for BlobClient constructed with a shared key credential.
Generates string to sign for a Blob Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the input user delegation key.
See https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas
function generateUserDelegationSasStringToSign(options: BlobGenerateSasUrlOptions, userDelegationKey: UserDelegationKey): string
Parameters
Return value of blobServiceClient.getUserDelegationKey()
string
The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
Inherited From BlobClient.generateUserDelegationSasStringToSign
generateUserDelegationSasUrl(BlobGenerateSasUrlOptions, UserDelegationKey) getAccountInfo(BlobGetAccountInfoOptions) getBlobLeaseClient(string)Get a BlobLeaseClient that manages leases on the blob.
function getBlobLeaseClient(proposeLeaseId?: string): BlobLeaseClient
Parameters
string
Initial proposed lease Id.
ReturnsA new BlobLeaseClient object for managing leases on the blob.
Inherited From BlobClient.getBlobLeaseClient
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.
See https://learn.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.
function getProperties(options?: BlobGetPropertiesOptions): Promise<BlobGetPropertiesResponse>
Parameters Returns
Promise<BlobGetPropertiesResponse>
Inherited From BlobClient.getProperties
getTags(BlobGetTagsOptions)Gets the tags associated with the underlying blob.
function getTags(options?: BlobGetTagsOptions): Promise<BlobGetTagsResponse>
Parameters Returns
Promise<BlobGetTagsResponse>
Inherited From BlobClient.getTags
setAccessTier(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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-tier
function setAccessTier(tier: string, options?: BlobSetTierOptions): Promise<BlobSetTierResponse>
Parameters
string
The tier to be set on the blob. Valid values are Hot, Cool, or Archive.
ReturnsPromise<BlobSetTierResponse>
Inherited From BlobClient.setAccessTier
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.
See https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-properties
function setHTTPHeaders(blobHTTPHeaders?: BlobHTTPHeaders, options?: BlobSetHTTPHeadersOptions): Promise<BlobSetHTTPHeadersResponse>
Parameters
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.
Promise<BlobSetHTTPHeadersResponse>
Inherited From BlobClient.setHTTPHeaders
setImmutabilityPolicy(BlobImmutabilityPolicy, BlobSetImmutabilityPolicyOptions) setLegalHold(boolean, BlobSetLegalHoldOptions)Set legal hold on the blob.
function setLegalHold(legalHoldEnabled: boolean, options?: BlobSetLegalHoldOptions): Promise<BlobSetLegalHoldResponse>
Parameters Returns
Promise<BlobSetLegalHoldResponse>
Inherited From BlobClient.setLegalHold
setMetadata(Metadata, BlobSetMetadataOptions) 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): Promise<BlobSetTagsResponse>
Parameters Returns
Promise<BlobSetTagsResponse>
Inherited From BlobClient.setTags
syncCopyFromURL(string, BlobSyncCopyFromURLOptions) undelete(BlobUndeleteOptions) 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): BlobClient
Parameters
string
The versionId.
ReturnsA new BlobClient object pointing to the version of this blob.
Inherited From BlobClient.withVersion
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4