Azure Storage And Storage Services

Introduction

Azure Storage means scalability, durability, and availability of the data -- what every application requires. An Azure Storage Account gives a platform to store a small amount of data to a large amount, with a fee. As you use it, this means whenever you need to call back an amount of storage data from the Storage Account, you only pay for how much you store and only when you use it. It supports cross platform clients and these clients can also request the data from Storage through REST APIs. It supports a variety of programming languages.

Before we upload and download in Azure Storage Account, we should know a bit about the various terms which will be used, as we move forward in this article.

In order to use the Services in Azure Storage, we must have a Storage Account. To create an Azure Storage Account, go to Azure Portal

New -> Data +Storage --> Storage Account as shown in the following screenshot:



After clicking Azure Storage Account, create Storage Account, fill in the name and all other properties accordingly.



After creating a Storage Account, it will be listed in All Items in Azure Portal with the running status. Location and subscription type is shown below:

 

Let us discuss the various types of the Services offered by Storage Account:

types

Storage Account generally provides four types of Service to store the data namely Blob, Table, Queue and File storages. Let us know about these Services, one by one .



BLOB is any type of the document or the media file, which is of the media or the text type. BLOB is a Binary Large Object. BLOB data can be public or private, which means, it may be accessed from the outside world. It stores an unstructured data object. A storage account can contain the number of containers and a container can contain any number of BLOBS.

Table storage is used to store the structured data in a key-value way.The purpose of introducing Key Value storage is to make access to the data fast, which helps to retrieve a large amount of data from the storage.

The queues are used to message the processing, while making the communication between Azure Cloud Services. Single Storage Account can have any number of queues and a queue contains the messages.

File Storage: For file sharing.

Connection String of Storage Account

If we need to store the files, document, or any media file to one of the Services offered by Azure Storage, using .NET Code(Visual Studio), we need to create the connection between Azure Storage Account and Application. For this, we need to configure the connection string in Web.Config file in our Application.

For the connection string, open the Storage Account in the Azure Portal and click on Manage Access Keys, as shown below:



A pop up with StorageAccount Name and access keys appears. Copy the Storage Account name and the access key, as shown below:



In the Web.Config file with HTTP/HTTPS, as an endpoint protocol to connect with Azure Storage Account.

  1. <appSettings>  
  2. <add key="storageAccountName" value="ishrissstorage" />  
  3. <add key="storageAccountKey" value="************************" />  
  4. </appSettings>  

To start with Azure Service, we need to install Windows Azure SDK for .NET. Also, install the packages like Windows Azure Storage to be used in Azure classes, interfaces and enumerations.

How to get Connection String for Web.Config

Similar to ConfigurationManager, the class is used to get the connection string, CloudConfigurationManager class is used with GetSetting method to get the connection string from Web.Config file. Once we get Azure Storage Connection String, we are required to parse it to Cloud StorageAccount type.

CloudStorageAccount.Parse(string connectionString)

  1. string _accountName = CloudConfigurationManager.GetSetting("storageAccountName");  
  2. string _accountKey = CloudConfigurationManager.GetSetting("storageAccountKey");  
  3. string _storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", _accountName, _accountKey);  
  4. CloudStorageAccount _storageAccount = CloudStorageAccount.Parse(_storageConnectionString);  

Once, we get the Storage Connection string, we can do lots of stuff like creating a container, creating a BLOB within it, uploading and downloading the file, create Azure CDN, CDN endpoints, get data via CDN.

Closure

By going through this article, we learned a bit about Azure Storage Service, what services storage offers, how to use Azure Storage Accounts in .NET Applications,  and what are the things that can be done by using Azure Storage Account.


Similar Articles