使用下面的代码,我收到一条错误消息:
The specified blob does not exist
当我调试我的代码时,在 .CreateBlobContainer
-我可以看到指定的 bob 被创建,然后在我的代码之外我手动复制一个文本文件并将其粘贴到我的 blob 中。然后当我到达时代码的最后一行,.DownloadToStream
,它抛出异常错误,指出指定的 blob 不存在。 --即使鲍勃确实存在
下面的示例代码有什么问题:
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
这是异常消息。
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:
最佳答案
我刚刚重新启动了我的 webrole,它就开始工作了
关于c# - 指定的 blob 不存在——即使 bob 确实存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19217940/