PageBlobAsyncClient Class
- java.
lang. Object - com.
azure. storage. blob. specialized. BlobAsyncClientBase - com.
azure. storage. blob. specialized. PageBlobAsyncClient
- com.
- com.
public final class PageBlobAsyncClient
extends BlobAsyncClientBase
Client to a page blob. It may only be instantiated through a SpecializedBlobClientBuilder or via the method 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().
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 put |
static final int |
PAGE_BYTES
Indicates the number of bytes in a page. |
Method Summary
Methods inherited from BlobAsyncClientBase
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 Mono
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);
client.clearPages(pageRange).subscribe(response -> System.out.printf(
"Cleared page blob with sequence number %s%n", response.getBlobSequenceNumber()));
Parameters:
Returns:
clearPagesWithResponse
public Mono
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);
client.clearPagesWithResponse(pageRange, pageBlobRequestConditions)
.subscribe(response -> System.out.printf(
"Cleared page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
Parameters:
Returns:
copyIncremental
public Mono
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";
client.copyIncremental(url, snapshot).subscribe(statusType -> {
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:
Returns:
copyIncrementalWithResponse
public Mono
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");
client.copyIncrementalWithResponse(new PageBlobCopyIncrementalOptions(url, snapshot)
.setRequestConditions(destinationRequestConditions))
.subscribe(response -> {
CopyStatusType statusType = response.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:
Returns:
copyIncrementalWithResponse
public Mono
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");
client.copyIncrementalWithResponse(url, snapshot, modifiedRequestConditions)
.subscribe(response -> {
CopyStatusType statusType = response.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:
Returns:
create
public Mono
Creates a page blob of the specified length. By default, this method will not overwrite an existing blob. Call PutPage to upload data to a page blob. For more information, see the Azure Docs.
Code Samples
client.create(size).subscribe(response -> System.out.printf(
"Created page blob with sequence number %s%n", response.getBlobSequenceNumber()));
Parameters:
Returns:
create
public Mono
Creates a page blob of the specified length. Call PutPage to upload data to a page blob. For more information, see the Azure Docs.
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()));
Parameters:
Returns:
createIfNotExists
public Mono
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
client.createIfNotExists(size).subscribe(response ->
System.out.printf("Created page blob with sequence number %s%n", response.getBlobSequenceNumber()));
Parameters:
Returns:
createIfNotExistsWithResponse
public Mono
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");
client.createIfNotExistsWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber)
.setHeaders(headers).setMetadata(metadata).setTags(tags)).subscribe(response -> {
if (response.getStatusCode() == 409) {
System.out.println("Already exists.");
} else {
System.out.println("successfully created.");
}
});
Parameters:
Returns:
createWithResponse
public Mono
Creates a page blob of the specified length. Call PutPage to upload 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);
client.createWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber)
.setHeaders(headers).setMetadata(metadata).setTags(tags).setRequestConditions(blobRequestConditions))
.subscribe(response -> System.out.printf(
"Created page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
Parameters:
Returns:
createWithResponse
public Mono
Creates a page blob of the specified length. Call PutPage to upload 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);
client.createWithResponse(size, sequenceNumber, headers, metadata, blobRequestConditions)
.subscribe(response -> System.out.printf(
"Created page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
Parameters:
Returns:
getCustomerProvidedKeyAsyncClient
public PageBlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey)
Creates a new PageBlobAsyncClient with the specified customerProvidedKey
.
Overrides:
PageBlobAsyncClient.getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey)Parameters:
null
to use no customer provided key.
Returns:
customerProvidedKey
.getEncryptionScopeAsyncClient
public PageBlobAsyncClient getEncryptionScopeAsyncClient(String encryptionScope)
Creates a new PageBlobAsyncClient with the specified encryptionScope
.
Overrides:
PageBlobAsyncClient.getEncryptionScopeAsyncClient(String encryptionScope)Parameters:
null
to use no encryption scope.
Returns:
encryptionScope
.getManagedDiskPageRangesDiff
public Mono
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";
client.getPageRangesDiff(blobRange, prevSnapshotUrl).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());
}
});
Parameters:
Returns:
getManagedDiskPageRangesDiffWithResponse
public Mono
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);
client.getPageRangesDiffWithResponse(blobRange, prevSnapshotUrl, 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());
}
});
Parameters:
Returns:
getPageRanges
@Deprecated
public Mono
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);
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());
}
});
Parameters:
Returns:
getPageRangesDiff
@Deprecated
public Mono
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";
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());
}
});
Parameters:
Returns:
getPageRangesDiffWithResponse
@Deprecated
public Mono
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";
BlobRequestConditions blobRequestConditions = new BlobRequestConditions().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());
}
});
Parameters:
Returns:
getPageRangesWithResponse
@Deprecated
public Mono
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);
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());
}
});
Parameters:
Returns:
listPageRanges
public PagedFlux
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);
System.out.println("Valid Page Ranges are:");
client.listPageRanges(blobRange).subscribe(rangeItem -> System.out.printf("Offset: %s, Length: %s%n",
rangeItem.getRange().getOffset(), rangeItem.getRange().getLength()));
Parameters:
Returns:
listPageRanges
public PagedFlux
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))
.setMaxResultsPerPage(1000).setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId));
client.listPageRanges(options)
.subscribe(rangeItem -> System.out.printf("Offset: %s, Length: %s%n", rangeItem.getRange().getOffset(),
rangeItem.getRange().getLength()));
Parameters:
Returns:
listPageRangesDiff
public PagedFlux
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";
System.out.println("Valid Page Ranges are:");
client.listPageRangesDiff(blobRange, prevSnapshot).subscribe(rangeItem ->
System.out.printf("Offset: %s, Length: %s, isClear: %s%n",
rangeItem.getRange().getOffset(), rangeItem.getRange().getLength(), rangeItem.isClear()));
Parameters:
Returns:
listPageRangesDiff
public PagedFlux
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);
client.listPageRangesDiff(options)
.subscribe(rangeItem -> System.out.printf("Offset: %s, Length: %s, isClear: %s%n",
rangeItem.getRange().getOffset(), rangeItem.getRange().getLength(), rangeItem.isClear()));
Parameters:
Returns:
resize
public Mono
Resizes the page blob to the specified size (which must be a multiple of 512). For more information, see the Azure Docs.
Code Samples
client.resize(size).subscribe(response -> System.out.printf(
"Page blob resized with sequence number %s%n", response.getBlobSequenceNumber()));
Parameters:
Returns:
resizeWithResponse
public Mono
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);
client.resizeWithResponse(size, blobRequestConditions)
.subscribe(response -> System.out.printf(
"Page blob resized with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
Parameters:
Returns:
updateSequenceNumber
public Mono
Sets the page blob's sequence number. For more information, see the Azure Docs.
Code Samples
client.updateSequenceNumber(SequenceNumberActionType.INCREMENT, size)
.subscribe(response -> System.out.printf(
"Page blob updated to sequence number %s%n", response.getBlobSequenceNumber()));
Parameters:
Returns:
updateSequenceNumberWithResponse
public Mono
Sets the page blob's sequence number. For more information, see the Azure Docs.
Code Samples
BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
client.updateSequenceNumberWithResponse(SequenceNumberActionType.INCREMENT, size, blobRequestConditions)
.subscribe(response -> System.out.printf(
"Page blob updated to sequence number %s%n", response.getValue().getBlobSequenceNumber()));
Parameters:
Returns:
uploadPages
public Mono
Writes one or more pages to the page blob. 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);
client.uploadPages(pageRange, body).subscribe(response -> System.out.printf(
"Uploaded page blob with sequence number %s%n", response.getBlobSequenceNumber()));
Parameters:
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.
Returns:
uploadPagesFromUrl
public Mono
Writes one or more pages from the source page blob to this page blob. 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);
client.uploadPagesFromUrl(pageRange, url, sourceOffset)
.subscribe(response -> System.out.printf(
"Uploaded page blob from URL with sequence number %s%n", response.getBlobSequenceNumber()));
Parameters:
Returns:
uploadPagesFromUrlWithResponse
public Mono
Writes one or more pages from the source page blob to this page blob. 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));
client.uploadPagesFromUrlWithResponse(pageRange, url, sourceOffset, sourceContentMD5, pageBlobRequestConditions,
sourceRequestConditions)
.subscribe(response -> System.out.printf(
"Uploaded page blob from URL with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
Parameters:
Returns:
uploadPagesFromUrlWithResponse
public Mono
Writes one or more pages from the source page blob to this page blob. 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));
client.uploadPagesFromUrlWithResponse(new PageBlobUploadPagesFromUrlOptions(pageRange, url)
.setSourceOffset(sourceOffset).setSourceContentMd5(sourceContentMD5)
.setDestinationRequestConditions(pageBlobRequestConditions)
.setSourceRequestConditions(sourceRequestConditions))
.subscribe(response -> System.out.printf(
"Uploaded page blob from URL with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
Parameters:
Returns:
uploadPagesWithResponse
public Mono
Writes one or more pages to the page blob. 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);
byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
client.uploadPagesWithResponse(pageRange, body, md5, pageBlobRequestConditions)
.subscribe(response -> System.out.printf(
"Uploaded page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
Parameters:
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.
Returns: