Working with Azure Storage in Web Application

Dheeraj Kumar Gunti

Reading Time : ( words)

Hi All, Welcome back to Knowledge Base.

Azure Storage is the cloud storage solution for modern applications that rely on durability, availability, and scalability to meet the needs of their customers. Cloud computing enables new scenarios for applications requiring scalable, durable, and highly available storage for their data.

Azure storage provides four services: Blob storage, Table storage, Queue storage, and File storage.

  • Blob Storage, which stores unstructured object data. A blob can be any type of text or binary data, such as a document, media file, or application installer. Blob storage is also referred to as Object storage.
  • Table Storage, which stores structured datasets. Table storage is a NoSQL key-attribute data store, which allows for rapid development and fast access to large quantities of data.
  • Queue Storage provides reliable messaging for workflow processing and for communication between components of cloud services.
  • File Storage offers shared storage for legacy applications.

Today we will see how to create a Azure Storage and creating a small application which stores data in the storage. Lets get started.

Open http://manage.windowsazure.com

Click on the New button.


Choose the below flow and specify the name for the storage. Note: Storage name should be in small letters. Choose the Location and Click on Create Storage Account.



Once the storage account is created as below. Click on the storage account name and it will navigate to account details.



The default page is Dashboard where we can see the statistics of the blobs, tables etc. We can see even the endpoints of all the services under Storage account.



Click on Containers and you can able to see no containers. Click on Create Container. We can create a container from code or directly from here. It depends on the process which we choose.



On clicking on the Create Container, we can able to see a window which takes Container name and access scope (Private, Public Container, Public Blob). Choose Public Container and specify a container name and click on create. Note: Container name should be in small letters.




Once the creation in done. We will start creating a web application. In this sample I have chosen ASP.NET Core Application with .NET Framework. We can choose any template based on the requirement.

Once the project is created. We need to include WindowsAzure.Storage from Nuget Packages. Once the package is included, open HomeController and have some declarations as below.

To resolve issue with respect to the new classes we are using, Include the below namespaces.
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.Auth;
.

Specify the account name and primary key from the Container created. Choose Manage Keys in the bottom of the page in the portal.

Following is the code to get the name of the container and the list of blobs under that container.

For showing container and blobs and creating a blob, we will have a sample UI as below.

Have a UploadFiles Action Method in the controller which performs getting file from the input and uploading it to the storage.

Run the application and upload files to the storage.


Sample Application

Happy Coding....