Delen via


PageBlobClient Class

public final class PageBlobClient
extends BlobClientBase

Client to a page blob. It may only be instantiated through a SpecializedBlobClientBuilder or via the method getPageBlobClient(). This class does not hold any state about a particular blob, but is instead a convenient way of sending appropriate requests to the resource on the service.

Please refer to the Azure Docs for more information.

Field Summary

Modifier and Type Field and Description
static final int MAX_PUT_PAGES_BYTES

Indicates the maximum number of bytes that may be sent in a call to putPage.

static final int PAGE_BYTES

Indicates the number of bytes in a page.

Method Summary

Modifier and Type Method and Description
PageBlobItem clearPages(PageRange pageRange)

Frees the specified pages from the page blob.

Response<PageBlobItem> clearPagesWithResponse(PageRange pageRange, PageBlobRequestConditions pageBlobRequestConditions, Duration timeout, Context context)

Frees the specified pages from the page blob.

CopyStatusType copyIncremental(String source, String snapshot)

Begins an operation to start an incremental copy from one page blob's snapshot to this page blob.

Response<CopyStatusType> copyIncrementalWithResponse(PageBlobCopyIncrementalOptions options, Duration timeout, Context context)

Begins an operation to start an incremental copy from one page blob's snapshot to this page blob.

Response<CopyStatusType> copyIncrementalWithResponse(String source, String snapshot, RequestConditions modifiedRequestConditions, Duration timeout, Context context)

Begins an operation to start an incremental copy from one page blob's snapshot to this page blob.

PageBlobItem create(long size)

Creates a page blob of the specified length.

PageBlobItem create(long size, boolean overwrite)

Creates a page blob of the specified length.

PageBlobItem createIfNotExists(long size)

Creates a page blob of the specified length if it does not exist.

Response<PageBlobItem> createIfNotExistsWithResponse(PageBlobCreateOptions options, Duration timeout, Context context)

Creates a page blob of the specified length if it does not exist.

Response<PageBlobItem> createWithResponse(PageBlobCreateOptions options, Duration timeout, Context context)

Creates a page blob of the specified length.

Response<PageBlobItem> createWithResponse(long size, Long sequenceNumber, BlobHttpHeaders headers, Map<String,String> metadata, BlobRequestConditions requestConditions, Duration timeout, Context context)

Creates a page blob of the specified length.

BlobOutputStream getBlobOutputStream(PageRange pageRange)

Creates and opens an output stream to write data to the page blob.

BlobOutputStream getBlobOutputStream(PageRange pageRange, BlobRequestConditions requestConditions)

Creates and opens an output stream to write data to the page blob.

PageBlobClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)

Creates a new PageBlobClient with the specified customerProvidedKey.

PageBlobClient getEncryptionScopeClient(String encryptionScope)

Creates a new PageBlobClient with the specified encryptionScope.

PageList getManagedDiskPageRangesDiff(BlobRange blobRange, String prevSnapshotUrl)

This API only works for managed disk accounts.

Response<PageList> getManagedDiskPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshotUrl, BlobRequestConditions requestConditions, Duration timeout, Context context)

This API only works for managed disk accounts.

PageList getPageRanges(BlobRange blobRange)

Deprecated

Returns the list of valid page ranges for a page blob or snapshot of a page blob.

PageList getPageRangesDiff(BlobRange blobRange, String prevSnapshot)

Deprecated

Gets the collection of page ranges that differ between a specified snapshot and this page blob.

Response<PageList> getPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshot, BlobRequestConditions requestConditions, Duration timeout, Context context)

Deprecated

This API only works for managed disk accounts.

Response<PageList> getPageRangesWithResponse(BlobRange blobRange, BlobRequestConditions requestConditions, Duration timeout, Context context)

Deprecated

Returns the list of valid page ranges for a page blob or snapshot of a page blob.

PagedIterable<PageRangeItem> listPageRanges(BlobRange blobRange)

Returns the list of valid page ranges for a page blob or snapshot of a page blob.

PagedIterable<PageRangeItem> listPageRanges(ListPageRangesOptions options, Duration timeout, Context context)

