Azure Storage libraries for Java


Read and write blob (object) data, files, and messages from your Java applications with Azure Storage.

To get started with Azure Storage, see How to use Blob storage from Java.

Client library

Use a Shared Key, SAS token or an OAuth token from the Azure Active Directory to authorize with Azure Storage services. Then use the client libraries' classes and methods to work with blob, file, or queue storage.

Add a dependency to your Maven pom.xml file to use the client library in your project.

Dependency for Blob service:


Dependency for Queue service:



Write an image file from the local file system into a new blob in an existing Azure Storage blob container.

// Retrieve the credentials and initialize SharedKeyCredentials
String accountName = System.getenv("AZURE_STORAGE_ACCOUNT");
String accountKey = System.getenv("AZURE_STORAGE_ACCESS_KEY");

// Create a BlockBlobURL to run operations on Block Blobs. Alternatively create a ServiceURL, or ContainerURL for operations on Blob service, and Blob containers
SharedKeyCredentials creds = new SharedKeyCredentials(accountName, accountKey);

// We are using a default pipeline here, you can learn more about it at
final BlockBlobURL blobURL = new BlockBlobURL(
    new URL("https://" + accountName + ""), 
        StorageURL.createPipeline(creds, new PipelineOptions())

AsynchronousFileChannel fileChannel ="myimage.jpg"));
TransferManager.uploadFileToBlockBlob(fileChannel, blobURL,0, null).blockingGet();

Management API

Create and manage Azure Storage accounts and connection keys with the management API.

Add a dependency to your Maven pom.xml file to use the management API in your project.



Create a new Azure Storage account in your subscription and retrieve its access keys.

StorageAccount storageAccount = azure.storageAccounts().define(storageAccountName)

// get a list of storage account keys related to the account
List<StorageAccountKey> storageAccountKeys = storageAccount.getKeys();
for(StorageAccountKey key : storageAccountKeys)    {
    System.out.println("Key name: " + key.keyName() + " with value "+ key.value());


Azure Storage SDK for Java Read and write objects to blob storage
Read and write messages with queues