Implementing Blob Tiering - Understanding Blob Storage: Part Eight

These days, data stored in the cloud is growing at an exponential pace. To manage costs for your expanding storage needs, it's helpful to organize your data based on attributes like frequency-of-access and planned retention period to optimize costs. Data stored in the cloud can be different in terms of how it is generated, processed, and accessed over its lifetime. Some data is actively accessed and modified throughout its lifetime. Some data is accessed frequently early in its lifetime, with access dropping drastically as the data ages. Some data remains idle in the cloud and is rarely if ever, accessed once stored.

Azure Storage offers three storage tiers for Blob object storage so that you can store your data most cost-effectively depending on its usage.

  • Hot storage tier - optimized for storing data that is accessed frequently
  • Cool storage tier - optimized for storing data that is infrequently accessed and stored for at least 30 days.
  • Archive storage tier - optimized for storing data that is rarely accessed and stored for at least 180 days

Only the hot and cool storage tiers (not archive) can be set at the account level. All three tiers can be set at the object level. In this article, we will see how to implement the tiering both via the portal and C# application.

Step 1

We have to upgrade our storage account to General Purpose v2 (GPv2) as General Purpose v1 (GPv1) account won't support tiering. Go to Configuration blade of your storage account, where you can see a button to upgrade. Click on Upgrade and type the storage account name once more for confirmation and click on upgrade again which will initiate the upgrade process.

Azure 

Step 2

Once upgraded you can see the option to choose the Access tiering at the account level. Choose one as per your choice and click on save to make the changes take effect.

Azure 

Step 3

To configure tiering at blob level, either double-click the blob file or right-click and select Properties, which will open the properties window where you can change the tier from the dropdown list and save the changes.

Azure 

Step 4

Now, we will see how to do the same with the C# application that we are working with. Copy and paste the following code into the main method. Here, we are getting a reference to the BlockBlob and setting the tier of the BlockBlob.

  1. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(  
  2. CloudConfigurationManager.GetSetting("StorageConnection"));  
  3. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();  
  4. CloudBlobContainer container = blobClient.GetContainerReference("images");  
  5. CloudBlockBlob blockBlob = container.GetBlockBlobReference("img2.jpeg");  
  6. blockBlob.SetStandardBlobTier(StandardBlobTier.Hot);  
  7. Console.WriteLine(blockBlob.Properties.StandardBlobTier);  
  8. Console.ReadKey();  
Azure

 Step 5

Run your application and you can see the result in the console window. You can also verify the same via the portal.
 
Azure 
 
Azure