With my code below, I am getting an error message:
The specified blob does not exist
when I debug my code ,at .CreateBlobContainer
-I can see the specified bob got created ,Then outside the my code I manually copied and pasted a text file into my blob.Then when I reach the last line of the code ,.DownloadToStream
,it throws exception error saying the specified blob doesnot exist. --even when the bob does exists
What's wrong with my sample code below:
string testContainerName = "xyz"+Common.GenerateRandomEightCharString().ToLower();
var testBlobClient = BlobClientFactory.CreateBlobClient(true);
var testContainer = BlobClientFactory.CreateBlobContainer(testBlobClient, testContainerName);
var zipOutputStream = new ZipOutputStream(Response.OutputStream)
{
CompressionLevel = CompressionLevel.Default
};
zipOutputStream.CompressionLevel = CompressionLevel.Default;
zipOutputStream.EnableZip64 = Zip64Option.AsNecessary;
CloudBlob testBlob = testBlobClient.GetBlobReference(testBlobClient.BaseUri.ToString() + testContainerName);
zipOutputStream.PutNextEntry(testContainerName);
BlobRequestOptions options = new BlobRequestOptions();
options.Timeout = TimeSpan.FromSeconds(20.0);
testBlob.DownloadToStream(zipOutputStream, options); //Exception error here
Here is the exception message .
Microsoft.WindowsAzure.StorageClient.StorageClientException was unhandled by user code
HResult=-2146233088
Message=The specified blob does not exist.
Source=Microsoft.WindowsAzure.StorageClient
StackTrace:
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.Execute()
at Microsoft.WindowsAzure.StorageClient.RequestWithRetry.RequestWithRetrySyncImpl[TResult](ShouldRetry retryOracle, SynchronousTask`1 syncTask)
at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteSyncTaskWithRetry[TResult](SynchronousTask`1 syncTask, RetryPolicy policy)
at Microsoft.WindowsAzure.StorageClient.CloudBlob.DownloadToStream(Stream target, BlobRequestOptions options)
at ............................
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
InnerException: System.Net.WebException
HResult=-2146233079
Message=The remote server returned an error: (404) Not Found.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponseSync(WebRequest req, EventHandler`1 handler, Object sender)
InnerException:
.CreateBlobContainer
-I can see the specified bob got created ,Then outside the my code I manually copied and pasted a text file into my blob.Then when I reach the last line of the code ,.DownloadToStream
,it throws exception error saying the specified blob doesnot exist – Lee