Tuesday, April 17, 2012

Windows Azure Blob - Unable to read data from the transport connection: The connection was closed

I had file of 1.5GB uploaded on Azure Blob Storage. My supervisor asked me to write a simple console application to download this huge file of 1.5 GB from Blob storage and send to the client. As my client don’t wanted to have complexities involved in using Windows Azure Cloud Storage Explorer (he never wants any type of complexities other than Notepad... anyways) I started with Console Application with simple code to download the blob.
I added the reference of Microsoft.WindowsAzure.ServiceRuntime.dll and Microsoft.WindowsAzure.StorageClient.dll in my application. Then wrote following code in Main method –
CloudBlobClient blobClient = new CloudBlobClient("https://myStorageService.blob.core.windows.net/");
CloudBlob blob = blobClient.GetBlobReference("mycontainer/job2/part-00000");

            blob.DownloadToFile(AppDomain.CurrentDomain.BaseDirectory + "HeatMapperInput.txt", options);
catch (Exception ex)
Console.WriteLine("=------------------------------------" + ex.StackTrace);

I ran the console application. 28MB out of 1.5 GB of file was downloaded and suddently received following error –
“Unable to read data from the transport connection: The connection was closed.”
It was really strange and I had received this error for the first time. After digging in Blob Storage I found this –