Blob Operations On Azure Storage - Part Four


This article will help you to work with the copy operations on Azure Blob Storage and will offer an overview of CDN (Content Delivery Network) on Azure Storage.


Here are a few links that you should go through before heading towards Azure Storage Security,

  • Click here for Azure Storage - Creating A Container Using Visual Studio.
  • Click here for Part One - Azure Storage components – Blob.
  • Click here for Part Two - Azure Blob Storage Service – Uploading a Blob and Set Container propertied with metadata.
  • Click here for Part Three – Blob Security on Azure Storage.

Copy blob operations asynchronously between containers

By this demo, we will be working with copy operations asynchronously and programmatically using Visual Studio.

On the Azure portal, you can perform Delete, but not Copy. This you can perform programmatically on the below blob. You can go for the Azure portal and check the container from the storage account which was created in the previous demo.

Azure Storage

Open the project solution file which was created in the previous demo and add the below code to perform the copy operation to your program.cs.

Use the CopyBlob API, as shown below, to copy a Blob asynchronously.

Code Snippet

  1. //CopyBlob  
  2. CopyBlob(container);  

Code Explanation

Here, we are adding a CopyBlob() method to the main program.

Azure Storage

Code Snippet

  1. static void CopyBlob(CloudBlobContainer container)  
  2.   {  
  3.       CloudBlockBlob blockBlob = container.GetBlockBlobReference("AzureStorageAccount");  
  4.       CloudBlockBlob copyToBlockblob = container.GetBlockBlobReference("AzureStorageAccount-Copy");  
  5.       copyToBlockblob.StartCopyAsync(new Uri(blockBlob.Uri.AbsoluteUri));  
  6.   }  

Code Explanation

The above code gets the reference to the source followed by the reference to the destination and calls StartCopyAsync method to perform an asynchronous copy between blobs, including the contents, properties, and metadata.

Azure Storage

Press F5 or click “Start” to run the program.

Note – It is highly recommended to build and clean the solution before you run.

Azure Storage

Azure Storage

Azure Storage

After running the solution, get back to the Azure portal and check for the copied container on the respective Azure Storage account.

Azure Storage

Content Delivery Network

Content Delivery Network is called a CDN in short. The Azure Content Delivery Network (CDN) is designed to send audio, video, images, and other files faster and more reliably to the customers using servers that are closest to the users. This will increase the speed and availability resulting in significant user experience improvements.

The improvements can create better performance for your apps and services, global distributed network, highly scalable infrastructure, active redundancy and failover, high availability and reliability with robust security.

How Does Azure CDN Work?

A user requests a file using a URL with a specific domain name such as – DNS routes the request to the best performing point of presence (POP) location. Usually, this is POP that is geographically closest to the user. If the edge servers in the POP do not have the file in their cache, the edge server requests the file from the origin – the origin can be an Azure web app, Azure cloud service, Azure Storage account, or any publicly accessible web server.

The origin returns the file to the edge server, including optional HTTP headers describing the file’s Time To Live (TTL), the edge server caches the file and returns the file to the original requestor – the file remains cached on the edge server until the TTL expires, if the origin didn’t specify a TTL, the default TTL is seven days.

Additional users may, then, request the same file using that same URL, and may also be directed to the same POP. If the TTL for the file hasn’t expired, the edge server returns the file from the cache. This results in a faster, more responsive user experience.


Here, we have gone through the Azure storage copy operations and an overview about CDN. 

Recommended Ebook

Architecting Modern Web Applications with ASP.NET Core and Microsoft Azure

Download Now!
Similar Articles