How to upload a file to Azure Blob using Spring Boot?
Tags: azure, programming, opensource, devops
Published: 2021-11-08 14:34:32

Hello👋, Its Rohan Kadam😊

Today cloud is becoming come standard for the development of any software. We used the cloud in every aspect of the programming cycle be it uploading our code to [Github ](https://medium.com/javarevisited/7-best-courses-to-master-git-and-github-for-programmers-d671859a68b2?source=---------9------------------)or Gitlab or be it using Google Drive or Dropbox or uploading our personal files. In the article, we are going to understand how we can implement file** upload to Azure Blob Using [Spring Boot](https://medium.com/javarevisited/top-10-courses-to-learn-spring-boot-in-2020-best-of-lot-6ffce88a1b6e)**.

![How to upload a file to Azure Blob Using Spring Boot?](https://cdn-images-1.medium.com/max/6000/1*tzvH8h7KT6vuFZjSatf8sA.jpeg)

### What Does Blob Storage Mean?

Blob storage is a feature in Microsoft Azure that lets developers store unstructured data in Microsoft’s cloud platform. This data can be accessed from anywhere in the world and can include audio, video and text. Blobs are grouped into “containers” that are tied to user accounts. Blobs can be manipulated by using any programming language. Blobs are widely used by streaming companies with high volumes of audio and video data.

### Why used Blob Storage?

Blob storage is ideal for:

* Accessing images or documents directly to devices.

* Storing files for distributed access.

* Streaming video and audio.

* Storing data for backup and restore disaster recovery, and archiving.

* Storing data for analysis by an on-premises or Azure-hosted service

### How to implement blob Storage?

Blob Storage is widely been used by the industry today for developing great user-friendly apps. Its best known for storing files, images and binary data. Today we are going to implement the Azure Blob using the spring boot and the programming language Java. In this part of we going to cover the Read, Write and Upload operations for the same.

### Step 1: How to generate Spring Boot Project?
[**Spring Initializr**](https://start.spring.io/)

### Step 2: Which dependencies should I include?

![Dependencies](https://cdn-images-1.medium.com/max/2720/1*2aMKmXTE1xAakZdoFY_ZFA.png)

### Step 3: What will the configuration be for my Azure?

When we talk of configuration is we required three main parts

 1. Blob Container Name

 2. Account Key — Secret Key

 3. Blob Container Endpoint

![Credits: Microsoft](https://cdn-images-1.medium.com/max/2000/1*mnsXLS2Id_oUinI5HH1jVg.png)

![](https://cdn-images-1.medium.com/max/2404/1*rnflQLltovS_bR8ba0rItg.png)

Note:- Need to get the above from the Azure website.

### Step 4:- Need to Create a Controller endpoint for Upload & Read file.

**1 →How to upload files to Azure Blob Storage?**

![Upload File to Blob Storage](https://cdn-images-1.medium.com/max/3364/1*D2mgF8EqN1VFRZ2VO-nNoQ.png)

**2 →How to read files from Azure Blob Storage?**

![Read File From Blob Storage](https://cdn-images-1.medium.com/max/2468/1*-rAVHk2JHlezGFGUL6y6xQ.png)

**3 →How to write files to Azure Blob Storage?**

![Write Blob From Storage](https://cdn-images-1.medium.com/max/3100/1*ulPxjmgjvlw4Fxb2UbWopA.png)

### Step 5: Postman Endpoint Upload File.

![azure_blob_upload_file](https://cdn-images-1.medium.com/max/2000/1*LpRngwHh_lYRPXwSTte8bQ.png)

### Step 6: Postman Endpoint for reading File.

![azure_blob_read_file](https://cdn-images-1.medium.com/max/2000/1*RvIVKbXyUFSFuo526cENaQ.png)

### Conclusion:-

In the article, we tried to answers many questions related to Azure Blob and how to implement the same using Spring boot. Blob storage has widely been used to store unstructured data such as text, images or binary etc are used by many fortune 500 companies to provide service to their users.

Please do share and like💖 if you find the article useful. Follow me on medium [Rohan Ravindra Kadam](undefined) and on Twitter at [**rohankadam25](https://twitter.com/rohankadam25)**

### Bibliography:-
[**How to use the Spring Boot Starter for Azure Storage**](https://docs.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-storage)

![Thank You, Viewers — Rohan Kadam](https://cdn-images-1.medium.com/max/2800/1*f9TMjifJVReTlh93qJ845Q.png)