Returns the list of valid page ranges for a page blob or snapshot of a page blob.

PagedIterable<PageRangeItem> listPageRangesDiff(BlobRange blobRange, String prevSnapshot)

Gets the collection of page ranges that differ between a specified snapshot and this page blob.

PagedIterable<PageRangeItem> listPageRangesDiff(ListPageRangesDiffOptions options, Duration timeout, Context context)

Gets the collection of page ranges that differ between a specified snapshot and this page blob.

PageBlobItem resize(long size)

Resizes the page blob to the specified size (which must be a multiple of 512).

Response<PageBlobItem> resizeWithResponse(long size, BlobRequestConditions requestConditions, Duration timeout, Context context)

Resizes the page blob to the specified size (which must be a multiple of 512).

PageBlobItem updateSequenceNumber(SequenceNumberActionType action, Long sequenceNumber)

Sets the page blob's sequence number.

Response<PageBlobItem> updateSequenceNumberWithResponse(SequenceNumberActionType action, Long sequenceNumber, BlobRequestConditions requestConditions, Duration timeout, Context context)

Sets the page blob's sequence number.

PageBlobItem uploadPages(PageRange pageRange, InputStream body)

Writes one or more pages to the page blob.

PageBlobItem uploadPagesFromUrl(PageRange range, String sourceUrl, Long sourceOffset)

Writes one or more pages from the source page blob to this page blob.

Response<PageBlobItem> uploadPagesFromUrlWithResponse(PageRange range, String sourceUrl, Long sourceOffset, byte[] sourceContentMd5, PageBlobRequestConditions destRequestConditions, BlobRequestConditions sourceRequestConditions, Duration timeout, Context context)

Writes one or more pages from the source page blob to this page blob.

Response<PageBlobItem> uploadPagesFromUrlWithResponse(PageBlobUploadPagesFromUrlOptions options, Duration timeout, Context context)

Writes one or more pages from the source page blob to this page blob.

Response<PageBlobItem> uploadPagesWithResponse(PageRange pageRange, InputStream body, byte[] contentMd5, PageBlobRequestConditions pageBlobRequestConditions, Duration timeout, Context context)

Writes one or more pages to the page blob.

Methods inherited from BlobClientBase

abortCopyFromUrl abortCopyFromUrlWithResponse beginCopy beginCopy beginCopy copyFromUrl copyFromUrlWithResponse copyFromUrlWithResponse createSnapshot createSnapshotWithResponse delete deleteIfExists deleteIfExistsWithResponse deleteImmutabilityPolicy deleteImmutabilityPolicyWithResponse deleteWithResponse download downloadContent downloadContentWithResponse downloadContentWithResponse downloadStream downloadStreamWithResponse downloadToFile downloadToFile downloadToFileWithResponse downloadToFileWithResponse downloadToFileWithResponse downloadWithResponse exists existsWithResponse generateSas generateSas generateSas generateUserDelegationSas generateUserDelegationSas generateUserDelegationSas getAccountInfo getAccountInfoWithResponse getAccountName getAccountUrl getBlobName getBlobUrl getContainerClient getContainerName getCustomerProvidedKey getCustomerProvidedKeyClient getEncryptionScope getEncryptionScopeClient getHttpPipeline getProperties getPropertiesWithResponse getServiceVersion getSnapshotClient getSnapshotId getTags getTagsWithResponse getVersionClient getVersionId isSnapshot openInputStream openInputStream openInputStream openInputStream openQueryInputStream openQueryInputStreamWithResponse openSeekableByteChannelRead query queryWithResponse setAccessTier setAccessTierWithResponse setAccessTierWithResponse setHttpHeaders setHttpHeadersWithResponse setImmutabilityPolicy setImmutabilityPolicyWithResponse setLegalHold setLegalHoldWithResponse setMetadata setMetadataWithResponse setTags setTagsWithResponse undelete undeleteWithResponse

Methods inherited from java.lang.Object

Field Details

MAX_PUT_PAGES_BYTES

public static final int MAX_PUT_PAGES_BYTES

