Skip to content

Azure java with maven.

March 27, 2012

I am writing small java client application to upload large files to azure blob storage. So I started with setting up sample java project using maven. It is very basic stuff, still I am going ahead and dumping it here.

mvn archetype:generate -DartifactId=upload-client -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

You need to add maven dependency in your pom file


now you are ready to roll.

I wanted to upload the big file in parallel and fortunately java azure SDK provide built in capability to upload the blob using multiple thread to avoid latency. Below is code snip to show that.

CloudBlobClient cloudBlobClient = storageaccount

//thread count
cloudBlobClient.setSingleBlobPutThresholdInBytes(64* Constants.MB);
//create container if it does not exist
CloudBlobContainer uploadLoc = cloudBlobClient.getContainerReference(“mycontainer”);
CloudBlockBlob blockBlob = uploadLoc.getBlockBlobReference(file.getName());
blockBlob.upload(new FileInputStream(file), file.length());

for details refer to the link below.

From → Tech

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: