c# - 指定的 blob 不存在——即使 bob 确实存在

标签 c# azure azure-storage azure-blob-storage azure-table-storage

使用下面的代码,我收到一条错误消息:

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/

相关文章:

azure - azure函数或azure逻辑应用程序中是否有Azure文件共享的触发器?

c# - 具有继承类型的列表的序列化

c# - 如何通过代理服务器使用 API 上传到 YouTube

session - AZURE ACS 将身份与多个登录关联起来

python - 在 Azure Web 应用程序中使用 PIP

c# - Azure 表存储错误地插入日期属性

Azure 逻辑应用程序 - Google 云端硬盘复制文件 - 连接器无法从 Azure 文件共享上传文件

C# FindBySubjectName 函数

c# - 将 Redis 与 SignalR 结合使用

适用于个人的 Azure Synapse 计费模型?