Indicates the maximum number of bytes that may be sent in a call to putPage.

PAGE_BYTES

public static final int PAGE_BYTES

Indicates the number of bytes in a page.

Method Details

clearPages

public PageBlobItem clearPages(PageRange pageRange)

Frees the specified pages from the page blob. The size of the range must be a multiple of 512. For more information, see the Azure Docs.

Code Samples

PageRange pageRange = new PageRange()
     .setStart(0)
     .setEnd(511);

 PageBlobItem pageBlob = client.clearPages(pageRange);

 System.out.printf("Cleared page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

pageRange - A PageRange object. Given that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges are 0-511, 512-1023, etc.

Returns:

The information of the cleared pages.

clearPagesWithResponse

public Response clearPagesWithResponse(PageRange pageRange, PageBlobRequestConditions pageBlobRequestConditions, Duration timeout, Context context)

Frees the specified pages from the page blob. The size of the range must be a multiple of 512. For more information, see the Azure Docs.

Code Samples

PageRange pageRange = new PageRange()
     .setStart(0)
     .setEnd(511);
 PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
 Context context = new Context(key, value);

 PageBlobItem pageBlob = client
     .clearPagesWithResponse(pageRange, pageBlobRequestConditions, timeout, context).getValue();

 System.out.printf("Cleared page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

pageRange - A PageRange object. Given that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges are 0-511, 512-1023, etc.
pageBlobRequestConditions - PageBlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The information of the cleared pages.

copyIncremental

public CopyStatusType copyIncremental(String source, String snapshot)

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. For more information, see the Azure Docs here and here.

Code Samples

final String snapshot = "copy snapshot";
 CopyStatusType statusType = client.copyIncremental(url, snapshot);

 switch (statusType) {
     case SUCCESS:
         System.out.println("Page blob copied successfully");
         break;
     case FAILED:
         System.out.println("Page blob copied failed");
         break;
     case ABORTED:
         System.out.println("Page blob copied aborted");
         break;
     case PENDING:
         System.out.println("Page blob copied pending");
         break;
     default:
         break;
 }

Parameters:

source - The source page blob.
snapshot - The snapshot on the copy source.

Returns:

The copy status.

copyIncrementalWithResponse

public Response copyIncrementalWithResponse(PageBlobCopyIncrementalOptions options, Duration timeout, Context context)

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. For more information, see the Azure Docs here and here.

Code Samples

final String snapshot = "copy snapshot";
 PageBlobCopyIncrementalRequestConditions destinationRequestConditions = new PageBlobCopyIncrementalRequestConditions()
     .setIfNoneMatch("snapshotMatch");
 Context context = new Context(key, value);

 CopyStatusType statusType = client
     .copyIncrementalWithResponse(new PageBlobCopyIncrementalOptions(url, snapshot)
         .setRequestConditions(destinationRequestConditions), timeout, context).getValue();

 switch (statusType) {
     case SUCCESS:
         System.out.println("Page blob copied successfully");
         break;
     case FAILED:
         System.out.println("Page blob copied failed");
         break;
     case ABORTED:
         System.out.println("Page blob copied aborted");
         break;
     case PENDING:
         System.out.println("Page blob copied pending");
         break;
     default:
         break;
 }

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The copy status.

copyIncrementalWithResponse

public Response copyIncrementalWithResponse(String source, String snapshot, RequestConditions modifiedRequestConditions, Duration timeout, Context context)

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. For more information, see the Azure Docs here and here.

Code Samples

final String snapshot = "copy snapshot";
 RequestConditions modifiedRequestConditions = new RequestConditions()
     .setIfNoneMatch("snapshotMatch");
 Context context = new Context(key, value);

 CopyStatusType statusType = client
     .copyIncrementalWithResponse(url, snapshot, modifiedRequestConditions, timeout, context).getValue();

 switch (statusType) {
     case SUCCESS:
         System.out.println("Page blob copied successfully");
         break;
     case FAILED:
         System.out.println("Page blob copied failed");
         break;
     case ABORTED:
         System.out.println("Page blob copied aborted");
         break;
     case PENDING:
         System.out.println("Page blob copied pending");
         break;
     default:
         break;
 }

Parameters:

source - The source page blob.
snapshot - The snapshot on the copy source.
modifiedRequestConditions - Standard HTTP Access conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given request. The request will fail if the specified condition is not satisfied.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The copy status.

create

public PageBlobItem create(long size)

Creates a page blob of the specified length. By default this method will not overwrite an existing blob. Call PutPage to upload data data to a page blob. For more information, see the Azure Docs.

Code Samples

PageBlobItem pageBlob = client.create(size);
 System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

size - Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a 512-byte boundary.

Returns:

The information of the created page blob.

create

public PageBlobItem create(long size, boolean overwrite)

Creates a page blob of the specified length. Call PutPage to upload data data to a page blob. For more information, see the Azure Docs.

Code Samples

boolean overwrite = false; // Default value
 PageBlobItem pageBlob = client.create(size, overwrite);
 System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

size - Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a 512-byte boundary.
overwrite - Whether or not to overwrite, should data exist on the blob.

Returns:

The information of the created page blob.

createIfNotExists

public PageBlobItem createIfNotExists(long size)

Creates a page blob of the specified length if it does not exist. Call PutPage to upload data to a page blob. For more information, see the Azure Docs.

Code Samples

PageBlobItem pageBlob = client.createIfNotExists(size);
 System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

size - Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a 512-byte boundary.

Returns:

PageBlobItem containing information of the created page blob.

createIfNotExistsWithResponse

public Response createIfNotExistsWithResponse(PageBlobCreateOptions options, Duration timeout, Context context)

Creates a page blob of the specified length if it does not exist. Call PutPage to upload data to a page blob. For more information, see the Azure Docs.

Code Samples

BlobHttpHeaders headers = new BlobHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary");
 Context context = new Context(key, value);

 Response<PageBlobItem> response = client.createIfNotExistsWithResponse(new PageBlobCreateOptions(size)
     .setHeaders(headers).setMetadata(metadata).setTags(tags), timeout, context);

 if (response.getStatusCode() == 409) {
     System.out.println("Already existed.");
 } else {
     System.out.printf("Create completed with status %d%n", response.getStatusCode());
 }

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A reactive Response<T> signaling completion, whose value contains a PageBlobItem containing information about the page blob. If Response<T>'s status code is 201, a new page blob was successfully created. If status code is 409, a page blob already existed at this location.

createWithResponse

public Response createWithResponse(PageBlobCreateOptions options, Duration timeout, Context context)

Creates a page blob of the specified length. Call PutPage to upload data data to a page blob. For more information, see the Azure Docs.

To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).

Code Samples

BlobHttpHeaders headers = new BlobHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary");
 BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 Context context = new Context(key, value);

 PageBlobItem pageBlob = client
     .createWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber)
             .setHeaders(headers).setMetadata(metadata).setTags(tags)
             .setRequestConditions(blobRequestConditions), timeout,
         context)
     .getValue();

 System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The information of the created page blob.

