This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Azure Blob storage is Microsoft's object storage solution for the cloud. Blobstorage is optimized for storing massive amounts of unstructured data.Unstructured data is data that does not adhere to a particular data model ordefinition, such as text or binary data.
Source code |API reference documentation |REST API documentation |Product documentation |Samples
Please include the azure-sdk-bom to your project to take dependency on GA version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number.To learn more about the BOM, see theAZURE SDK BOM README.
<dependencyManagement> <dependencies> <dependency> <groupId>com.azure</groupId> <artifactId>azure-sdk-bom</artifactId> <version>{bom_version_to_target}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies></dependencyManagement>
and then include the direct dependency in the dependencies section without the version tag.
<dependencies> <dependency> <groupId>com.azure</groupId> <artifactId>azure-storage-blob-batch</artifactId> </dependency></dependencies>
If you want to take dependency on a particular version of the library that is not present in the BOM,add the direct dependency to your project as follows.
<dependency> <groupId>com.azure</groupId> <artifactId>azure-storage-blob-batch</artifactId> <version>12.26.1</version></dependency>
To create a Storage Account you can use theAzure Portal orAzure CLI.
az storage account create \ --resource-group <resource-group-name> \ --name <storage-account-name> \ --location <location>
Blob storage is designed for:
The following sections provide several code snippets covering some of the most common Azure Storage Blob Batch tasks, including:
Create a BlobBatchClient from aBlobServiceClient.
BlobBatchClient blobBatchClient = new BlobBatchClientBuilder(blobServiceClient).buildClient();
blobBatchClient.deleteBlobs(blobUrls, DeleteSnapshotsOptionType.INCLUDE).forEach(response -> System.out.printf("Deleting blob with URL %s completed with status code %d%n", response.getRequest().getUrl(), response.getStatusCode()));
blobBatchClient.setBlobsAccessTier(blobUrls, AccessTier.HOT).forEach(response -> System.out.printf("Setting blob access tier with URL %s completed with status code %d%n", response.getRequest().getUrl(), response.getStatusCode()));
Deleting blobs in a batch that have different pre-requisites.
BlobBatch blobBatch = blobBatchClient.getBlobBatch();// Delete a blob.Response<Void> deleteResponse = blobBatch.deleteBlob(blobUrl);// Delete a specific blob snapshot.Response<Void> deleteSnapshotResponse = blobBatch.deleteBlob(blobUrlWithSnapshot, DeleteSnapshotsOptionType.ONLY, null);// Delete a blob that has a lease.Response<Void> deleteWithLeaseResponse = blobBatch.deleteBlob(blobUrlWithLease, DeleteSnapshotsOptionType.INCLUDE, new BlobRequestConditions() .setLeaseId("leaseId"));blobBatchClient.submitBatch(blobBatch);System.out.printf("Deleting blob completed with status code %d%n", deleteResponse.getStatusCode());System.out.printf("Deleting blob snapshot completed with status code %d%n", deleteSnapshotResponse.getStatusCode());System.out.printf("Deleting blob with lease completed with status code %d%n", deleteWithLeaseResponse.getStatusCode());
SettingAccessTier
on blobs in batch that have different pre-requisites.
BlobBatch blobBatch = blobBatchClient.getBlobBatch();// Set AccessTier on a blob.Response<Void> setTierResponse = blobBatch.setBlobAccessTier(blobUrl, AccessTier.COOL);// Set AccessTier on another blob.Response<Void> setTierResponse2 = blobBatch.setBlobAccessTier(blobUrl2, AccessTier.ARCHIVE);// Set AccessTier on a blob that has a lease.Response<Void> setTierWithLeaseResponse = blobBatch.setBlobAccessTier(blobUrlWithLease, AccessTier.HOT, "leaseId");blobBatchClient.submitBatch(blobBatch);System.out.printf("Set AccessTier on blob completed with status code %d%n", setTierResponse.getStatusCode());System.out.printf("Set AccessTier on blob completed with status code %d%n", setTierResponse2.getStatusCode());System.out.printf("Set AccessTier on blob with lease completed with status code %d%n", setTierWithLeaseResponse.getStatusCode());
When interacts with blobs using this Java client library, errors returned by the service correspond to the same HTTPstatus codes returned forREST API requests. For example, if you try to retrieve a container or blob thatdoesn't exist in your Storage Account, a404
error is returned, indicatingNot Found
.
All client libraries by default use the Netty HTTP client. Adding the above dependency will automatically configurethe client library to use the Netty HTTP client. Configuring or changing the HTTP client is detailed in theHTTP clients wiki.
All client libraries, by default, use the Tomcat-native Boring SSL library to enable native-level performance for SSLoperations. The Boring SSL library is an uber jar containing native libraries for Linux / macOS / Windows, and providesbetter performance compared to the default SSL implementation within the JDK. For more information, including how toreduce the dependency size, refer to theperformance tuning section of the wiki.
Get started with ourBlob Batch samples:
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visithttps://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted theMicrosoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Was this page helpful?
Was this page helpful?