From 13fff816b96a805bd438b60c6186fd897f19a737 Mon Sep 17 00:00:00 2001
From: Alan Zimmer <48699787+alzimmermsft@users.noreply.github.com>
Date: Thu, 11 Nov 2021 08:23:27 -0800
Subject: [PATCH 1/6] Update Blobs to neew codesnippet tooling
---
sdk/storage/azure-storage-blob/README.md | 219 +++----
sdk/storage/azure-storage-blob/pom.xml | 3 +
.../azure/storage/blob/BlobAsyncClient.java | 195 +++++-
.../com/azure/storage/blob/BlobClient.java | 74 ++-
.../azure/storage/blob/BlobClientBuilder.java | 16 +-
.../blob/BlobContainerAsyncClient.java | 309 ++++++++-
.../storage/blob/BlobContainerClient.java | 335 +++++++++-
.../blob/BlobContainerClientBuilder.java | 16 +-
.../storage/blob/BlobServiceAsyncClient.java | 242 +++++++-
.../azure/storage/blob/BlobServiceClient.java | 240 ++++++-
.../specialized/AppendBlobAsyncClient.java | 119 +++-
.../blob/specialized/AppendBlobClient.java | 132 +++-
.../blob/specialized/BlobAsyncClientBase.java | 586 ++++++++++++++++--
.../blob/specialized/BlobClientBase.java | 572 +++++++++++++++--
.../specialized/BlobLeaseAsyncClient.java | 165 ++++-
.../blob/specialized/BlobLeaseClient.java | 175 +++++-
.../specialized/BlobLeaseClientBuilder.java | 36 +-
.../specialized/BlockBlobAsyncClient.java | 240 ++++++-
.../blob/specialized/BlockBlobClient.java | 248 +++++++-
.../blob/specialized/PageBlobAsyncClient.java | 352 ++++++++++-
.../blob/specialized/PageBlobClient.java | 369 ++++++++++-
.../SpecializedBlobClientBuilder.java | 9 +-
.../com/azure/storage/blob/ReadmeSamples.java | 223 ++++---
sdk/storage/azure-storage-common/pom.xml | 3 +
.../common/StorageSharedKeyCredential.java | 6 +-
.../credentials/SasTokenCredential.java | 4 -
.../azure-storage-internal-avro/pom.xml | 3 +
27 files changed, 4299 insertions(+), 592 deletions(-)
diff --git a/sdk/storage/azure-storage-blob/README.md b/sdk/storage/azure-storage-blob/README.md
index 105b71cdb6e7..297357dc8b62 100644
--- a/sdk/storage/azure-storage-blob/README.md
+++ b/sdk/storage/azure-storage-blob/README.md
@@ -191,8 +191,7 @@ The following sections provide several code snippets covering some of the most c
Create a `BlobServiceClient` using the [`sasToken`](#get-credentials) generated above.
-
-```java
+```java readme-sample-getBlobServiceClient1
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint("")
.sasToken("")
@@ -201,8 +200,7 @@ BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
or
-
-```java
+```java readme-sample-getBlobServiceClient2
// Only one "?" is needed here. If the sastoken starts with "?", please removing one "?".
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint("" + "?" + "")
@@ -213,15 +211,13 @@ BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
Create a `BlobContainerClient` using a `BlobServiceClient`.
-
-```java
+```java readme-sample-getBlobContainerClient1
BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient("mycontainer");
```
Create a `BlobContainerClient` from the builder [`sasToken`](#get-credentials) generated above.
-
-```java
+```java readme-sample-getBlobContainerClient2
BlobContainerClient blobContainerClient = new BlobContainerClientBuilder()
.endpoint("")
.sasToken("")
@@ -231,8 +227,7 @@ BlobContainerClient blobContainerClient = new BlobContainerClientBuilder()
or
-
-```java
+```java readme-sample-getBlobContainerClient3
// Only one "?" is needed here. If the sastoken starts with "?", please removing one "?".
BlobContainerClient blobContainerClient = new BlobContainerClientBuilder()
.endpoint("" + "/" + "mycontainer" + "?" + "")
@@ -243,8 +238,7 @@ BlobContainerClient blobContainerClient = new BlobContainerClientBuilder()
Create a `BlobClient` using a `BlobContainerClient`.
-
-```java
+```java readme-sample-getBlobClient1
BlobClient blobClient = blobContainerClient.getBlobClient("myblob");
```
@@ -252,8 +246,7 @@ or
Create a `BlobClient` from the builder [`sasToken`](#get-credentials) generated above.
-
-```java
+```java readme-sample-getBlobClient2
BlobClient blobClient = new BlobClientBuilder()
.endpoint("")
.sasToken("")
@@ -264,8 +257,7 @@ BlobClient blobClient = new BlobClientBuilder()
or
-
-```java
+```java readme-sample-getBlobClient3
// Only one "?" is needed here. If the sastoken starts with "?", please removing one "?".
BlobClient blobClient = new BlobClientBuilder()
.endpoint("" + "/" + "mycontainer" + "/" + "myblob" + "?" + "")
@@ -276,8 +268,7 @@ BlobClient blobClient = new BlobClientBuilder()
Create a container using a `BlobServiceClient`.
-
-```java
+```java readme-sample-createBlobContainerClient1
blobServiceClient.createBlobContainer("mycontainer");
```
@@ -285,8 +276,7 @@ or
Create a container using a `BlobContainerClient`.
-
-```java
+```java readme-sample-createBlobContainerClient2
blobContainerClient.create();
```
@@ -294,8 +284,7 @@ blobContainerClient.create();
Upload `BinaryData` to a blob using a `BlobClient` generated from a `BlobContainerClient`.
-
-```java
+```java readme-sample-uploadBinaryDataToBlob
BlobClient blobClient = blobContainerClient.getBlobClient("myblockblob");
String dataSample = "samples";
blobClient.upload(BinaryData.fromString(dataSample));
@@ -305,8 +294,7 @@ blobClient.upload(BinaryData.fromString(dataSample));
Upload from an `InputStream` to a blob using a `BlockBlobClient` generated from a `BlobContainerClient`.
-
-```java
+```java readme-sample-uploadBlobFromStream
BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient("myblockblob").getBlockBlobClient();
String dataSample = "samples";
try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
@@ -320,8 +308,7 @@ try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBy
Upload a file to a blob using a `BlobClient` generated from a `BlobContainerClient`.
-
-```java
+```java readme-sample-uploadBlobFromFile
BlobClient blobClient = blobContainerClient.getBlobClient("myblockblob");
blobClient.uploadFromFile("local-file.jpg");
```
@@ -330,90 +317,88 @@ blobClient.uploadFromFile("local-file.jpg");
Upload data to a blob and fail if one already exists.
-
-```java
-/*
+```java readme-sample-uploadIfNotExists
+ /*
Rather than use an if block conditioned on an exists call, there are three ways to upload-if-not-exists using one
network call instead of two. Equivalent options are present on all upload methods.
- */
-// 1. The minimal upload method defaults to no overwriting
-String dataSample = "samples";
-try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
- blobClient.upload(dataStream, dataSample.length());
-} catch (IOException e) {
- e.printStackTrace();
-}
-
-// 2. The overwrite flag can explicitly be set to false to make intention clear
-try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
- blobClient.upload(dataStream, dataSample.length(), false /* overwrite */);
-} catch (IOException e) {
- e.printStackTrace();
-}
-
-// 3. If the max overload is needed, access conditions must be used to prevent overwriting
-try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
- BlobParallelUploadOptions options =
- new BlobParallelUploadOptions(dataStream, dataSample.length());
- // Setting IfNoneMatch="*" ensures the upload will fail if there is already a blob at the destination.
- options.setRequestConditions(new BlobRequestConditions().setIfNoneMatch("*"));
- blobClient.uploadWithResponse(options, null, Context.NONE);
-} catch (IOException e) {
- e.printStackTrace();
-}
+ */
+ // 1. The minimal upload method defaults to no overwriting
+ String dataSample = "samples";
+ try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
+ blobClient.upload(dataStream, dataSample.length());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // 2. The overwrite flag can explicitly be set to false to make intention clear
+ try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
+ blobClient.upload(dataStream, dataSample.length(), false /* overwrite */);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // 3. If the max overload is needed, access conditions must be used to prevent overwriting
+ try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
+ BlobParallelUploadOptions options =
+ new BlobParallelUploadOptions(dataStream, dataSample.length());
+ // Setting IfNoneMatch="*" ensures the upload will fail if there is already a blob at the destination.
+ options.setRequestConditions(new BlobRequestConditions().setIfNoneMatch("*"));
+ blobClient.uploadWithResponse(options, null, Context.NONE);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
```
### Upload a blob and overwrite if one already exists
Upload data to a blob and overwrite any existing data at the destination.
-```java
-/*
+```java readme-sample-overwriteBlob
+ /*
Rather than use an if block conditioned on an exists call, there are three ways to upload-if-exists in one
network call instead of two. Equivalent options are present on all upload methods.
- */
-String dataSample = "samples";
-
-// 1. The overwrite flag can explicitly be set to true. This will succeed as a create and overwrite.
-try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
- blobClient.upload(dataStream, dataSample.length(), true /* overwrite */);
-} catch (IOException e) {
- e.printStackTrace();
-}
-
-/*
- 2. If the max overload is needed and no access conditions are passed, the upload will succeed as both a
- create and overwrite.
- */
-try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
- BlobParallelUploadOptions options =
- new BlobParallelUploadOptions(dataStream, dataSample.length());
- blobClient.uploadWithResponse(options, null, Context.NONE);
-} catch (IOException e) {
- e.printStackTrace();
-}
-
-/*
- 3. If the max overload is needed, access conditions may be used to assert that the upload is an overwrite and
- not simply a create.
- */
-try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
- BlobParallelUploadOptions options =
- new BlobParallelUploadOptions(dataStream, dataSample.length());
- // Setting IfMatch="*" ensures the upload will succeed only if there is already a blob at the destination.
- options.setRequestConditions(new BlobRequestConditions().setIfMatch("*"));
- blobClient.uploadWithResponse(options, null, Context.NONE);
-} catch (IOException e) {
- e.printStackTrace();
-}
+ */
+ String dataSample = "samples";
+
+ // 1. The overwrite flag can explicitly be set to true. This will succeed as a create and overwrite.
+ try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
+ blobClient.upload(dataStream, dataSample.length(), true /* overwrite */);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ /*
+ 2. If the max overload is needed and no access conditions are passed, the upload will succeed as both a
+ create and overwrite.
+ */
+ try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
+ BlobParallelUploadOptions options =
+ new BlobParallelUploadOptions(dataStream, dataSample.length());
+ blobClient.uploadWithResponse(options, null, Context.NONE);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ /*
+ 3. If the max overload is needed, access conditions may be used to assert that the upload is an overwrite and
+ not simply a create.
+ */
+ try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) {
+ BlobParallelUploadOptions options =
+ new BlobParallelUploadOptions(dataStream, dataSample.length());
+ // Setting IfMatch="*" ensures the upload will succeed only if there is already a blob at the destination.
+ options.setRequestConditions(new BlobRequestConditions().setIfMatch("*"));
+ blobClient.uploadWithResponse(options, null, Context.NONE);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
```
### Upload a blob via an `OutputStream`
Upload a blob by opening a `BlobOutputStream` and writing to it through standard stream APIs.
-
-```java
+```java readme-sample-openBlobOutputStream
/*
Opening a blob input stream allows you to write to a blob through a normal stream interface. It will not be
committed until the stream is closed.
@@ -431,8 +416,7 @@ try (BlobOutputStream blobOS = blobClient.getBlockBlobClient().getBlobOutputStre
Download a blob to an `OutputStream` using a `BlobClient`.
-
-```java
+```java readme-sample-downloadDataFromBlob
BinaryData content = blobClient.downloadContent();
```
@@ -440,8 +424,7 @@ BinaryData content = blobClient.downloadContent();
Download a blob to an `OutputStream` using a `BlobClient`.
-
-```java
+```java readme-sample-downloadBlobToStream
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
blobClient.downloadStream(outputStream);
} catch (IOException e) {
@@ -453,8 +436,7 @@ try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
Download blob to a local file using a `BlobClient`.
-
-```java
+```java readme-sample-downloadBlobToFile
blobClient.downloadToFile("downloaded-file.jpg");
```
@@ -462,8 +444,7 @@ blobClient.downloadToFile("downloaded-file.jpg");
Download a blob by opening a `BlobInputStream` and reading from it through standard stream APIs.
-
-```java
+```java readme-sample-openBlobInputStream
/*
Opening a blob input stream allows you to read from a blob through a normal stream interface. It is also
markable.
@@ -479,8 +460,7 @@ try (BlobInputStream blobIS = blobClient.openInputStream()) {
Enumerating all blobs using a `BlobContainerClient`.
-
-```java
+```java readme-sample-enumerateBlobs
for (BlobItem blobItem : blobContainerClient.listBlobs()) {
System.out.println("This is the blob name: " + blobItem.getName());
}
@@ -490,8 +470,7 @@ or
Enumerate all blobs and create new clients pointing to the items.
-
-```java
+```java readme-sample-enumerateBlobsCreateClient
for (BlobItem blobItem : blobContainerClient.listBlobs()) {
BlobClient blobClient;
if (blobItem.getSnapshot() != null) {
@@ -508,16 +487,14 @@ for (BlobItem blobItem : blobContainerClient.listBlobs()) {
Copying a blob. Please refer to the javadocs on each of these methods for more information around requirements on the
copy source and its authentication.
-
-```java
+```java readme-sample-copyBlob
SyncPoller poller = blobClient.beginCopy("", Duration.ofSeconds(1));
poller.waitForCompletion();
```
or
-
-```java
+```java readme-sample-copyBlob2
blobClient.copyFromUrl("url-to-blob");
```
@@ -526,7 +503,7 @@ blobClient.copyFromUrl("url-to-blob");
Use an instance of a client to generate a new SAS token.
-```java
+```java readme-sample-generateSas
/*
Generate an account sas. Other samples in this file will demonstrate how to create a client with the sas token.
*/
@@ -551,14 +528,13 @@ blobContainerClient.generateSas(serviceSasValues);
BlobSasPermission blobSasPermission = new BlobSasPermission().setReadPermission(true);
serviceSasValues = new BlobServiceSasSignatureValues(expiryTime, blobSasPermission);
blobClient.generateSas(serviceSasValues);
-```
+```
### Authenticate with Azure Identity
The [Azure Identity library][identity] provides Azure Active Directory support for authenticating with Azure Storage.
-
-```java
+```java readme-sample-authWithIdentity
BlobServiceClient blobStorageClient = new BlobServiceClientBuilder()
.endpoint("")
.credential(new DefaultAzureCredentialBuilder().build())
@@ -567,14 +543,25 @@ BlobServiceClient blobStorageClient = new BlobServiceClientBuilder()
### Set a proxy when building a client
-
-```java
+```java readme-sample-setProxy
ProxyOptions options = new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 888));
BlobServiceClient client = new BlobServiceClientBuilder()
.httpClient(new NettyAsyncHttpClientBuilder().proxy(options).build())
.buildClient();
```
+or
+
+Allow the client builder to determine the `HttpClient` type to be used but construct it with passed configurations.
+
+```java readme-sample-setProxy2
+HttpClientOptions clientOptions = new HttpClientOptions()
+ .setProxyOptions(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 888)));
+BlobServiceClient client = new BlobServiceClientBuilder()
+ .clientOptions(clientOptions)
+ .buildClient();
+```
+
## Troubleshooting
When interacting with blobs using this Java client library, errors returned by the service correspond to the same HTTP
diff --git a/sdk/storage/azure-storage-blob/pom.xml b/sdk/storage/azure-storage-blob/pom.xml
index aaba94250141..db50c38a68cc 100644
--- a/sdk/storage/azure-storage-blob/pom.xml
+++ b/sdk/storage/azure-storage-blob/pom.xml
@@ -55,6 +55,9 @@
--add-reads com.azure.storage.common=ALL-UNNAMED
--add-reads com.azure.storage.internal.avro=ALL-UNNAMED
+ false
+
+
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java
index ffb1a610521b..3b57291b54fc 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java
@@ -310,7 +310,16 @@ private SpecializedBlobClientBuilder prepareBuilder() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.upload#Flux-ParallelTransferOptions}
+ *
+ *
+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions()
+ * .setBlockSizeLong(blockSize)
+ * .setMaxConcurrency(maxConcurrency);
+ * client.upload(data, parallelTransferOptions).subscribe(response ->
+ * System.out.printf("Uploaded BlockBlob MD5 is %s%n",
+ * Base64.getEncoder().encodeToString(response.getContentMd5())));
+ *
+ *
*
* @param data The data to write to the blob. Unlike other upload methods, this method does not require that the
* {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected
@@ -351,7 +360,17 @@ public Mono upload(Flux data, ParallelTransferOptions
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.upload#Flux-ParallelTransferOptions-boolean}
+ *
+ *
+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions()
+ * .setBlockSizeLong(blockSize)
+ * .setMaxConcurrency(maxConcurrency);
+ * boolean overwrite = false; // Default behavior
+ * client.upload(data, parallelTransferOptions, overwrite).subscribe(response ->
+ * System.out.printf("Uploaded BlockBlob MD5 is %s%n",
+ * Base64.getEncoder().encodeToString(response.getContentMd5())));
+ *
+ *
*
* @param data The data to write to the blob. Unlike other upload methods, this method does not require that the
* {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected
@@ -391,7 +410,13 @@ public Mono upload(Flux data, ParallelTransferOptions
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.upload#BinaryData}
+ *
+ *
+ * client.upload(BinaryData.fromString("Data!")).subscribe(response ->
+ * System.out.printf("Uploaded BlockBlob MD5 is %s%n",
+ * Base64.getEncoder().encodeToString(response.getContentMd5())));
+ *
+ *
*
* @param data The data to write to the blob.
* @return A reactive response containing the information of the uploaded block blob.
@@ -410,7 +435,14 @@ public Mono upload(BinaryData data) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.upload#BinaryData-boolean}
+ *
+ *
+ * boolean overwrite = false; // Default behavior
+ * client.upload(BinaryData.fromString("Data!"), overwrite).subscribe(response ->
+ * System.out.printf("Uploaded BlockBlob MD5 is %s%n",
+ * Base64.getEncoder().encodeToString(response.getContentMd5())));
+ *
+ *
*
* @param data The data to write to the blob.
* @param overwrite Whether or not to overwrite, should the blob already exist.
@@ -467,11 +499,52 @@ public Mono upload(BinaryData data,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#Flux-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
+ * .setContentLanguage("en-US")
+ * .setContentType("binary");
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions()
+ * .setBlockSizeLong(blockSize)
+ * .setMaxConcurrency(maxConcurrency);
+ *
+ * client.uploadWithResponse(data, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions)
+ * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
+ * Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
+ *
+ *
*
* Using Progress Reporting
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#Flux-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions.ProgressReporter}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
+ * .setContentLanguage("en-US")
+ * .setContentType("binary");
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions()
+ * .setBlockSizeLong(blockSize)
+ * .setMaxConcurrency(maxConcurrency)
+ * .setProgressReceiver(bytesTransferred -> System.out.printf("Upload progress: %s bytes sent", bytesTransferred));
+ *
+ * client.uploadWithResponse(data, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions)
+ * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
+ * Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
+ *
+ *
*
* @param data The data to write to the blob. Unlike other upload methods, this method does not require that the
* {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected
@@ -519,11 +592,57 @@ public Mono> uploadWithResponse(Flux data,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#BlobParallelUploadOptions}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
+ * .setContentLanguage("en-US")
+ * .setContentType("binary");
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Map<String, String> tags = Collections.singletonMap("tag", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize)
+ * .setMaxConcurrency(maxConcurrency).setProgressReceiver(bytesTransferred ->
+ * System.out.printf("Upload progress: %s bytes sent", bytesTransferred));
+ *
+ * client.uploadWithResponse(new BlobParallelUploadOptions(data)
+ * .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata).setTags(tags)
+ * .setTier(AccessTier.HOT).setRequestConditions(requestConditions))
+ * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
+ * Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
+ *
+ *
*
* Using Progress Reporting
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#BlobParallelUploadOptions}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
+ * .setContentLanguage("en-US")
+ * .setContentType("binary");
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Map<String, String> tags = Collections.singletonMap("tag", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize)
+ * .setMaxConcurrency(maxConcurrency).setProgressReceiver(bytesTransferred ->
+ * System.out.printf("Upload progress: %s bytes sent", bytesTransferred));
+ *
+ * client.uploadWithResponse(new BlobParallelUploadOptions(data)
+ * .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata).setTags(tags)
+ * .setTier(AccessTier.HOT).setRequestConditions(requestConditions))
+ * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
+ * Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
+ *
+ *
*
* @param options {@link BlobParallelUploadOptions}. Unlike other upload methods, this method does not require that
* the {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not
@@ -689,7 +808,13 @@ private Mono> uploadInChunks(BlockBlobAsyncClient blockB
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String}
+ *
+ *
+ * client.uploadFromFile(filePath)
+ * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage()))
+ * .subscribe(completion -> System.out.println("Upload from file succeeded"));
+ *
+ *
*
* @param filePath Path to the upload file
* @return An empty response
@@ -710,7 +835,14 @@ public Mono uploadFromFile(String filePath) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-boolean}
+ *
+ *
+ * boolean overwrite = false; // Default behavior
+ * client.uploadFromFile(filePath, overwrite)
+ * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage()))
+ * .subscribe(completion -> System.out.println("Upload from file succeeded"));
+ *
+ *
*
* @param filePath Path to the upload file
* @param overwrite Whether or not to overwrite, should the blob already exist.
@@ -749,7 +881,25 @@ public Mono uploadFromFile(String filePath, boolean overwrite) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
+ * .setContentLanguage("en-US")
+ * .setContentType("binary");
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.uploadFromFile(filePath,
+ * new ParallelTransferOptions().setBlockSizeLong(BlockBlobClient.MAX_STAGE_BLOCK_BYTES_LONG),
+ * headers, metadata, AccessTier.HOT, requestConditions)
+ * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage()))
+ * .subscribe(completion -> System.out.println("Upload from file succeeded"));
+ *
+ *
*
* @param filePath Path to the upload file
* @param parallelTransferOptions {@link ParallelTransferOptions} to use to upload from file. Number of parallel
@@ -780,7 +930,28 @@ public Mono uploadFromFile(String filePath, ParallelTransferOptions parall
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadFromFileWithResponse#BlobUploadFromFileOptions}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
+ * .setContentLanguage("en-US")
+ * .setContentType("binary");
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Map<String, String> tags = Collections.singletonMap("tag", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath)
+ * .setParallelTransferOptions(
+ * new ParallelTransferOptions().setBlockSizeLong(BlobAsyncClient.BLOB_MAX_UPLOAD_BLOCK_SIZE))
+ * .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
+ * .setRequestConditions(requestConditions))
+ * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage()))
+ * .subscribe(completion -> System.out.println("Upload from file succeeded"));
+ *
+ *
*
* @param options {@link BlobUploadFromFileOptions}
* @return A reactive response containing the information of the uploaded block blob.
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java
index 7a2557fc1542..b2f93561ece2 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java
@@ -311,7 +311,16 @@ public Response uploadWithResponse(BlobParallelUploadOptions opti
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobClient.uploadFromFile#String}
+ *
+ *
+ * try {
+ * client.uploadFromFile(filePath);
+ * System.out.println("Upload from file succeeded");
+ * } catch (UncheckedIOException ex) {
+ * System.err.printf("Failed to upload from file %s%n", ex.getMessage());
+ * }
+ *
+ *
*
* @param filePath Path of the file to upload
* @throws UncheckedIOException If an I/O error occurs
@@ -326,7 +335,17 @@ public void uploadFromFile(String filePath) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobClient.uploadFromFile#String-boolean}
+ *
+ *
+ * try {
+ * boolean overwrite = false;
+ * client.uploadFromFile(filePath, overwrite);
+ * System.out.println("Upload from file succeeded");
+ * } catch (UncheckedIOException ex) {
+ * System.err.printf("Failed to upload from file %s%n", ex.getMessage());
+ * }
+ *
+ *
*
* @param filePath Path of the file to upload
* @param overwrite Whether or not to overwrite, should the blob already exist
@@ -354,7 +373,29 @@ public void uploadFromFile(String filePath, boolean overwrite) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions-Duration}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
+ * .setContentLanguage("en-US")
+ * .setContentType("binary");
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ * Long blockSize = 100L * 1024L * 1024L; // 100 MB;
+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);
+ *
+ * try {
+ * client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata,
+ * AccessTier.HOT, requestConditions, timeout);
+ * System.out.println("Upload from file succeeded");
+ * } catch (UncheckedIOException ex) {
+ * System.err.printf("Failed to upload from file %s%n", ex.getMessage());
+ * }
+ *
+ *
*
* @param filePath Path of the file to upload
* @param parallelTransferOptions {@link ParallelTransferOptions} to use to upload from file. Number of parallel
@@ -383,7 +424,32 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobClient.uploadFromFileWithResponse#BlobUploadFromFileOptions-Duration-Context}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
+ * .setContentLanguage("en-US")
+ * .setContentType("binary");
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Map<String, String> tags = Collections.singletonMap("tag", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ * Long blockSize = 100 * 1024 * 1024L; // 100 MB;
+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);
+ *
+ * try {
+ * client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath)
+ * .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata)
+ * .setTags(tags).setTier(AccessTier.HOT).setRequestConditions(requestConditions), timeout,
+ * new Context(key2, value2));
+ * System.out.println("Upload from file succeeded");
+ * } catch (UncheckedIOException ex) {
+ * System.err.printf("Failed to upload from file %s%n", ex.getMessage());
+ * }
+ *
+ *
*
* @param options {@link BlobUploadFromFileOptions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java
index 080e821a0afe..21d35eaa40af 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java
@@ -92,7 +92,13 @@ public BlobClientBuilder() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobClientBuilder.buildClient}
+ *
+ *
+ * BlobClient client = new BlobClientBuilder()
+ * .connectionString(connectionString)
+ * .buildClient();
+ *
+ *
*
* @return a {@link BlobClient} created from the configurations in this builder.
* @throws NullPointerException If {@code endpoint} or {@code blobName} is {@code null}.
@@ -109,7 +115,13 @@ public BlobClient buildClient() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobClientBuilder.buildAsyncClient}
+ *
+ *
+ * BlobAsyncClient client = new BlobClientBuilder()
+ * .connectionString(connectionString)
+ * .buildAsyncClient();
+ *
+ *
*
* @return a {@link BlobAsyncClient} created from the configurations in this builder.
* @throws NullPointerException If {@code endpoint} or {@code blobName} is {@code null}.
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java
index 9e77ce1838f8..8aee3b600faf 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java
@@ -144,7 +144,11 @@ public final class BlobContainerAsyncClient {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getBlobAsyncClient#String}
+ *
+ *
+ * BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName);
+ *
+ *
*
* @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters,
* pass in the url encoded version of the blob name.
@@ -160,7 +164,11 @@ public BlobAsyncClient getBlobAsyncClient(String blobName) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getBlobAsyncClient#String-String}
+ *
+ *
+ * BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName, snapshot);
+ *
+ *
*
* @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters,
* pass in the url encoded version of the blob name.
@@ -209,7 +217,12 @@ public String getBlobContainerUrl() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getBlobContainerName}
+ *
+ *
+ * String containerName = client.getBlobContainerName();
+ * System.out.println("The name of the blob is " + containerName);
+ *
+ *
*
* @return The name of container.
*/
@@ -292,7 +305,11 @@ public String getEncryptionScope() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.exists}
+ *
+ *
+ * client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
+ *
+ *
*
* @return true if the container exists, false if it doesn't
*/
@@ -310,7 +327,11 @@ public Mono exists() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.existsWithResponse}
+ *
+ *
+ * client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
+ *
+ *
*
* @return true if the container exists, false if it doesn't
*/
@@ -346,7 +367,13 @@ Mono> existsWithResponse(Context context) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.create}
+ *
+ *
+ * client.create().subscribe(
+ * response -> System.out.printf("Create completed%n"),
+ * error -> System.out.printf("Error while creating container %s%n", error));
+ *
+ *
*
* @return A reactive response signalling completion.
*/
@@ -366,7 +393,13 @@ public Mono create() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.createWithResponse#Map-PublicAccessType}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * client.createWithResponse(metadata, PublicAccessType.CONTAINER).subscribe(response ->
+ * System.out.printf("Create completed with status %d%n", response.getStatusCode()));
+ *
+ *
*
* @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any
* metadata key or value, it must be removed or encoded.
@@ -399,7 +432,13 @@ Mono> createWithResponse(Map metadata, PublicAcce
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.delete}
+ *
+ *
+ * client.delete().subscribe(
+ * response -> System.out.printf("Delete completed%n"),
+ * error -> System.out.printf("Delete failed: %s%n", error));
+ *
+ *
*
* @return A reactive response signalling completion.
*/
@@ -419,7 +458,16 @@ public Mono delete() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.deleteWithResponse#BlobRequestConditions}
+ *
+ *
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.deleteWithResponse(requestConditions).subscribe(response ->
+ * System.out.printf("Delete completed with status %d%n", response.getStatusCode()));
+ *
+ *
*
* @param requestConditions {@link BlobRequestConditions}
* @return A reactive response signalling completion.
@@ -459,7 +507,15 @@ Mono> deleteWithResponse(BlobRequestConditions requestConditions,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getProperties}
+ *
+ *
+ * client.getProperties().subscribe(response ->
+ * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
+ * response.getBlobPublicAccess(),
+ * response.hasLegalHold(),
+ * response.hasImmutabilityPolicy()));
+ *
+ *
*
* @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} containing the
* container properties.
@@ -479,7 +535,15 @@ public Mono getProperties() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getPropertiesWithResponse#String}
+ *
+ *
+ * client.getPropertiesWithResponse(leaseId).subscribe(response ->
+ * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
+ * response.getValue().getBlobPublicAccess(),
+ * response.getValue().hasLegalHold(),
+ * response.getValue().hasImmutabilityPolicy()));
+ *
+ *
*
* @param leaseId The lease ID the active lease on the container must match.
* @return A reactive response containing the container properties.
@@ -516,7 +580,14 @@ Mono> getPropertiesWithResponse(String leaseId
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.setMetadata#Map}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * client.setMetadata(metadata).subscribe(
+ * response -> System.out.printf("Set metadata completed%n"),
+ * error -> System.out.printf("Set metadata failed: %s%n", error));
+ *
+ *
*
* @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any
* metadata key or value, it must be removed or encoded.
@@ -538,7 +609,17 @@ public Mono setMetadata(Map metadata) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.setMetadataWithResponse#Map-BlobRequestConditions}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.setMetadataWithResponse(metadata, requestConditions).subscribe(response ->
+ * System.out.printf("Set metadata completed with status %d%n", response.getStatusCode()));
+ *
+ *
*
* @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any
* metadata key or value, it must be removed or encoded.
@@ -582,7 +663,19 @@ Mono> setMetadataWithResponse(Map metadata,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getAccessPolicy}
+ *
+ *
+ * client.getAccessPolicy().subscribe(response -> {
+ * System.out.printf("Blob Access Type: %s%n", response.getBlobAccessType());
+ *
+ * for (BlobSignedIdentifier identifier : response.getIdentifiers()) {
+ * System.out.printf("Identifier Name: %s, Permissions %s%n",
+ * identifier.getId(),
+ * identifier.getAccessPolicy().getPermissions());
+ * }
+ * });
+ *
+ *
*
* @return A reactive response containing the container access policy.
*/
@@ -602,7 +695,19 @@ public Mono getAccessPolicy() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getAccessPolicyWithResponse#String}
+ *
+ *
+ * client.getAccessPolicyWithResponse(leaseId).subscribe(response -> {
+ * System.out.printf("Blob Access Type: %s%n", response.getValue().getBlobAccessType());
+ *
+ * for (BlobSignedIdentifier identifier : response.getValue().getIdentifiers()) {
+ * System.out.printf("Identifier Name: %s, Permissions %s%n",
+ * identifier.getId(),
+ * identifier.getAccessPolicy().getPermissions());
+ * }
+ * });
+ *
+ *
*
* @param leaseId The lease ID the active lease on the container must match.
* @return A reactive response containing the container access policy.
@@ -634,7 +739,20 @@ Mono> getAccessPolicyWithResponse(String l
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.setAccessPolicy#PublicAccessType-List}
+ *
+ *
+ * BlobSignedIdentifier identifier = new BlobSignedIdentifier()
+ * .setId("name")
+ * .setAccessPolicy(new BlobAccessPolicy()
+ * .setStartsOn(OffsetDateTime.now())
+ * .setExpiresOn(OffsetDateTime.now().plusDays(7))
+ * .setPermissions("permissionString"));
+ *
+ * client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)).subscribe(
+ * response -> System.out.printf("Set access policy completed%n"),
+ * error -> System.out.printf("Set access policy failed: %s%n", error));
+ *
+ *
*
* @param accessType Specifies how the data in this container is available to the public. See the
* x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.
@@ -661,7 +779,24 @@ public Mono setAccessPolicy(PublicAccessType accessType, ListCode Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.setAccessPolicyWithResponse#PublicAccessType-List-BlobRequestConditions}
+ *
+ *
+ * BlobSignedIdentifier identifier = new BlobSignedIdentifier()
+ * .setId("name")
+ * .setAccessPolicy(new BlobAccessPolicy()
+ * .setStartsOn(OffsetDateTime.now())
+ * .setExpiresOn(OffsetDateTime.now().plusDays(7))
+ * .setPermissions("permissionString"));
+ *
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, Collections.singletonList(identifier), requestConditions)
+ * .subscribe(response ->
+ * System.out.printf("Set access policy completed with status %d%n", response.getStatusCode()));
+ *
+ *
*
* @param accessType Specifies how the data in this container is available to the public. See the
* x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.
@@ -744,7 +879,12 @@ OffsetDateTime.now will only give back milliseconds (more precise fields are zer
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.listBlobs}
+ *
+ *
+ * client.listBlobs().subscribe(blob ->
+ * System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix()));
+ *
+ *
*
* @return A reactive response emitting the flattened blobs.
*/
@@ -777,7 +917,22 @@ public PagedFlux listBlobs() {
*
*
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.listBlobs#ListBlobsOptions}
+ *
+ *
+ * ListBlobsOptions options = new ListBlobsOptions()
+ * .setPrefix("prefixToMatch")
+ * .setDetails(new BlobListDetails()
+ * .setRetrieveDeletedBlobs(true)
+ * .setRetrieveSnapshots(true));
+ *
+ * client.listBlobs(options).subscribe(blob ->
+ * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
+ * blob.getName(),
+ * blob.isPrefix(),
+ * blob.isDeleted(),
+ * blob.getSnapshot()));
+ *
+ *
*
* @param options {@link ListBlobsOptions}
* @return A reactive response emitting the listed blobs, flattened.
@@ -811,7 +966,24 @@ public PagedFlux listBlobs(ListBlobsOptions options) {
*
*
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.listBlobs#ListBlobsOptions-String}
+ *
+ *
+ * ListBlobsOptions options = new ListBlobsOptions()
+ * .setPrefix("prefixToMatch")
+ * .setDetails(new BlobListDetails()
+ * .setRetrieveDeletedBlobs(true)
+ * .setRetrieveSnapshots(true));
+ *
+ * String continuationToken = "continuationToken";
+ *
+ * client.listBlobs(options, continuationToken).subscribe(blob ->
+ * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
+ * blob.getName(),
+ * blob.isPrefix(),
+ * blob.isDeleted(),
+ * blob.getSnapshot()));
+ *
+ *
*
* @param options {@link ListBlobsOptions}
* @param continuationToken Identifies the portion of the list to be returned with the next list operation.
@@ -928,7 +1100,12 @@ private Mono listBlobsFlatSegment(String
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.listBlobsByHierarchy#String}
+ *
+ *
+ * client.listBlobsByHierarchy("directoryName").subscribe(blob ->
+ * System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isDeleted()));
+ *
+ *
*
* @param directory The directory to list blobs underneath
* @return A reactive response emitting the prefixes and blobs.
@@ -968,7 +1145,22 @@ public PagedFlux listBlobsByHierarchy(String directory) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.listBlobsByHierarchy#String-ListBlobsOptions}
+ *
+ *
+ * ListBlobsOptions options = new ListBlobsOptions()
+ * .setPrefix("directoryName")
+ * .setDetails(new BlobListDetails()
+ * .setRetrieveDeletedBlobs(true)
+ * .setRetrieveSnapshots(true));
+ *
+ * client.listBlobsByHierarchy("/", options).subscribe(blob ->
+ * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
+ * blob.getName(),
+ * blob.isPrefix(),
+ * blob.isDeleted(),
+ * blob.getSnapshot()));
+ *
+ *
*
* @param delimiter The delimiter for blob hierarchy, "/" for hierarchy based on directories
* @param options {@link ListBlobsOptions}
@@ -1062,7 +1254,14 @@ private Mono listBlobsHierarchySegme
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getAccountInfo}
+ *
+ *
+ * client.getAccountInfo().subscribe(response ->
+ * System.out.printf("Account Kind: %s, SKU: %s%n",
+ * response.getAccountKind(),
+ * response.getSkuName()));
+ *
+ *
*
* @return A reactive response containing the account info.
*/
@@ -1081,7 +1280,14 @@ public Mono getAccountInfo() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getAccountInfoWithResponse}
+ *
+ *
+ * client.getAccountInfoWithResponse().subscribe(response ->
+ * System.out.printf("Account Kind: %s, SKU: %s%n",
+ * response.getValue().getAccountKind(),
+ * response.getValue().getSkuName()));
+ *
+ *
*
* @return A reactive response containing the account info.
*/
@@ -1109,7 +1315,8 @@ Mono> getAccountInfoWithResponse(Context context) {
// *
// * Code Samples
// *
-// * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.rename#String}
+// *
+// *
// *
// * @param destinationContainerName The new name of the container.
// * @return A {@link Mono} containing a {@link BlobContainerAsyncClient} used to interact with the renamed container.
@@ -1124,7 +1331,8 @@ Mono> getAccountInfoWithResponse(Context context) {
// *
// * Code Samples
// *
-// * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.renameWithResponse#BlobContainerRenameOptions}
+// *
+// *
// *
// * @param options {@link BlobContainerRenameOptions}
// * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains a
@@ -1172,7 +1380,17 @@ Mono> getAccountInfoWithResponse(Context context) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey}
+ *
+ *
+ * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
+ * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true);
+ *
+ * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
+ * .setStartTime(OffsetDateTime.now());
+ *
+ * client.generateUserDelegationSas(values, userDelegationKey);
+ *
+ *
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values.
@@ -1193,7 +1411,17 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context}
+ *
+ *
+ * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
+ * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true);
+ *
+ * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
+ * .setStartTime(OffsetDateTime.now());
+ *
+ * client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value"));
+ *
+ *
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values.
@@ -1217,7 +1445,17 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues}
+ *
+ *
+ * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
+ * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true);
+ *
+ * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
+ * .setStartTime(OffsetDateTime.now());
+ *
+ * client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
+ *
+ *
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
*
@@ -1234,7 +1472,18 @@ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureV
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues-Context}
+ *
+ *
+ * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
+ * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true);
+ *
+ * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
+ * .setStartTime(OffsetDateTime.now());
+ *
+ * // Client must be authenticated via StorageSharedKeyCredential
+ * client.generateSas(values, new Context("key", "value"));
+ *
+ *
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param context Additional context that is passed through the code when generating a SAS.
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java
index 2c6bf6ab6929..7a313b20c675 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java
@@ -74,7 +74,11 @@ public final class BlobContainerClient {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.getBlobClient#String}
+ *
+ *
+ * BlobClient blobClient = client.getBlobClient(blobName);
+ *
+ *
* @return A new {@link BlobClient} object which references the blob with the specified name in this container.
*/
public BlobClient getBlobClient(String blobName) {
@@ -87,7 +91,11 @@ public BlobClient getBlobClient(String blobName) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.getBlobClient#String-String}
+ *
+ *
+ * BlobClient blobClient = client.getBlobClient(blobName, snapshot);
+ *
+ *
*
* @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters,
* pass in the url encoded version of the blob name.
@@ -116,7 +124,12 @@ public BlobClient getBlobVersionClient(String blobName, String versionId) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.getBlobContainerName}
+ *
+ *
+ * String containerName = client.getBlobContainerName();
+ * System.out.println("The name of the blob is " + containerName);
+ *
+ *
*
* @return The name of container.
*/
@@ -202,7 +215,11 @@ public String getEncryptionScope() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.exists}
+ *
+ *
+ * System.out.printf("Exists? %b%n", client.exists());
+ *
+ *
*
* @return true if the container exists, false if it doesn't
*/
@@ -215,7 +232,12 @@ public boolean exists() {
* Gets if the container this client represents exists in the cloud.
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.existsWithResponse#Duration-Context}
+ *
+ *
+ * Context context = new Context("Key", "Value");
+ * System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, context).getValue());
+ *
+ *
*
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @param context Additional context that is passed through the Http pipeline during the service call.
@@ -235,7 +257,18 @@ public Response existsWithResponse(Duration timeout, Context context) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.create}
+ *
+ *
+ * try {
+ * client.create();
+ * System.out.printf("Create completed%n");
+ * } catch (BlobStorageException error) {
+ * if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_ALREADY_EXISTS)) {
+ * System.out.printf("Can't create container. It already exists %n");
+ * }
+ * }
+ *
+ *
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void create() {
@@ -249,7 +282,15 @@ public void create() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.createWithResponse#Map-PublicAccessType-Duration-Context}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Context context = new Context("Key", "Value");
+ *
+ * System.out.printf("Create completed with status %d%n",
+ * client.createWithResponse(metadata, PublicAccessType.CONTAINER, timeout, context).getStatusCode());
+ *
+ *
*
* @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any
* metadata key or value, it must be removed or encoded.
@@ -273,7 +314,18 @@ public Response createWithResponse(Map metadata, PublicAcc
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.delete}
+ *
+ *
+ * try {
+ * client.delete();
+ * System.out.printf("Delete completed%n");
+ * } catch (BlobStorageException error) {
+ * if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_NOT_FOUND)) {
+ * System.out.printf("Delete failed. Container was not found %n");
+ * }
+ * }
+ *
+ *
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void delete() {
@@ -287,7 +339,17 @@ public void delete() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.deleteWithResponse#BlobRequestConditions-Duration-Context}
+ *
+ *
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ * Context context = new Context("Key", "Value");
+ *
+ * System.out.printf("Delete completed with status %d%n", client.deleteWithResponse(
+ * requestConditions, timeout, context).getStatusCode());
+ *
+ *
*
* @param requestConditions {@link BlobRequestConditions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
@@ -308,7 +370,15 @@ public Response deleteWithResponse(BlobRequestConditions requestConditions
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.getProperties}
+ *
+ *
+ * BlobContainerProperties properties = client.getProperties();
+ * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
+ * properties.getBlobPublicAccess(),
+ * properties.hasLegalHold(),
+ * properties.hasImmutabilityPolicy());
+ *
+ *
*
* @return The container properties.
*/
@@ -323,7 +393,18 @@ public BlobContainerProperties getProperties() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.getPropertiesWithResponse#String-Duration-Context}
+ *
+ *
+ * Context context = new Context("Key", "Value");
+ *
+ * BlobContainerProperties properties = client.getPropertiesWithResponse(leaseId, timeout, context)
+ * .getValue();
+ * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
+ * properties.getBlobPublicAccess(),
+ * properties.hasLegalHold(),
+ * properties.hasImmutabilityPolicy());
+ *
+ *
*
* @param leaseId The lease ID the active lease on the container must match.
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
@@ -342,7 +423,17 @@ public Response getPropertiesWithResponse(String leaseI
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.setMetadata#Map}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * try {
+ * client.setMetadata(metadata);
+ * System.out.printf("Set metadata completed with status %n");
+ * } catch (UnsupportedOperationException error) {
+ * System.out.printf("Fail while setting metadata %n");
+ * }
+ *
+ *
*
* @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any
* metadata key or value, it must be removed or encoded.
@@ -358,7 +449,18 @@ public void setMetadata(Map metadata) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.setMetadataWithResponse#Map-BlobRequestConditions-Duration-Context}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ * Context context = new Context("Key", "Value");
+ *
+ * System.out.printf("Set metadata completed with status %d%n",
+ * client.setMetadataWithResponse(metadata, requestConditions, timeout, context).getStatusCode());
+ *
+ *
* @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any
* metadata key or value, it must be removed or encoded.
* @param requestConditions {@link BlobRequestConditions}
@@ -381,7 +483,18 @@ public Response setMetadataWithResponse(Map metadata,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.getAccessPolicy}
+ *
+ *
+ * BlobContainerAccessPolicies accessPolicies = client.getAccessPolicy();
+ * System.out.printf("Blob Access Type: %s%n", accessPolicies.getBlobAccessType());
+ *
+ * for (BlobSignedIdentifier identifier : accessPolicies.getIdentifiers()) {
+ * System.out.printf("Identifier Name: %s, Permissions %s%n",
+ * identifier.getId(),
+ * identifier.getAccessPolicy().getPermissions());
+ * }
+ *
+ *
*
* @return The container access policy.
*/
@@ -397,7 +510,20 @@ public BlobContainerAccessPolicies getAccessPolicy() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.getAccessPolicyWithResponse#String-Duration-Context}
+ *
+ *
+ * Context context = new Context("Key", "Value");
+ * BlobContainerAccessPolicies accessPolicies = client.getAccessPolicyWithResponse(leaseId, timeout, context)
+ * .getValue();
+ * System.out.printf("Blob Access Type: %s%n", accessPolicies.getBlobAccessType());
+ *
+ * for (BlobSignedIdentifier identifier : accessPolicies.getIdentifiers()) {
+ * System.out.printf("Identifier Name: %s, Permissions %s%n",
+ * identifier.getId(),
+ * identifier.getAccessPolicy().getPermissions());
+ * }
+ *
+ *
*
* @param leaseId The lease ID the active lease on the container must match.
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
@@ -418,7 +544,23 @@ public Response getAccessPolicyWithResponse(String
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.setAccessPolicy#PublicAccessType-List}
+ *
+ *
+ * BlobSignedIdentifier identifier = new BlobSignedIdentifier()
+ * .setId("name")
+ * .setAccessPolicy(new BlobAccessPolicy()
+ * .setStartsOn(OffsetDateTime.now())
+ * .setExpiresOn(OffsetDateTime.now().plusDays(7))
+ * .setPermissions("permissionString"));
+ *
+ * try {
+ * client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier));
+ * System.out.printf("Set Access Policy completed %n");
+ * } catch (UnsupportedOperationException error) {
+ * System.out.printf("Set Access Policy completed %s%n", error);
+ * }
+ *
+ *
*
* @param accessType Specifies how the data in this container is available to the public. See the
* x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.
@@ -441,7 +583,29 @@ public void setAccessPolicy(PublicAccessType accessType,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.setAccessPolicyWithResponse#PublicAccessType-List-BlobRequestConditions-Duration-Context}
+ *
+ *
+ * BlobSignedIdentifier identifier = new BlobSignedIdentifier()
+ * .setId("name")
+ * .setAccessPolicy(new BlobAccessPolicy()
+ * .setStartsOn(OffsetDateTime.now())
+ * .setExpiresOn(OffsetDateTime.now().plusDays(7))
+ * .setPermissions("permissionString"));
+ *
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * Context context = new Context("Key", "Value");
+ *
+ * System.out.printf("Set access policy completed with status %d%n",
+ * client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER,
+ * Collections.singletonList(identifier),
+ * requestConditions,
+ * timeout,
+ * context).getStatusCode());
+ *
+ *
*
* @param accessType Specifies how the data in this container is available to the public. See the
* x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.
@@ -477,7 +641,12 @@ public Response setAccessPolicyWithResponse(PublicAccessType accessType,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobs}
+ *
+ *
+ * client.listBlobs().forEach(blob ->
+ * System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix()));
+ *
+ *
*
* @return The listed blobs, flattened.
*/
@@ -499,7 +668,22 @@ public PagedIterable listBlobs() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobs#ListBlobsOptions-Duration}
+ *
+ *
+ * ListBlobsOptions options = new ListBlobsOptions()
+ * .setPrefix("prefixToMatch")
+ * .setDetails(new BlobListDetails()
+ * .setRetrieveDeletedBlobs(true)
+ * .setRetrieveSnapshots(true));
+ *
+ * client.listBlobs(options, timeout).forEach(blob ->
+ * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
+ * blob.getName(),
+ * blob.isPrefix(),
+ * blob.isDeleted(),
+ * blob.getSnapshot()));
+ *
+ *
*
* @param options {@link ListBlobsOptions}. If iterating by page, the page size passed to byPage methods such as
* {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options.
@@ -524,7 +708,24 @@ public PagedIterable listBlobs(ListBlobsOptions options, Duration time
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobs#ListBlobsOptions-String-Duration}
+ *
+ *
+ * ListBlobsOptions options = new ListBlobsOptions()
+ * .setPrefix("prefixToMatch")
+ * .setDetails(new BlobListDetails()
+ * .setRetrieveDeletedBlobs(true)
+ * .setRetrieveSnapshots(true));
+ *
+ * String continuationToken = "continuationToken";
+ *
+ * client.listBlobs(options, continuationToken, timeout).forEach(blob ->
+ * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
+ * blob.getName(),
+ * blob.isPrefix(),
+ * blob.isDeleted(),
+ * blob.getSnapshot()));
+ *
+ *
*
* @param options {@link ListBlobsOptions}. If iterating by page, the page size passed to byPage methods such as
* {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options.
@@ -563,7 +764,12 @@ public PagedIterable listBlobs(ListBlobsOptions options, String contin
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobsByHierarchy#String}
+ *
+ *
+ * client.listBlobsByHierarchy("directoryName").forEach(blob ->
+ * System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix()));
+ *
+ *
*
* @param directory The directory to list blobs underneath
* @return A reactive response emitting the prefixes and blobs.
@@ -599,7 +805,22 @@ public PagedIterable listBlobsByHierarchy(String directory) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobsByHierarchy#String-ListBlobsOptions-Duration}
+ *
+ *
+ * ListBlobsOptions options = new ListBlobsOptions()
+ * .setPrefix("directoryName")
+ * .setDetails(new BlobListDetails()
+ * .setRetrieveDeletedBlobs(true)
+ * .setRetrieveSnapshots(true));
+ *
+ * client.listBlobsByHierarchy("/", options, timeout).forEach(blob ->
+ * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
+ * blob.getName(),
+ * blob.isPrefix(),
+ * blob.isDeleted(),
+ * blob.getSnapshot()));
+ *
+ *
*
* @param delimiter The delimiter for blob hierarchy, "/" for hierarchy based on directories
* @param options {@link ListBlobsOptions}. If iterating by page, the page size passed to byPage methods such as
@@ -621,7 +842,12 @@ public PagedIterable listBlobsByHierarchy(String delimiter, ListBlobsO
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.getAccountInfo#Duration}
+ *
+ *
+ * StorageAccountInfo accountInfo = client.getAccountInfo(timeout);
+ * System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());
+ *
+ *
* @return The account info.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
@@ -635,7 +861,13 @@ public StorageAccountInfo getAccountInfo(Duration timeout) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.getAccountInfoWithResponse#Duration-Context}
+ *
+ *
+ * Context context = new Context("Key", "Value");
+ * StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, context).getValue();
+ * System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());
+ *
+ *
*
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @param context Additional context that is passed through the Http pipeline during the service call.
@@ -653,7 +885,8 @@ public Response getAccountInfoWithResponse(Duration timeout,
// *
// * Code Samples
// *
-// * {@codesnippet com.azure.storage.blob.BlobContainerClient.rename#String}
+// *
+// *
// *
// * @param destinationContainerName The new name of the container.
// * @return A {@link BlobContainerClient} used to interact with the renamed container.
@@ -669,7 +902,8 @@ public Response getAccountInfoWithResponse(Duration timeout,
// *
// * Code Samples
// *
-// * {@codesnippet com.azure.storage.blob.BlobContainerClient.renameWithResponse#BlobContainerRenameOptions-Duration-Context}
+// *
+// *
// *
// * @param options {@link BlobContainerRenameOptions}
// * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
@@ -692,7 +926,17 @@ public Response getAccountInfoWithResponse(Duration timeout,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey}
+ *
+ *
+ * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
+ * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true);
+ *
+ * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
+ * .setStartTime(OffsetDateTime.now());
+ *
+ * client.generateUserDelegationSas(values, userDelegationKey);
+ *
+ *
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values.
@@ -712,7 +956,17 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context}
+ *
+ *
+ * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
+ * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true);
+ *
+ * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
+ * .setStartTime(OffsetDateTime.now());
+ *
+ * client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value"));
+ *
+ *
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values.
@@ -736,7 +990,17 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues}
+ *
+ *
+ * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
+ * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true);
+ *
+ * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
+ * .setStartTime(OffsetDateTime.now());
+ *
+ * client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
+ *
+ *
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
*
@@ -753,7 +1017,18 @@ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureV
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues-Context}
+ *
+ *
+ * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
+ * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true);
+ *
+ * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
+ * .setStartTime(OffsetDateTime.now());
+ *
+ * // Client must be authenticated via StorageSharedKeyCredential
+ * client.generateSas(values, new Context("key", "value"));
+ *
+ *
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param context Additional context that is passed through the code when generating a SAS.
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java
index 1c7932727ad4..0db7b1338910 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java
@@ -88,7 +88,13 @@ public BlobContainerClientBuilder() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClientBuilder.buildClient}
+ *
+ *
+ * BlobContainerClient client = new BlobContainerClientBuilder()
+ * .connectionString(connectionString)
+ * .buildClient();
+ *
+ *
*
* @return a {@link BlobContainerClient} created from the configurations in this builder.
* @throws IllegalStateException If multiple credentials have been specified.
@@ -102,7 +108,13 @@ public BlobContainerClient buildClient() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobContainerClientBuilder.buildAsyncClient}
+ *
+ *
+ * BlobContainerAsyncClient client = new BlobContainerClientBuilder()
+ * .connectionString(connectionString)
+ * .buildAsyncClient();
+ *
+ *
*
* @return a {@link BlobContainerAsyncClient} created from the configurations in this builder.
* @throws IllegalStateException If multiple credentials have been specified.
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java
index 43b6b43bfb77..3f6ecf4364b3 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java
@@ -141,7 +141,11 @@ public final class BlobServiceAsyncClient {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getBlobContainerAsyncClient#String}
+ *
+ *
+ * BlobContainerAsyncClient blobContainerAsyncClient = client.getBlobContainerAsyncClient("containerName");
+ *
+ *
*
* @param containerName The name of the container to point to. A value of null or empty string will be interpreted
* as pointing to the root container and will be replaced by "$root".
@@ -181,7 +185,12 @@ public BlobServiceVersion getServiceVersion() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainer#String}
+ *
+ *
+ * BlobContainerAsyncClient blobContainerAsyncClient =
+ * client.createBlobContainer("containerName").block();
+ *
+ *
*
* @param containerName Name of the container to create
* @return A {@link Mono} containing a {@link BlobContainerAsyncClient} used to interact with the container created.
@@ -202,7 +211,14 @@ public Mono createBlobContainer(String containerName)
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainerWithResponse#String-Map-PublicAccessType}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ *
+ * BlobContainerAsyncClient containerClient = client
+ * .createBlobContainerWithResponse("containerName", metadata, PublicAccessType.CONTAINER).block().getValue();
+ *
+ *
*
* @param containerName Name of the container to create
* @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any
@@ -238,7 +254,13 @@ Mono> createBlobContainerWithResponse(String
* Docs.
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainer#String}
+ *
+ *
+ * client.deleteBlobContainer("containerName").subscribe(
+ * response -> System.out.printf("Delete container completed%n"),
+ * error -> System.out.printf("Delete container failed: %s%n", error));
+ *
+ *
*
* @param containerName Name of the container to delete
* @return A {@link Mono} containing containing status code and HTTP headers
@@ -259,7 +281,13 @@ public Mono deleteBlobContainer(String containerName) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainerWithResponse#String-Context}
+ *
+ *
+ * Context context = new Context("Key", "Value");
+ * client.deleteBlobContainerWithResponse("containerName").subscribe(response ->
+ * System.out.printf("Delete container completed with status %d%n", response.getStatusCode()));
+ *
+ *
*
* @param containerName Name of the container to delete
* @return A {@link Mono} containing containing status code and HTTP headers
@@ -293,7 +321,11 @@ public String getAccountUrl() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.listBlobContainers}
+ *
+ *
+ * client.listBlobContainers().subscribe(container -> System.out.printf("Name: %s%n", container.getName()));
+ *
+ *
*
* @return A reactive response emitting the list of containers.
*/
@@ -312,7 +344,15 @@ public PagedFlux listBlobContainers() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.listBlobContainers#ListBlobContainersOptions}
+ *
+ *
+ * ListBlobContainersOptions options = new ListBlobContainersOptions()
+ * .setPrefix("containerNamePrefixToMatch")
+ * .setDetails(new BlobContainerListDetails().setRetrieveMetadata(true));
+ *
+ * client.listBlobContainers(options).subscribe(container -> System.out.printf("Name: %s%n", container.getName()));
+ *
+ *
*
* @param options A {@link ListBlobContainersOptions} which specifies what data should be returned by the service.
* @return A reactive response emitting the list of containers.
@@ -367,7 +407,11 @@ private Mono> listBlobContainersSegment(String
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.findBlobsByTag#String}
+ *
+ *
+ * client.findBlobsByTags("where=tag=value").subscribe(blob -> System.out.printf("Name: %s%n", blob.getName()));
+ *
+ *
*
* @param query Filters the results to return only blobs whose tags match the specified expression.
* @return A reactive response emitting the list of blobs.
@@ -383,7 +427,12 @@ public PagedFlux findBlobsByTags(String query) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncServiceClient.findBlobsByTag#FindBlobsOptions}
+ *
+ *
+ * client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10))
+ * .subscribe(blob -> System.out.printf("Name: %s%n", blob.getName()));
+ *
+ *
*
* @param options {@link FindBlobsOptions}
* @return A reactive response emitting the list of blobs.
@@ -484,7 +533,14 @@ private List toIncludeTypes(BlobContainerListDeta
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getProperties}
+ *
+ *
+ * client.getProperties().subscribe(response ->
+ * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
+ * response.getHourMetrics().isEnabled(),
+ * response.getMinuteMetrics().isEnabled()));
+ *
+ *
*
* @return A reactive response containing the storage account properties.
*/
@@ -503,7 +559,14 @@ public Mono getProperties() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getPropertiesWithResponse}
+ *
+ *
+ * client.getPropertiesWithResponse().subscribe(response ->
+ * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
+ * response.getValue().getHourMetrics().isEnabled(),
+ * response.getValue().getMinuteMetrics().isEnabled()));
+ *
+ *
*
* @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the storage
* account properties.
@@ -535,7 +598,28 @@ Mono> getPropertiesWithResponse(Context context)
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.setProperties#BlobServiceProperties}
+ *
+ *
+ * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3);
+ * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1);
+ *
+ * BlobServiceProperties properties = new BlobServiceProperties()
+ * .setLogging(new BlobAnalyticsLogging()
+ * .setWrite(true)
+ * .setDelete(true)
+ * .setRetentionPolicy(loggingRetentionPolicy))
+ * .setHourMetrics(new BlobMetrics()
+ * .setEnabled(true)
+ * .setRetentionPolicy(metricsRetentionPolicy))
+ * .setMinuteMetrics(new BlobMetrics()
+ * .setEnabled(true)
+ * .setRetentionPolicy(metricsRetentionPolicy));
+ *
+ * client.setProperties(properties).subscribe(
+ * response -> System.out.printf("Setting properties completed%n"),
+ * error -> System.out.printf("Setting properties failed: %s%n", error));
+ *
+ *
*
* @param properties Configures the service.
* @return A {@link Mono} containing the storage account properties.
@@ -558,7 +642,27 @@ public Mono setProperties(BlobServiceProperties properties) {
* If CORS policies are set, CORS parameters that are not set default to the empty string.
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.setPropertiesWithResponse#BlobServiceProperties}
+ *
+ *
+ * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3);
+ * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1);
+ *
+ * BlobServiceProperties properties = new BlobServiceProperties()
+ * .setLogging(new BlobAnalyticsLogging()
+ * .setWrite(true)
+ * .setDelete(true)
+ * .setRetentionPolicy(loggingRetentionPolicy))
+ * .setHourMetrics(new BlobMetrics()
+ * .setEnabled(true)
+ * .setRetentionPolicy(metricsRetentionPolicy))
+ * .setMinuteMetrics(new BlobMetrics()
+ * .setEnabled(true)
+ * .setRetentionPolicy(metricsRetentionPolicy));
+ *
+ * client.setPropertiesWithResponse(properties).subscribe(response ->
+ * System.out.printf("Setting properties completed with status %d%n", response.getStatusCode()));
+ *
+ *
*
* @param properties Configures the service.
* @return A {@link Mono} containing the storage account properties.
@@ -675,7 +779,12 @@ private void validateRetentionPolicy(BlobRetentionPolicy retentionPolicy, String
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getUserDelegationKey#OffsetDateTime-OffsetDateTime}
+ *
+ *
+ * client.getUserDelegationKey(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response ->
+ * System.out.printf("User delegation key: %s%n", response.getValue()));
+ *
+ *
*
* @param start Start time for the key's validity. Null indicates immediate start.
* @param expiry Expiration of the key's validity.
@@ -699,7 +808,12 @@ public Mono getUserDelegationKey(OffsetDateTime start, Offset
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getUserDelegationKeyWithResponse#OffsetDateTime-OffsetDateTime}
+ *
+ *
+ * client.getUserDelegationKeyWithResponse(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response ->
+ * System.out.printf("User delegation key: %s%n", response.getValue().getValue()));
+ *
+ *
*
* @param start Start time for the key's validity. Null indicates immediate start.
* @param expiry Expiration of the key's validity.
@@ -744,7 +858,12 @@ Mono> getUserDelegationKeyWithResponse(OffsetDateTim
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getStatistics}
+ *
+ *
+ * client.getStatistics().subscribe(response ->
+ * System.out.printf("Geo-replication status: %s%n", response.getGeoReplication().getStatus()));
+ *
+ *
*
* @return A {@link Mono} containing the storage account statistics.
*/
@@ -765,7 +884,12 @@ public Mono getStatistics() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getStatisticsWithResponse}
+ *
+ *
+ * client.getStatisticsWithResponse().subscribe(response ->
+ * System.out.printf("Geo-replication status: %s%n", response.getValue().getGeoReplication().getStatus()));
+ *
+ *
*
* @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} containing the
* storage account statistics.
@@ -793,7 +917,12 @@ Mono> getStatisticsWithResponse(Context context)
* Azure Docs.
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getAccountInfo}
+ *
+ *
+ * client.getAccountInfo().subscribe(response ->
+ * System.out.printf("Account kind: %s, SKU: %s%n", response.getAccountKind(), response.getSkuName()));
+ *
+ *
*
* @return A {@link Mono} containing containing the storage account info.
*/
@@ -812,7 +941,13 @@ public Mono getAccountInfo() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getAccountInfoWithResponse}
+ *
+ *
+ * client.getAccountInfoWithResponse().subscribe(response ->
+ * System.out.printf("Account kind: %s, SKU: %s%n", response.getValue().getAccountKind(),
+ * response.getValue().getSkuName()));
+ *
+ *
*
* @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} the storage account
* info.
@@ -851,7 +986,22 @@ public String getAccountName() {
*
* The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob
* containers and file shares.
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues}
+ *
+ *
+ * AccountSasPermission permissions = new AccountSasPermission()
+ * .setListPermission(true)
+ * .setReadPermission(true);
+ * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true);
+ * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true);
+ * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
+ *
+ * AccountSasSignatureValues sasValues =
+ * new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
+ *
+ * // Client must be authenticated via StorageSharedKeyCredential
+ * String sas = client.generateAccountSas(sasValues);
+ *
+ *
*
* @param accountSasSignatureValues {@link AccountSasSignatureValues}
*
@@ -868,7 +1018,22 @@ public String generateAccountSas(AccountSasSignatureValues accountSasSignatureVa
*
* The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob
* containers and file shares.
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues-Context}
+ *
+ *
+ * AccountSasPermission permissions = new AccountSasPermission()
+ * .setListPermission(true)
+ * .setReadPermission(true);
+ * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true);
+ * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true);
+ * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
+ *
+ * AccountSasSignatureValues sasValues =
+ * new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
+ *
+ * // Client must be authenticated via StorageSharedKeyCredential
+ * String sas = client.generateAccountSas(sasValues, new Context("key", "value"));
+ *
+ *
*
* @param accountSasSignatureValues {@link AccountSasSignatureValues}
* @param context Additional context that is passed through the code when generating a SAS.
@@ -901,7 +1066,19 @@ private void throwOnAnonymousAccess() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.undeleteBlobContainer#String-String}
+ *
+ *
+ * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions();
+ * listBlobContainersOptions.getDetails().setRetrieveDeleted(true);
+ * client.listBlobContainers(listBlobContainersOptions).flatMap(
+ * deletedContainer -> {
+ * Mono<BlobContainerAsyncClient> blobContainerClient = client.undeleteBlobContainer(
+ * deletedContainer.getName(), deletedContainer.getVersion());
+ * return blobContainerClient;
+ * }
+ * ).then().block();
+ *
+ *
*
* @param deletedContainerName The name of the previously deleted container.
* @param deletedContainerVersion The version of the previously deleted container.
@@ -927,7 +1104,20 @@ public Mono undeleteBlobContainer(
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.undeleteBlobContainerWithResponse#UndeleteBlobContainerOptions}
+ *
+ *
+ * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions();
+ * listBlobContainersOptions.getDetails().setRetrieveDeleted(true);
+ * client.listBlobContainers(listBlobContainersOptions).flatMap(
+ * deletedContainer -> {
+ * Mono<BlobContainerAsyncClient> blobContainerClient = client.undeleteBlobContainerWithResponse(
+ * new UndeleteBlobContainerOptions(deletedContainer.getName(), deletedContainer.getVersion()))
+ * .map(Response::getValue);
+ * return blobContainerClient;
+ * }
+ * ).then().block();
+ *
+ *
*
* @param options {@link UndeleteBlobContainerOptions}.
* @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains a {@link
@@ -963,7 +1153,8 @@ Mono> undeleteBlobContainerWithResponse(
// *
// * Code Samples
// *
-// * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.renameBlobContainer#String-String}
+// *
+// *
// *
// * @param sourceContainerName The current name of the container.
// * @param destinationContainerName The new name of the container.
@@ -981,7 +1172,8 @@ Mono> undeleteBlobContainerWithResponse(
// *
// * Code Samples
// *
-// * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.renameBlobContainerWithResponse#String-BlobContainerRenameOptions}
+// *
+// *
// *
// * @param sourceContainerName The current name of the container.
// * @param options {@link BlobContainerRenameOptions}
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java
index 7f15e0b63ee4..0a2e272e92e6 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java
@@ -63,7 +63,11 @@ public final class BlobServiceClient {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.getBlobContainerClient#String}
+ *
+ *
+ * BlobContainerClient blobContainerClient = client.getBlobContainerClient("containerName");
+ *
+ *
*
* @param containerName The name of the container to point to.
* @return A {@link BlobContainerClient} object pointing to the specified container
@@ -97,7 +101,11 @@ public BlobServiceVersion getServiceVersion() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.createBlobContainer#String}
+ *
+ *
+ * BlobContainerClient blobContainerClient = client.createBlobContainer("containerName");
+ *
+ *
*
* @param containerName Name of the container to create
* @return The {@link BlobContainerClient} used to interact with the container created.
@@ -114,7 +122,18 @@ public BlobContainerClient createBlobContainer(String containerName) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.createBlobContainerWithResponse#String-Map-PublicAccessType-Context}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Context context = new Context("Key", "Value");
+ *
+ * BlobContainerClient blobContainerClient = client.createBlobContainerWithResponse(
+ * "containerName",
+ * metadata,
+ * PublicAccessType.CONTAINER,
+ * context).getValue();
+ *
+ *
*
* @param containerName Name of the container to create
* @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any
@@ -139,7 +158,16 @@ public Response createBlobContainerWithResponse(String cont
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.deleteBlobContainer#String}
+ *
+ *
+ * try {
+ * client.deleteBlobContainer("container Name");
+ * System.out.printf("Delete container completed with status %n");
+ * } catch (UnsupportedOperationException error) {
+ * System.out.printf("Delete container failed: %s%n", error);
+ * }
+ *
+ *
*
* @param containerName Name of the container to delete
*/
@@ -178,7 +206,11 @@ public String getAccountUrl() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.listBlobContainers}
+ *
+ *
+ * client.listBlobContainers().forEach(container -> System.out.printf("Name: %s%n", container.getName()));
+ *
+ *
*
* @return The list of containers.
*/
@@ -194,7 +226,15 @@ public PagedIterable listBlobContainers() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.listBlobContainers#ListBlobContainersOptions-Duration}
+ *
+ *
+ * ListBlobContainersOptions options = new ListBlobContainersOptions()
+ * .setPrefix("containerNamePrefixToMatch")
+ * .setDetails(new BlobContainerListDetails().setRetrieveMetadata(true));
+ *
+ * client.listBlobContainers(options, timeout).forEach(container -> System.out.printf("Name: %s%n", container.getName()));
+ *
+ *
*
* @param options A {@link ListBlobContainersOptions} which specifies what data should be returned by the service.
* If iterating by page, the page size passed to byPage methods such as
@@ -214,7 +254,11 @@ public PagedIterable listBlobContainers(ListBlobContainersOpt
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.findBlobsByTag#String}
+ *
+ *
+ * client.findBlobsByTags("where=tag=value").forEach(blob -> System.out.printf("Name: %s%n", blob.getName()));
+ *
+ *
*
* @param query Filters the results to return only blobs whose tags match the specified expression.
* @return The list of blobs.
@@ -231,7 +275,13 @@ public PagedIterable findBlobsByTags(String query) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.findBlobsByTag#FindBlobsOptions-Duration}
+ *
+ *
+ * Context context = new Context("Key", "Value");
+ * client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10), timeout, context)
+ * .forEach(blob -> System.out.printf("Name: %s%n", blob.getName()));
+ *
+ *
*
* @param options {@link FindBlobsOptions}. If iterating by page, the page size passed to byPage methods such as
* {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options.
@@ -250,7 +300,15 @@ public PagedIterable findBlobsByTags(FindBlobsOptions options, D
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.getProperties}
+ *
+ *
+ * BlobServiceProperties properties = client.getProperties();
+ *
+ * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
+ * properties.getHourMetrics().isEnabled(),
+ * properties.getMinuteMetrics().isEnabled());
+ *
+ *
*
* @return The storage account properties.
*/
@@ -265,7 +323,16 @@ public BlobServiceProperties getProperties() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.getPropertiesWithResponse#Duration-Context}
+ *
+ *
+ * Context context = new Context("Key", "Value");
+ * BlobServiceProperties properties = client.getPropertiesWithResponse(timeout, context).getValue();
+ *
+ * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
+ * properties.getHourMetrics().isEnabled(),
+ * properties.getMinuteMetrics().isEnabled());
+ *
+ *
*
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @param context Additional context that is passed through the Http pipeline during the service call.
@@ -289,7 +356,31 @@ public Response getPropertiesWithResponse(Duration timeou
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.setProperties#BlobServiceProperties}
+ *
+ *
+ * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3);
+ * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1);
+ *
+ * BlobServiceProperties properties = new BlobServiceProperties()
+ * .setLogging(new BlobAnalyticsLogging()
+ * .setWrite(true)
+ * .setDelete(true)
+ * .setRetentionPolicy(loggingRetentionPolicy))
+ * .setHourMetrics(new BlobMetrics()
+ * .setEnabled(true)
+ * .setRetentionPolicy(metricsRetentionPolicy))
+ * .setMinuteMetrics(new BlobMetrics()
+ * .setEnabled(true)
+ * .setRetentionPolicy(metricsRetentionPolicy));
+ *
+ * try {
+ * client.setProperties(properties);
+ * System.out.printf("Setting properties completed%n");
+ * } catch (UnsupportedOperationException error) {
+ * System.out.printf("Setting properties failed: %s%n", error);
+ * }
+ *
+ *
*
* @param properties Configures the service.
*/
@@ -308,7 +399,29 @@ public void setProperties(BlobServiceProperties properties) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.setPropertiesWithResponse#BlobServiceProperties-Duration-Context}
+ *
+ *
+ * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3);
+ * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1);
+ *
+ * BlobServiceProperties properties = new BlobServiceProperties()
+ * .setLogging(new BlobAnalyticsLogging()
+ * .setWrite(true)
+ * .setDelete(true)
+ * .setRetentionPolicy(loggingRetentionPolicy))
+ * .setHourMetrics(new BlobMetrics()
+ * .setEnabled(true)
+ * .setRetentionPolicy(metricsRetentionPolicy))
+ * .setMinuteMetrics(new BlobMetrics()
+ * .setEnabled(true)
+ * .setRetentionPolicy(metricsRetentionPolicy));
+ *
+ * Context context = new Context("Key", "Value");
+ *
+ * System.out.printf("Setting properties completed with status %d%n",
+ * client.setPropertiesWithResponse(properties, timeout, context).getStatusCode());
+ *
+ *
*
* @param properties Configures the service.
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
@@ -329,7 +442,12 @@ public Response setPropertiesWithResponse(BlobServiceProperties properties
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.getUserDelegationKey#OffsetDateTime-OffsetDateTime}
+ *
+ *
+ * System.out.printf("User delegation key: %s%n",
+ * client.getUserDelegationKey(delegationKeyStartTime, delegationKeyExpiryTime));
+ *
+ *
*
* @param start Start time for the key's validity. Null indicates immediate start.
* @param expiry Expiration of the key's validity.
@@ -346,7 +464,12 @@ public UserDelegationKey getUserDelegationKey(OffsetDateTime start, OffsetDateTi
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.getUserDelegationKeyWithResponse#OffsetDateTime-OffsetDateTime-Duration-Context}
+ *
+ *
+ * System.out.printf("User delegation key: %s%n",
+ * client.getUserDelegationKeyWithResponse(delegationKeyStartTime, delegationKeyExpiryTime, timeout, context));
+ *
+ *
*
* @param start Start time for the key's validity. Null indicates immediate start.
* @param expiry Expiration of the key's validity.
@@ -371,7 +494,12 @@ public Response getUserDelegationKeyWithResponse(OffsetDateTi
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.getStatistics}
+ *
+ *
+ * System.out.printf("Geo-replication status: %s%n",
+ * client.getStatistics().getGeoReplication().getStatus());
+ *
+ *
*
* @return The storage account statistics.
*/
@@ -388,7 +516,12 @@ public BlobServiceStatistics getStatistics() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.getStatisticsWithResponse#Duration-Context}
+ *
+ *
+ * System.out.printf("Geo-replication status: %s%n",
+ * client.getStatisticsWithResponse(timeout, context).getValue().getGeoReplication().getStatus());
+ *
+ *
*
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @param context Additional context that is passed through the Http pipeline during the service call.
@@ -407,7 +540,13 @@ public Response getStatisticsWithResponse(Duration timeou
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.getAccountInfo}
+ *
+ *
+ * StorageAccountInfo accountInfo = client.getAccountInfo();
+ *
+ * System.out.printf("Account kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());
+ *
+ *
*
* @return The storage account info.
*/
@@ -448,7 +587,22 @@ public String getAccountName() {
* Generating an account SAS
* The snippet below generates an AccountSasSignatureValues object that lasts for two days and gives the user
* read and list access to blob and file shares.
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues}
+ *
+ *
+ * AccountSasPermission permissions = new AccountSasPermission()
+ * .setListPermission(true)
+ * .setReadPermission(true);
+ * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true);
+ * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true);
+ * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
+ *
+ * AccountSasSignatureValues sasValues =
+ * new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
+ *
+ * // Client must be authenticated via StorageSharedKeyCredential
+ * String sas = client.generateAccountSas(sasValues);
+ *
+ *
*
* @param accountSasSignatureValues {@link AccountSasSignatureValues}
*
@@ -467,7 +621,22 @@ public String generateAccountSas(AccountSasSignatureValues accountSasSignatureVa
* Generating an account SAS
* The snippet below generates an AccountSasSignatureValues object that lasts for two days and gives the user
* read and list access to blob and file shares.
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues-Context}
+ *
+ *
+ * AccountSasPermission permissions = new AccountSasPermission()
+ * .setListPermission(true)
+ * .setReadPermission(true);
+ * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true);
+ * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true);
+ * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
+ *
+ * AccountSasSignatureValues sasValues =
+ * new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
+ *
+ * // Client must be authenticated via StorageSharedKeyCredential
+ * String sas = client.generateAccountSas(sasValues, new Context("key", "value"));
+ *
+ *
*
* @param accountSasSignatureValues {@link AccountSasSignatureValues}
* @param context Additional context that is passed through the code when generating a SAS.
@@ -487,7 +656,18 @@ public String generateAccountSas(AccountSasSignatureValues accountSasSignatureVa
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.undeleteBlobContainer#String-String}
+ *
+ *
+ * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions();
+ * listBlobContainersOptions.getDetails().setRetrieveDeleted(true);
+ * client.listBlobContainers(listBlobContainersOptions, null).forEach(
+ * deletedContainer -> {
+ * BlobContainerClient blobContainerClient = client.undeleteBlobContainer(
+ * deletedContainer.getName(), deletedContainer.getVersion());
+ * }
+ * );
+ *
+ *
*
* @param deletedContainerName The name of the previously deleted container.
* @param deletedContainerVersion The version of the previously deleted container.
@@ -511,7 +691,19 @@ public BlobContainerClient undeleteBlobContainer(String deletedContainerName, St
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.undeleteBlobContainerWithResponse#UndeleteBlobContainerOptions-Duration-Context}
+ *
+ *
+ * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions();
+ * listBlobContainersOptions.getDetails().setRetrieveDeleted(true);
+ * client.listBlobContainers(listBlobContainersOptions, null).forEach(
+ * deletedContainer -> {
+ * BlobContainerClient blobContainerClient = client.undeleteBlobContainerWithResponse(
+ * new UndeleteBlobContainerOptions(deletedContainer.getName(), deletedContainer.getVersion()),
+ * timeout, context).getValue();
+ * }
+ * );
+ *
+ *
*
* @param options {@link UndeleteBlobContainerOptions}.
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
@@ -534,7 +726,8 @@ public Response undeleteBlobContainerWithResponse(
// *
// * Code Samples
// *
-// * {@codesnippet com.azure.storage.blob.BlobServiceClient.renameBlobContainer#String-String}
+// *
+// *
// *
// * @param sourceContainerName The current name of the container.
// * @param destinationContainerName The new name of the container.
@@ -551,7 +744,8 @@ public Response undeleteBlobContainerWithResponse(
// *
// * Code Samples
// *
-// * {@codesnippet com.azure.storage.blob.BlobServiceClient.renameBlobContainerWithResponse#String-BlobContainerRenameOptions-Duration-Context}
+// *
+// *
// *
// * @param options {@link BlobContainerRenameOptions}
// * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java
index cefa209cdfd6..7f8ba61608f6 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java
@@ -147,7 +147,12 @@ public AppendBlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedK
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.create}
+ *
+ *
+ * client.create().subscribe(response ->
+ * System.out.printf("Created AppendBlob at %s%n", response.getLastModified()));
+ *
+ *
*
* @return A {@link Mono} containing the information of the created appended blob.
*/
@@ -165,7 +170,13 @@ public Mono create() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.create#boolean}
+ *
+ *
+ * boolean overwrite = false; // Default behavior
+ * client.create(overwrite).subscribe(response ->
+ * System.out.printf("Created AppendBlob at %s%n", response.getLastModified()));
+ *
+ *
*
* @param overwrite Whether or not to overwrite, should data exist on the blob.
*
@@ -191,7 +202,19 @@ public Mono create(boolean overwrite) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.createWithResponse#BlobHttpHeaders-Map-BlobRequestConditions}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentType("binary")
+ * .setContentLanguage("en-US");
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.createWithResponse(headers, metadata, requestConditions).subscribe(response ->
+ * System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified()));
+ *
+ *
*
* @param headers {@link BlobHttpHeaders}
* @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any
@@ -214,7 +237,21 @@ public Mono> createWithResponse(BlobHttpHeaders headers
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.createWithResponse#AppendBlobCreateOptions}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentType("binary")
+ * .setContentLanguage("en-US");
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Map<String, String> tags = Collections.singletonMap("tag", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata)
+ * .setTags(tags).setRequestConditions(requestConditions)).subscribe(response ->
+ * System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified()));
+ *
+ *
*
* @param options {@link AppendBlobCreateOptions}
* @return A {@link Mono} containing {@link Response} whose {@link Response#getValue() value} contains the created
@@ -262,7 +299,12 @@ Mono> createWithResponse(AppendBlobCreateOptions option
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlock#Flux-long}
+ *
+ *
+ * client.appendBlock(data, length).subscribe(response ->
+ * System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount()));
+ *
+ *
*
* @param data The data to write to the blob. Note that this {@code Flux} 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.
@@ -287,7 +329,17 @@ public Mono appendBlock(Flux data, long length) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockWithResponse#Flux-long-byte-AppendBlobRequestConditions}
+ *
+ *
+ * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
+ * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions()
+ * .setAppendPosition(POSITION)
+ * .setMaxSize(maxSize);
+ *
+ * client.appendBlockWithResponse(data, length, md5, requestConditions).subscribe(response ->
+ * System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount()));
+ *
+ *
*
* @param data The data to write to the blob. Note that this {@code Flux} 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.
@@ -339,7 +391,12 @@ Mono> appendBlockWithResponse(Flux data, lo
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrl#String-BlobRange}
+ *
+ *
+ * client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).subscribe(response ->
+ * System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount()));
+ *
+ *
*
* @param 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
@@ -362,7 +419,20 @@ public Mono appendBlockFromUrl(String sourceUrl, BlobRange sourc
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrlWithResponse#String-BlobRange-byte-AppendBlobRequestConditions-BlobRequestConditions}
+ *
+ *
+ * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions()
+ * .setAppendPosition(POSITION)
+ * .setMaxSize(maxSize);
+ *
+ * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null,
+ * appendBlobRequestConditions, modifiedRequestConditions).subscribe(response ->
+ * System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount()));
+ *
+ *
*
* @param 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
@@ -395,7 +465,22 @@ public Mono> appendBlockFromUrlWithResponse(String sour
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrlWithResponse#AppendBlobAppendBlockFromUrlOptions}
+ *
+ *
+ * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions()
+ * .setAppendPosition(POSITION)
+ * .setMaxSize(maxSize);
+ *
+ * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl)
+ * .setSourceRange(new BlobRange(offset, count))
+ * .setDestinationRequestConditions(appendBlobRequestConditions)
+ * .setSourceRequestConditions(modifiedRequestConditions)).subscribe(response ->
+ * System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount()));
+ *
+ *
*
* @param options Parameters for the operation.
* @return A {@link Mono} containing {@link Response} whose {@link Response#getValue() value} contains the append
@@ -450,7 +535,11 @@ Mono> appendBlockFromUrlWithResponse(AppendBlobAppendBl
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.seal}
+ *
+ *
+ * client.seal().subscribe(response -> System.out.println("Sealed AppendBlob"));
+ *
+ *
*
* @return A reactive response signalling completion.
*/
@@ -469,7 +558,15 @@ public Mono seal() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.sealWithResponse#AppendBlobSealOptions}
+ *
+ *
+ * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions))
+ * .subscribe(response -> System.out.println("Sealed AppendBlob"));
+ *
+ *
*
* @param options {@link AppendBlobSealOptions}
* @return A reactive response signalling completion.
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java
index 0f035b026c09..64f71c4a2f7a 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java
@@ -128,7 +128,11 @@ public BlobOutputStream getBlobOutputStream(AppendBlobRequestConditions requestC
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.create}
+ *
+ *
+ * System.out.printf("Created AppendBlob at %s%n", client.create().getLastModified());
+ *
+ *
*
* @return The information of the created appended blob.
*/
@@ -142,7 +146,12 @@ public AppendBlobItem create() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.create#boolean}
+ *
+ *
+ * boolean overwrite = false; // Default value
+ * System.out.printf("Created AppendBlob at %s%n", client.create(overwrite).getLastModified());
+ *
+ *
*
* @param overwrite Whether or not to overwrite, should data exist on the blob.
*
@@ -164,7 +173,22 @@ public AppendBlobItem create(boolean overwrite) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.createWithResponse#BlobHttpHeaders-Map-BlobRequestConditions-Duration-Context}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentType("binary")
+ * .setContentLanguage("en-US");
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ * Context context = new Context("key", "value");
+ *
+ * System.out.printf("Created AppendBlob at %s%n",
+ * client.createWithResponse(headers, metadata, requestConditions, timeout, context).getValue()
+ * .getLastModified());
+ *
+ *
*
* @param headers {@link BlobHttpHeaders}
* @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any
@@ -188,7 +212,23 @@ public Response createWithResponse(BlobHttpHeaders headers, Map<
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.createWithResponse#AppendBlobCreateOptions-Duration-Context}
+ *
+ *
+ * BlobHttpHeaders headers = new BlobHttpHeaders()
+ * .setContentType("binary")
+ * .setContentLanguage("en-US");
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Map<String, String> tags = Collections.singletonMap("tags", "value");
+ * BlobRequestConditions requestConditions = new BlobRequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ * Context context = new Context("key", "value");
+ *
+ * System.out.printf("Created AppendBlob at %s%n",
+ * client.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata)
+ * .setTags(tags).setRequestConditions(requestConditions), timeout, context).getValue()
+ * .getLastModified());
+ *
+ *
*
* @param options {@link AppendBlobCreateOptions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
@@ -210,7 +250,12 @@ public Response createWithResponse(AppendBlobCreateOptions optio
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlock#InputStream-long}
+ *
+ *
+ * System.out.printf("AppendBlob has %d committed blocks%n",
+ * client.appendBlock(data, length).getBlobCommittedBlockCount());
+ *
+ *
*
* @param data The data to write to the blob. The data must be markable. This is in order to support retries. If
* the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream.
@@ -232,7 +277,19 @@ public AppendBlobItem appendBlock(InputStream data, long length) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlockWithResponse#InputStream-long-byte-AppendBlobRequestConditions-Duration-Context}
+ *
+ *
+ * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
+ * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions()
+ * .setAppendPosition(POSITION)
+ * .setMaxSize(maxSize);
+ * Context context = new Context("key", "value");
+ *
+ * System.out.printf("AppendBlob has %d committed blocks%n",
+ * client.appendBlockWithResponse(data, length, md5, requestConditions, timeout, context)
+ * .getValue().getBlobCommittedBlockCount());
+ *
+ *
*
* @param data The data to write to the blob. The data must be markable. This is in order to support retries. If
* the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream.
@@ -265,7 +322,12 @@ public Response appendBlockWithResponse(InputStream data, long l
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrl#String-BlobRange}
+ *
+ *
+ * System.out.printf("AppendBlob has %d committed blocks%n",
+ * client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).getBlobCommittedBlockCount());
+ *
+ *
*
* @param 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
@@ -284,7 +346,23 @@ public AppendBlobItem appendBlockFromUrl(String sourceUrl, BlobRange sourceRange
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrlWithResponse#String-BlobRange-byte-AppendBlobRequestConditions-BlobRequestConditions-Duration-Context}
+ *
+ *
+ * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions()
+ * .setAppendPosition(POSITION)
+ * .setMaxSize(maxSize);
+ *
+ * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * Context context = new Context("key", "value");
+ *
+ * System.out.printf("AppendBlob has %d committed blocks%n",
+ * client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null,
+ * appendBlobRequestConditions, modifiedRequestConditions, timeout,
+ * context).getValue().getBlobCommittedBlockCount());
+ *
+ *
*
* @param 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
@@ -315,7 +393,25 @@ public Response appendBlockFromUrlWithResponse(String sourceUrl,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrlWithResponse#AppendBlobAppendBlockFromUrlOptions-Duration-Context}
+ *
+ *
+ * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions()
+ * .setAppendPosition(POSITION)
+ * .setMaxSize(maxSize);
+ *
+ * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ *
+ * Context context = new Context("key", "value");
+ *
+ * System.out.printf("AppendBlob has %d committed blocks%n",
+ * client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl)
+ * .setSourceRange(new BlobRange(offset, count))
+ * .setDestinationRequestConditions(appendBlobRequestConditions)
+ * .setSourceRequestConditions(modifiedRequestConditions), timeout,
+ * context).getValue().getBlobCommittedBlockCount());
+ *
+ *
*
* @param options options for the operation
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
@@ -335,7 +431,12 @@ public Response appendBlockFromUrlWithResponse(AppendBlobAppendB
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.seal}
+ *
+ *
+ * client.seal();
+ * System.out.println("Sealed AppendBlob");
+ *
+ *
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void seal() {
@@ -347,7 +448,16 @@ public void seal() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.sealWithResponse#AppendBlobSealOptions-Duration-Context}
+ *
+ *
+ * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId)
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
+ * Context context = new Context("key", "value");
+ *
+ * client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions), timeout, context);
+ * System.out.println("Sealed AppendBlob");
+ *
+ *
*
* @param options {@link AppendBlobSealOptions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java
index 477eaa64f3f5..3d1c4108efa2 100644
--- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java
+++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java
@@ -329,7 +329,12 @@ public String getBlobUrl() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getContainerName}
+ *
+ *
+ * String containerName = client.getContainerName();
+ * System.out.println("The name of the container is " + containerName);
+ *
+ *
*
* @return The name of the container.
*/
@@ -342,7 +347,12 @@ public final String getContainerName() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getContainerAsyncClient}
+ *
+ *
+ * BlobContainerAsyncClient containerClient = client.getContainerAsyncClient();
+ * System.out.println("The name of the container is " + containerClient.getBlobContainerName());
+ *
+ *
*
* @return {@link BlobContainerAsyncClient}
*/
@@ -366,7 +376,12 @@ final BlobContainerClientBuilder getContainerClientBuilder() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getBlobName}
+ *
+ *
+ * String blobName = client.getBlobName();
+ * System.out.println("The name of the blob is " + blobName);
+ *
+ *
*
* @return The decoded name of the blob.
*/
@@ -442,7 +457,11 @@ public String getVersionId() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.exists}
+ *
+ *
+ * client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
+ *
+ *
*
* @return true if the blob exists, false if it doesn't
*/
@@ -460,7 +479,11 @@ public Mono exists() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.existsWithResponse}
+ *
+ *
+ * client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
+ *
+ *
*
* @return true if the blob exists, false if it doesn't
*/
@@ -502,7 +525,12 @@ Mono> existsWithResponse(Context context) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#String-Duration}
+ *
+ *
+ * client.beginCopy(url, Duration.ofSeconds(3))
+ * .subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -529,7 +557,21 @@ public PollerFlux beginCopy(String sourceUrl, Duration pollI
* Starting a copy operation
* Starting a copy operation and polling on the responses.
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#String-Map-AccessTier-RehydratePriority-RequestConditions-BlobRequestConditions-Duration}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * RequestConditions modifiedRequestConditions = new RequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
+ * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
+ *
+ * client.beginCopy(url, metadata, AccessTier.HOT, RehydratePriority.STANDARD,
+ * modifiedRequestConditions, blobRequestConditions, Duration.ofSeconds(2))
+ * .subscribe(response -> {
+ * BlobCopyInfo info = response.getValue();
+ * System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus());
+ * });
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -570,11 +612,52 @@ public PollerFlux beginCopy(String sourceUrl, MapStarting a copy operation
* Starting a copy operation and polling on the responses.
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#BlobBeginCopyOptions}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Map<String, String> tags = Collections.singletonMap("tag", "value");
+ * BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
+ * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
+ *
+ * client.beginCopy(new BlobBeginCopyOptions(url).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
+ * .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions)
+ * .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2)))
+ * .subscribe(response -> {
+ * BlobCopyInfo info = response.getValue();
+ * System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus());
+ * });
+ *
+ *
*
* Cancelling a copy operation
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopyFromUrlCancel#BlobBeginCopyOptions}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Map<String, String> tags = Collections.singletonMap("tag", "value");
+ * BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
+ * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
+ *
+ * PollerFlux<BlobCopyInfo, Void> poller = client.beginCopy(new BlobBeginCopyOptions(url)
+ * .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
+ * .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions)
+ * .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2)));
+ *
+ * poller.take(Duration.ofMinutes(30))
+ * .last()
+ * .flatMap(asyncPollResponse -> {
+ * if (!asyncPollResponse.getStatus().isComplete()) {
+ * return asyncPollResponse
+ * .cancelOperation()
+ * .then(Mono.error(new RuntimeException("Blob copy taking long time, "
+ * + "operation is cancelled!")));
+ * }
+ * return Mono.just(asyncPollResponse);
+ * }).block();
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -733,7 +816,11 @@ private Mono> onPoll(PollResponse pollR
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.abortCopyFromUrl#String}
+ *
+ *
+ * client.abortCopyFromUrl(copyId).doOnSuccess(response -> System.out.println("Aborted copy from URL"));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -758,7 +845,12 @@ public Mono abortCopyFromUrl(String copyId) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.abortCopyFromUrlWithResponse#String-String}
+ *
+ *
+ * client.abortCopyFromUrlWithResponse(copyId, leaseId)
+ * .subscribe(response -> System.out.printf("Aborted copy completed with status %d%n", response.getStatusCode()));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -793,7 +885,11 @@ Mono> abortCopyFromUrlWithResponse(String copyId, String leaseId,
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrl#String}
+ *
+ *
+ * client.copyFromUrl(url).subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -818,7 +914,17 @@ public Mono copyFromUrl(String copySource) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrlWithResponse#String-Map-AccessTier-RequestConditions-BlobRequestConditions}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * RequestConditions modifiedRequestConditions = new RequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
+ * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
+ *
+ * client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions, blobRequestConditions)
+ * .subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -851,7 +957,20 @@ public Mono> copyFromUrlWithResponse(String copySource, MapCode Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrlWithResponse#BlobCopyFromUrlOptions}
+ *
+ *
+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
+ * Map<String, String> tags = Collections.singletonMap("tag", "value");
+ * RequestConditions modifiedRequestConditions = new RequestConditions()
+ * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
+ * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
+ *
+ * client.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(url).setMetadata(metadata).setTags(tags)
+ * .setTier(AccessTier.HOT).setSourceRequestConditions(modifiedRequestConditions)
+ * .setDestinationRequestConditions(blobRequestConditions))
+ * .subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -904,7 +1023,18 @@ Mono> copyFromUrlWithResponse(BlobCopyFromUrlOptions options, C
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.download}
+ *
+ *
+ * ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
+ * client.download().subscribe(piece -> {
+ * try {
+ * downloadData.write(piece.array());
+ * } catch (IOException ex) {
+ * throw new UncheckedIOException(ex);
+ * }
+ * });
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -924,7 +1054,18 @@ public Flux download() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadStream}
+ *
+ *
+ * ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
+ * client.downloadStream().subscribe(piece -> {
+ * try {
+ * downloadData.write(piece.array());
+ * } catch (IOException ex) {
+ * throw new UncheckedIOException(ex);
+ * }
+ * });
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -947,7 +1088,13 @@ public Flux downloadStream() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.BlobAsyncClient.downloadContent}
+ *
+ *
+ * client.downloadContent().subscribe(data -> {
+ * System.out.printf("Downloaded %s", data.toString());
+ * });
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -973,7 +1120,23 @@ public Mono downloadContent() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean}
+ *
+ *
+ * BlobRange range = new BlobRange(1024, (long) 2048);
+ * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
+ *
+ * client.downloadWithResponse(range, options, null, false).subscribe(response -> {
+ * ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
+ * response.getValue().subscribe(piece -> {
+ * try {
+ * downloadData.write(piece.array());
+ * } catch (IOException ex) {
+ * throw new UncheckedIOException(ex);
+ * }
+ * });
+ * });
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -999,7 +1162,23 @@ public Mono downloadWithResponse(BlobRange range, Dow
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadStreamWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean}
+ *
+ *
+ * BlobRange range = new BlobRange(1024, (long) 2048);
+ * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
+ *
+ * client.downloadStreamWithResponse(range, options, null, false).subscribe(response -> {
+ * ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
+ * response.getValue().subscribe(piece -> {
+ * try {
+ * downloadData.write(piece.array());
+ * } catch (IOException ex) {
+ * throw new UncheckedIOException(ex);
+ * }
+ * });
+ * });
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1028,7 +1207,16 @@ public Mono downloadStreamWithResponse(BlobRange rang
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadContentWithResponse#DownloadRetryOptions-BlobRequestConditions}
+ *
+ *
+ * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
+ *
+ * client.downloadContentWithResponse(options, null).subscribe(response -> {
+ * BinaryData content = response.getValue();
+ * System.out.println(content.toString());
+ * });
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1146,7 +1334,11 @@ private Mono downloadRange(BlobRange range, BlobRequestCondition
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFile#String}
+ *
+ *
+ * client.downloadToFile(file).subscribe(response -> System.out.println("Completed download to file"));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1167,7 +1359,12 @@ public Mono downloadToFile(String filePath) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFile#String-boolean}
+ *
+ *
+ * boolean overwrite = false; // Default value
+ * client.downloadToFile(file, overwrite).subscribe(response -> System.out.println("Completed download to file"));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1203,7 +1400,15 @@ public Mono downloadToFile(String filePath, boolean overwrite) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean}
+ *
+ *
+ * BlobRange range = new BlobRange(1024, 2048L);
+ * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
+ *
+ * client.downloadToFileWithResponse(file, range, null, options, null, false)
+ * .subscribe(response -> System.out.println("Completed download to file"));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1236,7 +1441,17 @@ public Mono> downloadToFileWithResponse(String filePath
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Set}
+ *
+ *
+ * BlobRange blobRange = new BlobRange(1024, 2048L);
+ * DownloadRetryOptions downloadRetryOptions = new DownloadRetryOptions().setMaxRetryRequests(5);
+ * Set<OpenOption> openOptions = new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW,
+ * StandardOpenOption.WRITE, StandardOpenOption.READ)); // Default options
+ *
+ * client.downloadToFileWithResponse(file, blobRange, null, downloadRetryOptions, null, false, openOptions)
+ * .subscribe(response -> System.out.println("Completed download to file"));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1279,7 +1494,16 @@ public Mono> downloadToFileWithResponse(String filePath
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#BlobDownloadToFileOptions}
+ *
+ *
+ * client.downloadToFileWithResponse(new BlobDownloadToFileOptions(file)
+ * .setRange(new BlobRange(1024, 2018L))
+ * .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(5))
+ * .setOpenOptions(new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE,
+ * StandardOpenOption.READ))))
+ * .subscribe(response -> System.out.println("Completed download to file"));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1427,7 +1651,11 @@ private void downloadToFileCleanup(AsynchronousFileChannel channel, String fileP
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.delete}
+ *
+ *
+ * client.delete().doOnSuccess(response -> System.out.println("Completed delete"));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1450,7 +1678,12 @@ public Mono delete() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions}
+ *
+ *
+ * client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null)
+ * .subscribe(response -> System.out.printf("Delete completed with status %d%n", response.getStatusCode()));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1488,7 +1721,12 @@ Mono> deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnap
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getProperties}
+ *
+ *
+ * client.getProperties().subscribe(response ->
+ * System.out.printf("Type: %s, Size: %d%n", response.getBlobType(), response.getBlobSize()));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1509,7 +1747,15 @@ public Mono getProperties() {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getPropertiesWithResponse#BlobRequestConditions}
+ *
+ *
+ * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
+ *
+ * client.getPropertiesWithResponse(requestConditions).subscribe(
+ * response -> System.out.printf("Type: %s, Size: %d%n", response.getValue().getBlobType(),
+ * response.getValue().getBlobSize()));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1566,7 +1812,13 @@ Mono> getPropertiesWithResponse(BlobRequestConditions r
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setHttpHeaders#BlobHttpHeaders}
+ *
+ *
+ * client.setHttpHeaders(new BlobHttpHeaders()
+ * .setContentLanguage("en-US")
+ * .setContentType("binary"));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1589,7 +1841,18 @@ public Mono setHttpHeaders(BlobHttpHeaders headers) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setHttpHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions}
+ *
+ *
+ * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
+ *
+ * client.setHttpHeadersWithResponse(new BlobHttpHeaders()
+ * .setContentLanguage("en-US")
+ * .setContentType("binary"), requestConditions).subscribe(
+ * response ->
+ * System.out.printf("Set HTTP headers completed with status %d%n",
+ * response.getStatusCode()));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1625,7 +1888,11 @@ Mono> setHttpHeadersWithResponse(BlobHttpHeaders headers, BlobReq
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setMetadata#Map}
+ *
+ *
+ * client.setMetadata(Collections.singletonMap("metadata", "value"));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1649,7 +1916,14 @@ public Mono setMetadata(Map metadata) {
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setMetadataWithResponse#Map-BlobRequestConditions}
+ *
+ *
+ * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
+ *
+ * client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions)
+ * .subscribe(response -> System.out.printf("Set metadata completed with status %d%n", response.getStatusCode()));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1687,7 +1961,12 @@ Mono> setMetadataWithResponse(Map metadata, BlobR
*
* Code Samples
*
- * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getTags}
+ *
+ *
+ * client.getTags().subscribe(response ->
+ * System.out.printf("Num tags: %d%n", response.size()));
+ *
+ *
*
* For more information, see the
* Azure Docs
@@ -1704,7 +1983,12 @@ public Mono