createWithResponse

public Response createWithResponse(long size, Long sequenceNumber, BlobHttpHeaders headers, Map metadata, BlobRequestConditions requestConditions, Duration timeout, Context context)

Creates a page blob of the specified length. Call PutPage to upload data data to a page blob. For more information, see the Azure Docs.

To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).

Code Samples

BlobHttpHeaders headers = new BlobHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary");
 BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 Context context = new Context(key, value);

 PageBlobItem pageBlob = client
     .createWithResponse(size, sequenceNumber, headers, metadata, blobRequestConditions, timeout, context)
     .getValue();

 System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

size - Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a 512-byte boundary.
sequenceNumber - A user-controlled value that you can use to track requests. The value of the sequence number must be between 0 and 2^63 - 1.The default value is 0.
headers - BlobHttpHeaders
metadata - Metadata to associate with the blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The information of the created page blob.

getBlobOutputStream

public BlobOutputStream getBlobOutputStream(PageRange pageRange)

Creates and opens an output stream to write data to the page blob. If the blob already exists on the service, it will be overwritten.

Parameters:

pageRange - A PageRange object. Given that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges are 0-511, 512-1023, etc.

Returns:

A BlobOutputStream object used to write data to the blob.

getBlobOutputStream

public BlobOutputStream getBlobOutputStream(PageRange pageRange, BlobRequestConditions requestConditions)

Creates and opens an output stream to write data to the page blob. If the blob already exists on the service, it will be overwritten.

Parameters:

pageRange - A PageRange object. Given that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges are 0-511, 512-1023, etc.
requestConditions - A BlobRequestConditions object that represents the access conditions for the blob.

Returns:

A BlobOutputStream object used to write data to the blob.

getCustomerProvidedKeyClient

public PageBlobClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)

Creates a new PageBlobClient with the specified customerProvidedKey.

Overrides:

PageBlobClient.getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)

Parameters:

customerProvidedKey - the CustomerProvidedKey for the blob, pass null to use no customer provided key.

Returns:

a PageBlobClient with the specified customerProvidedKey.

getEncryptionScopeClient

public PageBlobClient getEncryptionScopeClient(String encryptionScope)

Creates a new PageBlobClient with the specified encryptionScope.

Overrides:

PageBlobClient.getEncryptionScopeClient(String encryptionScope)

Parameters:

encryptionScope - the encryption scope for the blob, pass null to use no encryption scope.

Returns:

a PageBlobClient with the specified encryptionScope.

getManagedDiskPageRangesDiff

public PageList getManagedDiskPageRangesDiff(BlobRange blobRange, String prevSnapshotUrl)

This API only works for managed disk accounts.

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more information, see the Azure Docs.

Code Samples

BlobRange blobRange = new BlobRange(offset);
 final String prevSnapshotUrl = "previous snapshot url";
 PageList pageList = client.getPageRangesDiff(blobRange, prevSnapshotUrl);

 System.out.println("Valid Page Ranges are:");
 for (PageRange pageRange : pageList.getPageRange()) {
     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
 }

Parameters:

blobRange - BlobRange
prevSnapshotUrl - Specifies the URL of a previous snapshot of the target blob. Specifies that the response will contain only pages that were changed between target blob and previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by prevsnapshot is the older of the two.

Returns:

All the different page ranges.

getManagedDiskPageRangesDiffWithResponse

public Response getManagedDiskPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshotUrl, BlobRequestConditions requestConditions, Duration timeout, Context context)

This API only works for managed disk accounts.

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more information, see the Azure Docs.

Code Samples

BlobRange blobRange = new BlobRange(offset);
 final String prevSnapshotUrl = "previous snapshot url";
 BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 Context context = new Context(key, value);

 PageList pageList = client
     .getPageRangesDiffWithResponse(blobRange, prevSnapshotUrl, blobRequestConditions, timeout, context).getValue();

 System.out.println("Valid Page Ranges are:");
 for (PageRange pageRange : pageList.getPageRange()) {
     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
 }

Parameters:

blobRange - BlobRange
prevSnapshotUrl - Specifies the URL of a previous snapshot of the target blob. Specifies that the response will contain only pages that were changed between target blob and previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by prevsnapshot is the older of the two.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

All the different page ranges.

getPageRanges

@Deprecated
public PageList getPageRanges(BlobRange blobRange)

Deprecated

Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the Azure Docs.

Code Samples

BlobRange blobRange = new BlobRange(offset);
 PageList pageList = client.getPageRanges(blobRange);

 System.out.println("Valid Page Ranges are:");
 for (PageRange pageRange : pageList.getPageRange()) {
     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
 }

Parameters:

blobRange - BlobRange

Returns:

The information of the cleared pages.

getPageRangesDiff

@Deprecated
public PageList getPageRangesDiff(BlobRange blobRange, String prevSnapshot)

Deprecated

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more information, see the Azure Docs.

Code Samples

BlobRange blobRange = new BlobRange(offset);
 final String prevSnapshot = "previous snapshot";
 PageList pageList = client.getPageRangesDiff(blobRange, prevSnapshot);

 System.out.println("Valid Page Ranges are:");
 for (PageRange pageRange : pageList.getPageRange()) {
     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
 }

