Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Hosted-services / Azure

What is Microsoft Azure Blob Storage and How To Use It From Visual Studio

4.91/5 (7 votes)
17 Jul 2015CPOL4 min read 21.3K  
This article describes blob storage service and how to use it from Visual Studio.

Contents

Introduction

This article describes Microsoft Azure Blob Storage and will demonstrate common use of Azure Blob storage service using Visual Studio.

What is Blob Storage?

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., public or private.

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.

Storage Account

To access Azure Storage service, we must have a Storage Account. An account can contain unlimited number of containers.

Container

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.

Blob

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.

How to Create a Storage Account?

To work with blobs, you must have a Storage account. To create a Storage account login to your Azure account, follow the below steps:

Steps

  1. Login to your Azure account.
  2. Switch to Azure Portal.
  3. Select Storage from workspace list and click on it.
  4. Click on New button at bottom left corner.

  5. Click on Quick Create.
  6. Enter the name of storage account. I have taken "strgproclass".
  7. Fill Location and Replication. Location should be selected as the closest location to you customers of this storage.
  8. 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.

How to Create a Container?

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.

Steps

  1. Click on the newly created Storage Account. It will open a new window.
  2. 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.

  3. After clicking on Container, it will pop up a window.
  4. Enter the Name of the container and select accessibility. (See Naming Convention of a Container)
  5. Click on Tick mark.

    It will create a container. Below is the snapshot of created container, i.e., "images".

Upto now, we have created Storage Account, i.e., "strgproclass" and Container i.e. "images".

Now, we are going to use this Container using our Visual Studio.

Naming Convention of A Container

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.

Uploading Blob Files from Visual Studio

To upload Blobs from Visual Studio, follow the below steps:

Steps

  1. Open Visual Studio.
  2. Go to server explorer.
  3. Click on Azure, it will prompt you to login to your Azure account.
  4. Fill the credentials and Login to your Azure account.
  5. After successful connection, navigate to storage.

  6. Now click on the container, here its name is "images".
  7. After clicking on container, it will open a new window.
  8. 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:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)