How to download the files from azure blob storage using java


  • First, create the CloudStorageAccount object using the STORAGE_CONNECTION_STRING(AccountName and Account Key).
  • Create the serviceClient using the CloudStorageAccount object.
  • Using the listBlobs method to get all list of objects in the container.
  • Using the iterator object to get the details of each object.
  • If you want to delete the object using the delete method.
File Download Process in azure using java

import; import; import; import; import; import; import; import; import; import; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Janardhan Randhi * Date : Feb 4 2019 * Description : This class download files from the azure blob storage container.and deleted the file in container. * * */ public class AzureBlobFileDownload { public static final String STORAGE_CONNECTION_STRING = "DefaultEndpointsProtocol=https;" + "AccountName=Ram;" //Your account name. + "AccountKey=key"; //your account key. private static final Logger LOGGER = Logger.getLogger(AzureBlobFileDownload.class.getName()); public static void main(String[] args) { try { CloudStorageAccount account = CloudStorageAccount.parse(STORAGE_CONNECTION_STRING); CloudBlobClient serviceClient = account.createCloudBlobClient(); File file = new File("C:\\Users\\Administrator\\Desktop\\SI-Azure_Download"); // File file = new File("D:\\Test"); if (!file.exists()) { file.mkdir(); } // Accessing the container to download files CloudBlobContainer container = serviceClient.getContainerReference("Janardhan"); // Creating a backup container if does not exists. // CloudBlobContainer container1 = serviceClient.getContainerReference("backupsicontainer"); container.createIfNotExists(); // container1.createIfNotExists(); // Iterating through all the blobs in the container Iterable blobs = container.listBlobs(); for (ListBlobItem blob : blobs) { // Accessing the file name from the blobs in the container inorder to create the same in the backup container. String[] str1 = blob.getUri().toString().split("/"); File f = new File(file.getAbsolutePath() + "\\" +str1[4] ); CloudBlockBlob cloudBlob = (CloudBlockBlob) blob; // Downloading files from the container cloudBlob.downloadToFile(f.toString()); cloudBlob.delete(); LOGGER.log(Level.INFO, "File downloaded successfylly & deleted from the container"); break; } } catch (StorageException | IOException | URISyntaxException | InvalidKeyException exception) { LOGGER.log(Level.SEVERE, exception.getMessage()); System.exit(-1); } } }


I’m the Founder of I am a Professional Blogger, Application developer, YouTuber. I’ve been blogging since 2015.I spend a lot of time learning new techniques and actively help other people learn web development through a variety of help groups and writing web development tutorials for my website and blog about advancements in web design and development.Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie or planning a trip to someplace I've never been before.

12 Responses to "How to download the files from azure blob storage using java "

  1. I am smart bitches

  2. i am smart too SOB(son of bitch)

  3. Thank you Janardhan. Can you provide sample program for reading and writing files within Container. Need to copy file from ContainerA and move to ContainerB.

  4. 우리카지노사이트 더킹카지노 샌즈카지노 퍼스트카지노 예스카지노 슈퍼카지노 개츠비카지노 33카지노 월드카지노 메리트카지노

  5. 우리카지노사이트 더킹카지노 샌즈카지노 퍼스트카지노 예스카지노 슈퍼카지노 개츠비카지노 33카지노 월드카지노 메리트카지노

  6. 우리카지노사이트 더킹카지노 샌즈카지노 퍼스트카지노 예스카지노 슈퍼카지노 개츠비카지노 33카지노 월드카지노 메리트카지노

  7. 우리카지노사이트 더킹카지노 샌즈카지노 퍼스트카지노 예스카지노 슈퍼카지노 개츠비카지노 33카지노 월드카지노 메리트카지노

  8. Hi,

    I have a use case to upload larger number of files to my app server hosted in azure app service. Since upload of such huge files can interrupt with application server, we have planned to use Azure storage for storing the files. The files are format and each zipped folder has around 100 pdf files. Could you please suggest what is the right option to go for. Is it Azure blob storage or File Storage?

  9. I copied your code and tried to compile , but getting the below error, can you please help me out to get rid of this error?

    Error:(47, 38) java: incompatible types: java.lang.Object cannot be converted to

  10. If you want to save a large amount of your money then click the link. So, visit here skillz discount code

  11. After three years of inception, we started to offer sales and services online and established a PTE company incorporated and operating in Singapore. After the entry into UAE, we added oil & gas controls, detectors, and sensors to our portfolio.

    Visit Website: isolonline