Parameters:

blobRange - BlobRange
prevSnapshot - Specifies that the response will contain only pages that were changed between target blob and previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by prevsnapshot is the older of the two.

Returns:

All the different page ranges.

getPageRangesDiffWithResponse

@Deprecated
public Response getPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshot, BlobRequestConditions requestConditions, Duration timeout, Context context)

Deprecated

This API only works for managed disk accounts.

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more information, see the Azure Docs.

Code Samples

BlobRange blobRange = new BlobRange(offset);
 final String prevSnapshot = "previous snapshot";
 BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 Context context = new Context(key, value);

 PageList pageList = client
     .getPageRangesDiffWithResponse(blobRange, prevSnapshot, blobRequestConditions, timeout, context).getValue();

 System.out.println("Valid Page Ranges are:");
 for (PageRange pageRange : pageList.getPageRange()) {
     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
 }

Parameters:

blobRange - BlobRange
prevSnapshot - Specifies that the response will contain only pages that were changed between target blob and previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by prevsnapshot is the older of the two.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

All the different page ranges.

getPageRangesWithResponse

@Deprecated
public Response getPageRangesWithResponse(BlobRange blobRange, BlobRequestConditions requestConditions, Duration timeout, Context context)

Deprecated

Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the Azure Docs.

Code Samples

BlobRange blobRange = new BlobRange(offset);
 BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 Context context = new Context(key, value);

 PageList pageList = client
     .getPageRangesWithResponse(blobRange, blobRequestConditions, timeout, context).getValue();

 System.out.println("Valid Page Ranges are:");
 for (PageRange pageRange : pageList.getPageRange()) {
     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
 }

Parameters:

blobRange - BlobRange
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

All the page ranges.

listPageRanges

public PagedIterable listPageRanges(BlobRange blobRange)

Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the Azure Docs.

Code Samples

BlobRange blobRange = new BlobRange(offset);
 String prevSnapshot = "previous snapshot";
 PagedIterable<PageRangeItem> iterable = client.listPageRanges(blobRange);

 for (PageRangeItem item : iterable) {
     System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(),
         item.getRange().getLength(), item.isClear());
 }

Parameters:

blobRange - BlobRange

Returns:

A reactive response containing the information of the cleared pages.

listPageRanges

public PagedIterable listPageRanges(ListPageRangesOptions options, Duration timeout, Context context)

Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the Azure Docs.

Code Samples

ListPageRangesOptions options = new ListPageRangesOptions(new BlobRange(offset))
     .setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId))
     .setMaxResultsPerPage(1000);

 Context context = new Context(key, value);

 PagedIterable<PageRangeItem> iter = client
     .listPageRanges(options, timeout, context);

 System.out.println("Valid Page Ranges are:");
 for (PageRangeItem item : iter) {
     System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(),
         item.getRange().getLength(), item.isClear());
 }

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A reactive response emitting all the page ranges.

listPageRangesDiff

public PagedIterable listPageRangesDiff(BlobRange blobRange, String prevSnapshot)

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more information, see the Azure Docs.

Code Samples

BlobRange blobRange = new BlobRange(offset);
 String prevSnapshot = "previous snapshot";
 PagedIterable<PageRangeItem> iterable = client.listPageRangesDiff(blobRange, prevSnapshot);

 for (PageRangeItem item : iterable) {
     System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(),
         item.getRange().getLength(), item.isClear());
 }

Parameters:

blobRange - BlobRange
prevSnapshot - Specifies that the response will contain only pages that were changed between target blob and previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by prevsnapshot is the older of the two.

Returns:

A reactive response emitting all the different page ranges.

listPageRangesDiff

public PagedIterable listPageRangesDiff(ListPageRangesDiffOptions options, Duration timeout, Context context)

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more information, see the Azure Docs.

Code Samples

