public final class PageBlobAsyncClient extends BlobAsyncClientBase
SpecializedBlobClientBuilder
or via the method
BlobAsyncClient.getPageBlobAsyncClient()
. 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.
Note this client is an async client that returns reactive responses from Spring Reactor Core project
(https://projectreactor.io/). Calling the methods in this client will NOT start the actual network
operation, until .subscribe()
is called on the reactive response. You can simply convert one of these
responses to a CompletableFuture
object through Mono.toFuture()
.
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.
|
accountName, azureBlobStorage, blobName, containerName, serviceVersion
Modifier and Type | Method and Description |
---|---|
Mono<PageBlobItem> |
clearPages(PageRange pageRange)
Frees the specified pages from the page blob.
|
Mono<Response<PageBlobItem>> |
clearPagesWithResponse(PageRange pageRange,
PageBlobRequestConditions pageBlobRequestConditions)
Frees the specified pages from the page blob.
|
Mono<CopyStatusType> |
copyIncremental(String source,
String snapshot)
Begins an operation to start an incremental copy from one page blob's snapshot to this page blob.
|
Mono<Response<CopyStatusType>> |
copyIncrementalWithResponse(String source,
String snapshot,
RequestConditions modifiedAccessConditions)
Begins an operation to start an incremental copy from one page blob's snapshot to this page blob.
|
Mono<PageBlobItem> |
create(long size)
Creates a page blob of the specified length.
|
Mono<PageBlobItem> |
create(long size,
boolean overwrite)
Creates a page blob of the specified length.
|
Mono<Response<PageBlobItem>> |
createWithResponse(long size,
Long sequenceNumber,
BlobHttpHeaders headers,
Map<String,String> metadata,
BlobRequestConditions accessConditions)
Creates a page blob of the specified length.
|
Mono<PageList> |
getPageRanges(BlobRange blobRange)
Returns the list of valid page ranges for a page blob or snapshot of a page blob.
|
Mono<PageList> |
getPageRangesDiff(BlobRange blobRange,
String prevSnapshot)
Gets the collection of page ranges that differ between a specified snapshot and this page blob.
|
Mono<Response<PageList>> |
getPageRangesDiffWithResponse(BlobRange blobRange,
String prevSnapshot,
BlobRequestConditions accessConditions)
Gets the collection of page ranges that differ between a specified snapshot and this page blob.
|
Mono<Response<PageList>> |
getPageRangesWithResponse(BlobRange blobRange,
BlobRequestConditions accessConditions)
Returns the list of valid page ranges for a page blob or snapshot of a page blob.
|
Mono<PageBlobItem> |
resize(long size)
Resizes the page blob to the specified size (which must be a multiple of 512).
|
Mono<Response<PageBlobItem>> |
resizeWithResponse(long size,
BlobRequestConditions accessConditions)
Resizes the page blob to the specified size (which must be a multiple of 512).
|
Mono<PageBlobItem> |
updateSequenceNumber(SequenceNumberActionType action,
Long sequenceNumber)
Sets the page blob's sequence number.
|
Mono<Response<PageBlobItem>> |
updateSequenceNumberWithResponse(SequenceNumberActionType action,
Long sequenceNumber,
BlobRequestConditions accessConditions)
Sets the page blob's sequence number.
|
Mono<PageBlobItem> |
uploadPages(PageRange pageRange,
Flux<ByteBuffer> body)
Writes one or more pages to the page blob.
|
Mono<PageBlobItem> |
uploadPagesFromUrl(PageRange range,
String sourceUrl,
Long sourceOffset)
Writes one or more pages from the source page blob to this page blob.
|
Mono<Response<PageBlobItem>> |
uploadPagesFromUrlWithResponse(PageRange range,
String sourceUrl,
Long sourceOffset,
byte[] sourceContentMd5,
PageBlobRequestConditions destAccessConditions,
BlobRequestConditions sourceRequestConditions)
Writes one or more pages from the source page blob to this page blob.
|
Mono<Response<PageBlobItem>> |
uploadPagesWithResponse(PageRange pageRange,
Flux<ByteBuffer> body,
byte[] contentMd5,
PageBlobRequestConditions pageBlobRequestConditions)
Writes one or more pages to the page blob.
|
abortCopyFromUrl, abortCopyFromUrlWithResponse, beginCopy, beginCopy, copyFromUrl, copyFromUrlWithResponse, createSnapshot, createSnapshotWithResponse, delete, deleteWithResponse, download, downloadToFile, downloadToFileWithResponse, downloadWithResponse, exists, existsWithResponse, getAccountInfo, getAccountInfoWithResponse, getAccountName, getBlobName, getBlobUrl, getContainerName, getCustomerProvidedKey, getHttpPipeline, getProperties, getPropertiesWithResponse, getServiceVersion, getSnapshotClient, getSnapshotId, isSnapshot, setAccessTier, setAccessTierWithResponse, setHttpHeaders, setHttpHeadersWithResponse, setMetadata, setMetadataWithResponse, undelete, undeleteWithResponse
public static final int PAGE_BYTES
public static final int MAX_PUT_PAGES_BYTES
public Mono<PageBlobItem> create(long size)
Code Samples
client.create(size).subscribe(response -> System
.out.printf(
"Created page blob with sequence number %s%n", response.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 Mono<PageBlobItem> create(long size, boolean overwrite)
Code Samples
boolean overwrite = false; // Default behavior
client.create(size, overwrite).subscribe(response -> System
.out.printf(
"Created page blob with sequence number %s%n", response.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 Mono<Response<PageBlobItem>> createWithResponse(long size, Long sequenceNumber, BlobHttpHeaders headers, Map<String,String> metadata, BlobRequestConditions accessConditions)
Code Samples
BlobHttpHeaders
headers = newBlobHttpHeaders
() .setContentLanguage("en-US") .setContentType("binary");BlobRequestConditions
blobRequestConditions = newBlobRequestConditions
().setLeaseId(leaseId); client.createWithResponse(size, sequenceNumber, headers, metadata, blobRequestConditions) .subscribe(response ->System
.out.printf( "Created page blob with sequence number %s%n", response.getValue().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
- BlobHttpHeaders
metadata
- Metadata to associate with the blob.accessConditions
- BlobRequestConditions
IllegalArgumentException
- If size
isn't a multiple of PageBlobAsyncClient.PAGE_BYTES
or
sequenceNumber
isn't null and is less than 0.public Mono<PageBlobItem> uploadPages(PageRange pageRange, Flux<ByteBuffer> 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
PageRange
pageRange = newPageRange
() .setStart(0) .setEnd(511); client.uploadPages(pageRange, body).subscribe(response ->System
.out.printf( "Uploaded page blob with sequence number %s%n", response.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. Note that this Flux
must be replayable if retries are enabled (the
default). In other words, the Flowable must produce the same data each time it is subscribed to.public Mono<Response<PageBlobItem>> uploadPagesWithResponse(PageRange pageRange, Flux<ByteBuffer> body, byte[] contentMd5, PageBlobRequestConditions pageBlobRequestConditions)
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 = newPageRange
() .setStart(0) .setEnd(511); byte[] md5 =MessageDigest
.getInstance("MD5").digest("data".getBytes(StandardCharsets
.UTF_8));PageBlobRequestConditions
pageBlobRequestConditions = newPageBlobRequestConditions
().setLeaseId(leaseId); client.uploadPagesWithResponse(pageRange, body, md5, pageBlobRequestConditions) .subscribe(response ->System
.out.printf( "Uploaded page blob with sequence number %s%n", response.getValue().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. Note that this Flux
must be replayable if retries are enabled (the
default). In other words, the Flowable must produce the same data each time it is subscribed to.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
IllegalArgumentException
- If pageRange
is null
public Mono<PageBlobItem> uploadPagesFromUrl(PageRange range, String sourceUrl, Long sourceOffset)
Code Samples
PageRange
pageRange = newPageRange
() .setStart(0) .setEnd(511); client.uploadPagesFromUrl(pageRange, url, sourceOffset) .subscribe(response ->System
.out.printf( "Uploaded page blob from URL with sequence number %s%n", response.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.public Mono<Response<PageBlobItem>> uploadPagesFromUrlWithResponse(PageRange range, String sourceUrl, Long sourceOffset, byte[] sourceContentMd5, PageBlobRequestConditions destAccessConditions, BlobRequestConditions sourceRequestConditions)
Code Samples
PageRange
pageRange = newPageRange
() .setStart(0) .setEnd(511);InputStream
dataStream = newByteArrayInputStream
(data.getBytes(StandardCharsets
.UTF_8)); byte[] sourceContentMD5 = new byte[512];PageBlobRequestConditions
pageBlobRequestConditions = newPageBlobRequestConditions
().setLeaseId(leaseId);BlobRequestConditions
sourceAccessConditions = newBlobRequestConditions
() .setIfUnmodifiedSince(OffsetDateTime
.now().minusDays(3)); client.uploadPagesFromUrlWithResponse(pageRange, url, sourceOffset, sourceContentMD5, pageBlobRequestConditions, sourceAccessConditions) .subscribe(response ->System
.out.printf( "Uploaded page blob from URL with sequence number %s%n", response.getValue().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 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.destAccessConditions
- PageBlobRequestConditions
sourceRequestConditions
- BlobRequestConditions
IllegalArgumentException
- If range
is null
public Mono<PageBlobItem> clearPages(PageRange pageRange)
Code Samples
PageRange
pageRange = newPageRange
() .setStart(0) .setEnd(511); client.clearPages(pageRange).subscribe(response ->System
.out.printf( "Cleared page blob with sequence number %s%n", response.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 Mono<Response<PageBlobItem>> clearPagesWithResponse(PageRange pageRange, PageBlobRequestConditions pageBlobRequestConditions)
Code Samples
PageRange
pageRange = newPageRange
() .setStart(0) .setEnd(511);PageBlobRequestConditions
pageBlobRequestConditions = newPageBlobRequestConditions
().setLeaseId(leaseId); client.clearPagesWithResponse(pageRange, pageBlobRequestConditions) .subscribe(response ->System
.out.printf( "Cleared page blob with sequence number %s%n", response.getValue().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.pageBlobRequestConditions
- PageBlobRequestConditions
IllegalArgumentException
- If pageRange
is null
public Mono<PageList> getPageRanges(BlobRange blobRange)
Code Samples
BlobRange
blobRange = newBlobRange
(offset); client.getPageRanges(blobRange).subscribe(response -> {System
.out.println("Valid Page Ranges are:"); for (PageRange
pageRange : response.getPageRange()) {System
.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); } });
blobRange
- BlobRange
public Mono<Response<PageList>> getPageRangesWithResponse(BlobRange blobRange, BlobRequestConditions accessConditions)
Code Samples
BlobRange
blobRange = newBlobRange
(offset);BlobRequestConditions
blobRequestConditions = newBlobRequestConditions
().setLeaseId(leaseId); client.getPageRangesWithResponse(blobRange, blobRequestConditions) .subscribe(response -> {System
.out.println("Valid Page Ranges are:"); for (PageRange
pageRange : response.getValue().getPageRange()) {System
.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); } });
blobRange
- BlobRange
accessConditions
- BlobRequestConditions
public Mono<PageList> getPageRangesDiff(BlobRange blobRange, String prevSnapshot)
Code Samples
BlobRange
blobRange = newBlobRange
(offset); finalString
prevSnapshot = "previous snapshot"; client.getPageRangesDiff(blobRange, prevSnapshot).subscribe(response -> {System
.out.println("Valid Page Ranges are:"); for (PageRange
pageRange : response.getPageRange()) {System
.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); } });
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.public Mono<Response<PageList>> getPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshot, BlobRequestConditions accessConditions)
Code Samples
BlobRange
blobRange = newBlobRange
(offset); finalString
prevSnapshot = "previous snapshot";BlobRequestConditions
blobRequestConditions = newBlobRequestConditions
().setLeaseId(leaseId); client.getPageRangesDiffWithResponse(blobRange, prevSnapshot, blobRequestConditions) .subscribe(response -> {System
.out.println("Valid Page Ranges are:"); for (PageRange
pageRange : response.getValue().getPageRange()) {System
.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); } });
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.accessConditions
- BlobRequestConditions
IllegalArgumentException
- If prevSnapshot
is null
public Mono<PageBlobItem> resize(long size)
Code Samples
client.resize(size).subscribe(response -> System
.out.printf(
"Page blob resized with sequence number %s%n", response.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 Mono<Response<PageBlobItem>> resizeWithResponse(long size, BlobRequestConditions accessConditions)
Code Samples
BlobRequestConditions
blobRequestConditions = newBlobRequestConditions
().setLeaseId(leaseId); client.resizeWithResponse(size, blobRequestConditions) .subscribe(response ->System
.out.printf( "Page blob resized with sequence number %s%n", response.getValue().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.accessConditions
- BlobRequestConditions
IllegalArgumentException
- If size
isn't a multiple of PageBlobAsyncClient.PAGE_BYTES
public Mono<PageBlobItem> updateSequenceNumber(SequenceNumberActionType action, Long sequenceNumber)
Code Samples
client.updateSequenceNumber(SequenceNumberActionType
.INCREMENT, size) .subscribe(response ->System
.out.printf( "Page blob updated to sequence number %s%n", response.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 Mono<Response<PageBlobItem>> updateSequenceNumberWithResponse(SequenceNumberActionType action, Long sequenceNumber, BlobRequestConditions accessConditions)
Code Samples
BlobRequestConditions
blobRequestConditions = newBlobRequestConditions
().setLeaseId(leaseId); client.updateSequenceNumberWithResponse(SequenceNumberActionType
.INCREMENT, size, blobRequestConditions) .subscribe(response ->System
.out.printf( "Page blob updated to sequence number %s%n", response.getValue().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.accessConditions
- BlobRequestConditions
IllegalArgumentException
- If sequenceNumber
isn't null and is less than 0public Mono<CopyStatusType> copyIncremental(String source, String snapshot)
Code Samples
finalString
snapshot = "copy snapshot"; client.copyIncremental(url, snapshot).subscribe(response -> { if (CopyStatusType
.SUCCESS == response) {System
.out.println("Page blob copied successfully"); } else if (CopyStatusType
.FAILED == response) {System
.out.println("Page blob copied failed"); } else if (CopyStatusType
.ABORTED == response) {System
.out.println("Page blob copied aborted"); } else if (CopyStatusType
.PENDING == response) {System
.out.println("Page blob copied pending"); } });
source
- The source page blob.snapshot
- The snapshot on the copy source.public Mono<Response<CopyStatusType>> copyIncrementalWithResponse(String source, String snapshot, RequestConditions modifiedAccessConditions)
Code Samples
finalString
snapshot = "copy snapshot";RequestConditions
modifiedAccessConditions = newRequestConditions
() .setIfNoneMatch("snapshotMatch"); client.copyIncrementalWithResponse(url, snapshot, modifiedAccessConditions) .subscribe(response -> {CopyStatusType
statusType = response.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.modifiedAccessConditions
- 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.IllegalStateException
- If source
and snapshot
form a malformed URL.Copyright © 2019 Microsoft Corporation. All rights reserved.