This article describes Microsoft Azure Blob Storage and will demonstrate common use of Azure Blob storage service using Visual Studio.
It is a service of Microsoft Azure which stores large amount of unstructured data of any format. These stored data in the blob can be accessed from anywhere in the world via HTTP or HTTPS. We can set the accessibility of data in a blob, i.e.,
Common features of Blob storage:
- Stores any kind of data
- Documents and images are directly served to the browser
- Provides streaming for video and audio file
- Provides Backup and Recovery option
The following figure shows the different components of Blob Storage service.
To access Azure Storage service, we must have a Storage Account. An account can contain unlimited number of containers.
Using a container, we can group a set of blobs. All blobs must be in a container. A container can store an unlimited number of blobs.
A Blob is basically a file of any type or of any size. Azure Storage Service contains two types of blobs : block and page blobs. A single Block Blob can be max of upto 200 GB in size. Page blobs can be up to 1 TB in size. Here, I am using Block blob in my example.
To work with blobs, you must have a Storage account. To create a Storage account login to your Azure account, follow the below steps:
- Login to your Azure account.
- Switch to Azure Portal.
- Select Storage from workspace list and click on it.
- Click on New button at bottom left corner.
- Click on Quick Create.
- Enter the name of storage account. I have taken "
- Fill Location and Replication. Location should be selected as the closest location to you customers of this storage.
- Click on Tick Mark (Bottom right corner of the same screen.)
After clicking on Create Storage Account, you will have a newly created Storage Account.
Here, the red square box shows our newly created Storage Account, i.e.,
strgproclass. After successful creation of a storage account, we need to create a container on the created storage.
As we know that Blobs resides in a container, so now our requirement is to create a container.
Below are the steps to create a container.
- Click on the newly created Storage Account. It will open a new window.
- Click on container.
At the bottom of the window, click on "Manage Access Keys" and copy the Primary key. This Storage Account will be accessible using this key.
- After clicking on Container, it will pop up a window.
- Enter the Name of the container and select accessibility. (See Naming Convention of a Container)
- Click on Tick mark.
It will create a container. Below is the snapshot of created container, i.e., "
Upto now, we have created Storage Account, i.e., "
strgproclass" and Container i.e. "
Now, we are going to use this Container using our Visual Studio.
Microsoft has given some rules for the naming convention of a container. According to this, a container name should be a valid DNS name and confirms the following rules:
- It should be in all lowercase.
- Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character.
- Each dash (-) character must be immediately preceeded and followed by a letter or number; consecutive dashes are not permitted in container names.
- Container names must be from 3 through 63 characters long.
To upload Blobs from Visual Studio, follow the below steps:
- Open Visual Studio.
- Go to server explorer.
- Click on Azure, it will prompt you to login to your Azure account.
- Fill the credentials and Login to your Azure account.
- After successful connection, navigate to storage.
- Now click on the container, here its name is "
- After clicking on container, it will open a new window.
- At header, you will get an upload button. Click on the button to upload any Blob(file).
After clicking on upload button, a file browser window will open. Browse your file here and click on OK.
You will get a window with one Uri. This Uri is for accessing your Blob.
Click on the Uri, you will get your Blob on the browser. This means using this Uri, you can get your Blob sitting from any part of the world.
Here is our uploaded blob in the below snapshot: