public final class PageBlobClient extends BlobClientBase
SpecializedBlobClientBuilder or via the method
BlobClient.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.
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_PUT_PAGES_BYTES
Indicates the maximum number of bytes that may be sent in a call to putPage.
|
static int |
PAGE_BYTES
Indicates the number of bytes in a page.
|
| Modifier and Type | Method and Description |
|---|---|
PageBlobItem |
clearPages(PageRange pageRange)
Frees the specified pages from the page blob.
|
com.azure.core.http.rest.Response<PageBlobItem> |
clearPagesWithResponse(PageRange pageRange,
PageBlobRequestConditions pageBlobRequestConditions,
Duration timeout,
com.azure.core.util.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.
|
com.azure.core.http.rest.Response<CopyStatusType> |
copyIncrementalWithResponse(String source,
String snapshot,
com.azure.core.http.RequestConditions modifiedRequestConditions,
Duration timeout,
com.azure.core.util.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.
|
com.azure.core.http.rest.Response<PageBlobItem> |
createWithResponse(long size,
Long sequenceNumber,
BlobHttpHeaders headers,
Map<String,String> metadata,
BlobRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.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.
|
PageList |
getPageRanges(BlobRange blobRange)
Returns the list of valid page ranges for a page blob or snapshot of a page blob.
|
PageList |
getPageRangesDiff(BlobRange blobRange,
String prevSnapshot)
Gets the collection of page ranges that differ between a specified snapshot and this page blob.
|
com.azure.core.http.rest.Response<PageList> |
getPageRangesDiffWithResponse(BlobRange blobRange,
String prevSnapshot,
BlobRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Gets the collection of page ranges that differ between a specified snapshot and this page blob.
|
com.azure.core.http.rest.Response<PageList> |
getPageRangesWithResponse(BlobRange blobRange,
BlobRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Returns the list of valid page ranges for a page blob or snapshot of a page blob.
|
PageBlobItem |
resize(long size)
Resizes the page blob to the specified size (which must be a multiple of 512).
|
com.azure.core.http.rest.Response<PageBlobItem> |
resizeWithResponse(long size,
BlobRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.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.
|
com.azure.core.http.rest.Response<PageBlobItem> |
updateSequenceNumberWithResponse(SequenceNumberActionType action,
Long sequenceNumber,
BlobRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.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.
|
com.azure.core.http.rest.Response<PageBlobItem> |
uploadPagesFromUrlWithResponse(PageRange range,
String sourceUrl,
Long sourceOffset,
byte[] sourceContentMd5,
PageBlobRequestConditions destRequestConditions,
BlobRequestConditions sourceRequestConditions,
Duration timeout,
com.azure.core.util.Context context)
Writes one or more pages from the source page blob to this page blob.
|
com.azure.core.http.rest.Response<PageBlobItem> |
uploadPagesWithResponse(PageRange pageRange,
InputStream body,
byte[] contentMd5,
PageBlobRequestConditions pageBlobRequestConditions,
Duration timeout,
com.azure.core.util.Context context)
Writes one or more pages to the page blob.
|
abortCopyFromUrl, abortCopyFromUrlWithResponse, beginCopy, beginCopy, copyFromUrl, copyFromUrlWithResponse, createSnapshot, createSnapshotWithResponse, delete, deleteWithResponse, download, downloadToFile, downloadToFile, downloadToFileWithResponse, downloadToFileWithResponse, downloadWithResponse, exists, existsWithResponse, generateSas, generateUserDelegationSas, getAccountInfo, getAccountInfoWithResponse, getAccountName, getBlobName, getBlobUrl, getContainerName, getCustomerProvidedKey, getHttpPipeline, getProperties, getPropertiesWithResponse, getServiceVersion, getSnapshotClient, getSnapshotId, isSnapshot, openInputStream, openInputStream, setAccessTier, setAccessTierWithResponse, setHttpHeaders, setHttpHeadersWithResponse, setMetadata, setMetadataWithResponse, undelete, undeleteWithResponsepublic static final int PAGE_BYTES
public static final int MAX_PUT_PAGES_BYTES
public BlobOutputStream getBlobOutputStream(PageRange pageRange)
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.BlobOutputStream object used to write data to the blob.BlobStorageException - If a storage service error occurred.public BlobOutputStream getBlobOutputStream(PageRange pageRange, BlobRequestConditions requestConditions)
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.BlobOutputStream object used to write data to the blob.BlobStorageException - If a storage service error occurred.public PageBlobItem create(long size)
Code Samples
PageBlobItempageBlob = client.create(size);System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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.public PageBlobItem create(long size, boolean overwrite)
Code Samples
boolean overwrite = false; // Default valuePageBlobItempageBlob = client.create(size, overwrite);System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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.public com.azure.core.http.rest.Response<PageBlobItem> createWithResponse(long size, Long sequenceNumber, BlobHttpHeaders headers, Map<String,String> metadata, BlobRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
To avoid overwriting, pass "*" to BlobRequestConditions.setIfNoneMatch(String).
Code Samples
BlobHttpHeadersheaders = newBlobHttpHeaders() .setContentLanguage("en-US") .setContentType("binary");BlobRequestConditionsblobRequestConditions = newBlobRequestConditions().setLeaseId(leaseId);Contextcontext = newContext(key, value);PageBlobItempageBlob = client .createWithResponse(size, sequenceNumber, headers, metadata, blobRequestConditions, timeout, context) .getValue();System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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 - BlobHttpHeadersmetadata - Metadata to associate with the blob.requestConditions - BlobRequestConditionstimeout - 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.public PageBlobItem uploadPages(PageRange pageRange, InputStream body)
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
PageRangepageRange = newPageRange() .setStart(0) .setEnd(511);InputStreamdataStream = newByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));PageBlobItempageBlob = client.uploadPages(pageRange, dataStream);System.out.printf("Uploaded page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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.public com.azure.core.http.rest.Response<PageBlobItem> uploadPagesWithResponse(PageRange pageRange, InputStream body, byte[] contentMd5, PageBlobRequestConditions pageBlobRequestConditions, Duration timeout, com.azure.core.util.Context context)
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));PageRangepageRange = newPageRange() .setStart(0) .setEnd(511);InputStreamdataStream = newByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));PageBlobRequestConditionspageBlobRequestConditions = newPageBlobRequestConditions().setLeaseId(leaseId);Contextcontext = newContext(key, value);PageBlobItempageBlob = client .uploadPagesWithResponse(pageRange, dataStream, md5, pageBlobRequestConditions, timeout, context).getValue();System.out.printf("Uploaded page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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.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 - PageBlobRequestConditionstimeout - 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.com.azure.core.exception.UnexpectedLengthException - when the length of data does not match the input length.NullPointerException - if the input data is null.public PageBlobItem uploadPagesFromUrl(PageRange range, String sourceUrl, Long sourceOffset)
Code Samples
PageRangepageRange = newPageRange() .setStart(0) .setEnd(511);PageBlobItempageBlob = client.uploadPagesFromUrl(pageRange, url, sourceOffset);System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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.IllegalArgumentException - If sourceUrl is a malformed URL.public com.azure.core.http.rest.Response<PageBlobItem> uploadPagesFromUrlWithResponse(PageRange range, String sourceUrl, Long sourceOffset, byte[] sourceContentMd5, PageBlobRequestConditions destRequestConditions, BlobRequestConditions sourceRequestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
PageRangepageRange = newPageRange() .setStart(0) .setEnd(511);InputStreamdataStream = newByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); byte[] sourceContentMD5 = new byte[512];PageBlobRequestConditionspageBlobRequestConditions = newPageBlobRequestConditions().setLeaseId(leaseId);BlobRequestConditionssourceRequestConditions = newBlobRequestConditions() .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));Contextcontext = newContext(key, value);PageBlobItempageBlob = 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());
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 - PageBlobRequestConditionssourceRequestConditions - BlobRequestConditionstimeout - 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.IllegalArgumentException - If sourceUrl is a malformed URL.public PageBlobItem clearPages(PageRange pageRange)
Code Samples
PageRangepageRange = newPageRange() .setStart(0) .setEnd(511);PageBlobItempageBlob = client.clearPages(pageRange);System.out.printf("Cleared page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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.public com.azure.core.http.rest.Response<PageBlobItem> clearPagesWithResponse(PageRange pageRange, PageBlobRequestConditions pageBlobRequestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
PageRangepageRange = newPageRange() .setStart(0) .setEnd(511);PageBlobRequestConditionspageBlobRequestConditions = newPageBlobRequestConditions().setLeaseId(leaseId);Contextcontext = newContext(key, value);PageBlobItempageBlob = client .clearPagesWithResponse(pageRange, pageBlobRequestConditions, timeout, context).getValue();System.out.printf("Cleared page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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.timeout - An optional timeout value beyond which a RuntimeException will be raised.pageBlobRequestConditions - PageBlobRequestConditionscontext - Additional context that is passed through the Http pipeline during the service call.public PageList getPageRanges(BlobRange blobRange)
Code Samples
BlobRangeblobRange = newBlobRange(offset);PageListpageList = client.getPageRanges(blobRange);System.out.println("Valid Page Ranges are:"); for (PageRangepageRange : pageList.getPageRange()) {System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); }
blobRange - BlobRangepublic com.azure.core.http.rest.Response<PageList> getPageRangesWithResponse(BlobRange blobRange, BlobRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
BlobRangeblobRange = newBlobRange(offset);BlobRequestConditionsblobRequestConditions = newBlobRequestConditions().setLeaseId(leaseId);Contextcontext = newContext(key, value);PageListpageList = client .getPageRangesWithResponse(blobRange, blobRequestConditions, timeout, context).getValue();System.out.println("Valid Page Ranges are:"); for (PageRangepageRange : pageList.getPageRange()) {System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); }
blobRange - BlobRangerequestConditions - BlobRequestConditionstimeout - 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.public PageList getPageRangesDiff(BlobRange blobRange, String prevSnapshot)
Code Samples
BlobRangeblobRange = newBlobRange(offset); finalStringprevSnapshot = "previous snapshot";PageListpageList = client.getPageRangesDiff(blobRange, prevSnapshot);System.out.println("Valid Page Ranges are:"); for (PageRangepageRange : pageList.getPageRange()) {System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); }
blobRange - BlobRangeprevSnapshot - 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.public com.azure.core.http.rest.Response<PageList> getPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshot, BlobRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
BlobRangeblobRange = newBlobRange(offset); finalStringprevSnapshot = "previous snapshot";BlobRequestConditionsblobRequestConditions = newBlobRequestConditions().setLeaseId(leaseId);Contextcontext = newContext(key, value);PageListpageList = client .getPageRangesDiffWithResponse(blobRange, prevSnapshot, blobRequestConditions, timeout, context).getValue();System.out.println("Valid Page Ranges are:"); for (PageRangepageRange : pageList.getPageRange()) {System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); }
blobRange - BlobRangeprevSnapshot - 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 - BlobRequestConditionstimeout - 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.public PageBlobItem resize(long size)
Code Samples
PageBlobItempageBlob = client.resize(size);System.out.printf("Page blob resized with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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.public com.azure.core.http.rest.Response<PageBlobItem> resizeWithResponse(long size, BlobRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
BlobRequestConditionsblobRequestConditions = newBlobRequestConditions().setLeaseId(leaseId);Contextcontext = newContext(key, value);PageBlobItempageBlob = client .resizeWithResponse(size, blobRequestConditions, timeout, context).getValue();System.out.printf("Page blob resized with sequence number %s%n", pageBlob.getBlobSequenceNumber());
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 - BlobRequestConditionstimeout - 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.public PageBlobItem updateSequenceNumber(SequenceNumberActionType action, Long sequenceNumber)
Code Samples
PageBlobItempageBlob = client.updateSequenceNumber(SequenceNumberActionType.INCREMENT, size);System.out.printf("Page blob updated to sequence number %s%n", pageBlob.getBlobSequenceNumber());
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.public com.azure.core.http.rest.Response<PageBlobItem> updateSequenceNumberWithResponse(SequenceNumberActionType action, Long sequenceNumber, BlobRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
BlobRequestConditionsblobRequestConditions = newBlobRequestConditions().setLeaseId(leaseId);Contextcontext = newContext(key, value);PageBlobItempageBlob = client.updateSequenceNumberWithResponse(SequenceNumberActionType.INCREMENT, size, blobRequestConditions, timeout, context).getValue();System.out.printf("Page blob updated to sequence number %s%n", pageBlob.getBlobSequenceNumber());
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 - BlobRequestConditionstimeout - 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.public CopyStatusType copyIncremental(String source, String snapshot)
Code Samples
finalStringsnapshot = "copy snapshot";CopyStatusTypestatusType = client.copyIncremental(url, snapshot); if (CopyStatusType.SUCCESS == statusType) {System.out.println("Page blob copied successfully"); } else if (CopyStatusType.FAILED == statusType) {System.out.println("Page blob copied failed"); } else if (CopyStatusType.ABORTED == statusType) {System.out.println("Page blob copied aborted"); } else if (CopyStatusType.PENDING == statusType) {System.out.println("Page blob copied pending"); }
source - The source page blob.snapshot - The snapshot on the copy source.IllegalArgumentException - If source is a malformed URL.public com.azure.core.http.rest.Response<CopyStatusType> copyIncrementalWithResponse(String source, String snapshot, com.azure.core.http.RequestConditions modifiedRequestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
finalStringsnapshot = "copy snapshot";RequestConditionsmodifiedRequestConditions = newRequestConditions() .setIfNoneMatch("snapshotMatch");Contextcontext = newContext(key, value);CopyStatusTypestatusType = client .copyIncrementalWithResponse(url, snapshot, modifiedRequestConditions, timeout, context).getValue(); if (CopyStatusType.SUCCESS == statusType) {System.out.println("Page blob copied successfully"); } else if (CopyStatusType.FAILED == statusType) {System.out.println("Page blob copied failed"); } else if (CopyStatusType.ABORTED == statusType) {System.out.println("Page blob copied aborted"); } else if (CopyStatusType.PENDING == statusType) {System.out.println("Page blob copied pending"); }
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.IllegalArgumentException - If source is a malformed URL.Copyright © 2020 Microsoft Corporation. All rights reserved.