ListPageRangesDiffOptions options = new ListPageRangesDiffOptions(new BlobRange(offset), "previous snapshot")
     .setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId))
     .setMaxResultsPerPage(1000);

 Context context = new Context(key, value);

 PagedIterable<PageRangeItem> iter = client
     .listPageRangesDiff(options, timeout, context);

 System.out.println("Valid Page Ranges are:");
 for (PageRangeItem item : iter) {
     System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(),
         item.getRange().getLength(), item.isClear());
 }

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A reactive response emitting all the different page ranges.

resize

public PageBlobItem resize(long size)

Resizes the page blob to the specified size (which must be a multiple of 512). For more information, see the Azure Docs.

Code Samples

PageBlobItem pageBlob = client.resize(size);
 System.out.printf("Page blob resized with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

size - Resizes a page blob to the specified size. If the specified value is less than the current size of the blob, then all pages above the specified value are cleared.

Returns:

The resized page blob.

resizeWithResponse

public Response resizeWithResponse(long size, BlobRequestConditions requestConditions, Duration timeout, Context context)

Resizes the page blob to the specified size (which must be a multiple of 512). For more information, see the Azure Docs.

Code Samples

BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 Context context = new Context(key, value);

 PageBlobItem pageBlob = client
     .resizeWithResponse(size, blobRequestConditions, timeout, context).getValue();
 System.out.printf("Page blob resized with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

size - Resizes a page blob to the specified size. If the specified value is less than the current size of the blob, then all pages above the specified value are cleared.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The resized page blob.

updateSequenceNumber

public PageBlobItem updateSequenceNumber(SequenceNumberActionType action, Long sequenceNumber)

Sets the page blob's sequence number. For more information, see the Azure Docs.

Code Samples

PageBlobItem pageBlob = client.updateSequenceNumber(SequenceNumberActionType.INCREMENT, size);

 System.out.printf("Page blob updated to sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

action - Indicates how the service should modify the blob's sequence number.
sequenceNumber - The blob's sequence number. The sequence number is a user-controlled property that you can use to track requests and manage concurrency issues.

Returns:

The updated page blob.

updateSequenceNumberWithResponse

public Response updateSequenceNumberWithResponse(SequenceNumberActionType action, Long sequenceNumber, BlobRequestConditions requestConditions, Duration timeout, Context context)

Sets the page blob's sequence number. For more information, see the Azure Docs.

Code Samples

BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 Context context = new Context(key, value);

 PageBlobItem pageBlob = client.updateSequenceNumberWithResponse(
     SequenceNumberActionType.INCREMENT, size, blobRequestConditions, timeout, context).getValue();

 System.out.printf("Page blob updated to sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

action - Indicates how the service should modify the blob's sequence number.
sequenceNumber - The blob's sequence number. The sequence number is a user-controlled property that you can use to track requests and manage concurrency issues.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The updated page blob.

uploadPages

public PageBlobItem uploadPages(PageRange pageRange, InputStream body)

Writes one or more pages to the page blob. The write size must be a multiple of 512. For more information, see the Azure Docs.

Note that the data passed must be replayable if retries are enabled (the default). In other words, the Flux must produce the same data each time it is subscribed to.

Code Samples

PageRange pageRange = new PageRange()
     .setStart(0)
     .setEnd(511);
 InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));

 PageBlobItem pageBlob = client.uploadPages(pageRange, dataStream);
 System.out.printf("Uploaded page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

pageRange - A PageRange object. Given that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges are 0-511, 512-1023, etc.
body - The data to upload. The data must be markable. This is in order to support retries. If the data is not markable, consider using getBlobOutputStream(PageRange pageRange) and writing to the returned OutputStream. Alternatively, consider wrapping your data source in a BufferedInputStream to add mark support.

Returns:

The information of the uploaded pages.

uploadPagesFromUrl

public PageBlobItem uploadPagesFromUrl(PageRange range, String sourceUrl, Long sourceOffset)

Writes one or more pages from the source page blob to this page blob. The write size must be a multiple of 512. For more information, see the Azure Docs.

Code Samples

PageRange pageRange = new PageRange()
     .setStart(0)
     .setEnd(511);

 PageBlobItem pageBlob = client.uploadPagesFromUrl(pageRange, url, sourceOffset);

 System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

range - A PageRange object. Given that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges are 0-511, 512-1023, etc.
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.
sourceOffset - The source offset to copy from. Pass null or 0 to copy from the beginning of source page blob.

Returns:

The information of the uploaded pages.

uploadPagesFromUrlWithResponse

public Response uploadPagesFromUrlWithResponse(PageRange range, String sourceUrl, Long sourceOffset, byte[] sourceContentMd5, PageBlobRequestConditions destRequestConditions, BlobRequestConditions sourceRequestConditions, Duration timeout, Context context)

Writes one or more pages from the source page blob to this page blob. The write size must be a multiple of 512. For more information, see the Azure Docs.

Code Samples

PageRange pageRange = new PageRange()
     .setStart(0)
     .setEnd(511);
 InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
 byte[] sourceContentMD5 = new byte[512];
 PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
 BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
 Context context = new Context(key, value);

 PageBlobItem pageBlob = client
     .uploadPagesFromUrlWithResponse(pageRange, url, sourceOffset, sourceContentMD5, pageBlobRequestConditions,
         sourceRequestConditions, timeout, context).getValue();

 System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

range - The destination PageRange range. Given that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges are 0-511, 512-1023, etc.
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.
sourceOffset - The source offset to copy from. Pass null or 0 to copy from the beginning of source blob.
sourceContentMd5 - An MD5 hash of the block content from the source blob. If specified, the service will calculate the MD5 of the received data and fail the request if it does not match the provided MD5.
destRequestConditions - PageBlobRequestConditions
sourceRequestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The information of the uploaded pages.

uploadPagesFromUrlWithResponse

public Response uploadPagesFromUrlWithResponse(PageBlobUploadPagesFromUrlOptions options, Duration timeout, Context context)

Writes one or more pages from the source page blob to this page blob. The write size must be a multiple of 512. For more information, see the Azure Docs.

Code Samples

PageRange pageRange = new PageRange()
     .setStart(0)
     .setEnd(511);
 InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
 byte[] sourceContentMD5 = new byte[512];
 PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
 BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
 Context context = new Context(key, value);

 PageBlobItem pageBlob = client
     .uploadPagesFromUrlWithResponse(new PageBlobUploadPagesFromUrlOptions(pageRange, url)
         .setSourceOffset(sourceOffset).setSourceContentMd5(sourceContentMD5)
         .setDestinationRequestConditions(pageBlobRequestConditions)
         .setSourceRequestConditions(sourceRequestConditions), timeout, context).getValue();

 System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

options - Parameters for the operation.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The information of the uploaded pages.

uploadPagesWithResponse

public Response uploadPagesWithResponse(PageRange pageRange, InputStream body, byte[] contentMd5, PageBlobRequestConditions pageBlobRequestConditions, Duration timeout, Context context)

Writes one or more pages to the page blob. The write size must be a multiple of 512. For more information, see the Azure Docs.

Note that the data passed must be replayable if retries are enabled (the default). In other words, the Flux must produce the same data each time it is subscribed to.

Code Samples

byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
 PageRange pageRange = new PageRange()
     .setStart(0)
     .setEnd(511);
 InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
 PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
 Context context = new Context(key, value);

 PageBlobItem pageBlob = client
     .uploadPagesWithResponse(pageRange, dataStream, md5, pageBlobRequestConditions, timeout, context).getValue();

 System.out.printf("Uploaded page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());

Parameters:

pageRange - A PageRange object. Given that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges are 0-511, 512-1023, etc.
body - The data to upload. The data must be markable. This is in order to support retries. If the data is not markable, consider using getBlobOutputStream(PageRange pageRange) and writing to the returned OutputStream. Alternatively, consider wrapping your data source in a BufferedInputStream to add mark support.
contentMd5 - An MD5 hash of the page content. This hash is used to verify the integrity of the page during transport. When this header is specified, the storage service compares the hash of the content that has arrived with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the operation will fail.
pageBlobRequestConditions - PageBlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The information of the uploaded pages.

Applies to