繁体   English   中英

将存储升级到4.0.1后,Azure存储容器ListBlobs抛出Uri NULL异常

[英]Azure Storage Container ListBlobs throw Uri NULL exception after upgrade storage to 4.0.1

当我将azure存储从1.8升级到4.0.1时,以下代码不再起作用。

var myUri = new Uri(generatedURLwithSAS);
var sasContainer = new CloudBlobContainer(myUri);
var result0 = sasContainer.ListBlobs();
Console.WriteLine(result0);

使用存储4.0.1时,代码将抛出异常:

Exception Type: Microsoft.WindowsAzure.Storage.StorageException
Exception: Value cannot be null.
Parameter name: uriString
Stack Trace: 
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd,     IRetryPolicy policy, OperationContext operationContext)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.<>c__DisplayClassf.<ListBlobs>b__e(IContinuationToken token)at Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility.<LazyEnumerable>d__0`1.MoveNext()

Exception Type: System.ArgumentNullException
Exception: Value cannot be null.
Parameter name: uriString
Stack Trace: 
at System.Uri..ctor(String uriString)
at Microsoft.WindowsAzure.Storage.Blob.Protocol.ListBlobsResponse.<ParseXml>d__0.MoveNext()
at Microsoft.WindowsAzure.Storage.Shared.Protocol.ResponseParsingBase`1.<ParseXmlAndClose>d__6.MoveNext()
at Microsoft.WindowsAzure.Storage.Shared.Protocol.ResponseParsingBase`1.<get_ObjectsToParse>d__0.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.<ListBlobsImpl>b__4a(RESTCommand`1 cmd, HttpWebResponse resp, OperationContext ctx)
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ProcessEndOfRequest[T](ExecutionState`1 executionState)
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)

是否知道如何使它正常工作?

我知道我可以使用account和accountkey创建凭据来访问容器并列出blob,但是我想知道如何仅使用SAS的blob路径来做到这一点。

任何建议将不胜感激。

您在下面提供的SAS令牌是使用旧版本的Storage Client Library生成的。 客户端库只能与REST协议的一个版本通信。 使用旧客户端生成的SAS令牌会强制使用旧的REST版本服务端进行操作,但是新客户端使用2014 REST版本语义来解释响应。 这是因为在这些REST版本之间ListBlobs XML响应中的更改发生了重大变化,因此新的客户端库无法正确解析该XML。

以下是有关可能有用的SAS令牌的某些更改的更多信息,包括api-version参数: http : //blogs.msdn.com/b/windowsazurestorage/archive/2014/05/14/what-s- Microsoft-azure-storage-at-teched-2014.aspx的新功能

请尝试使用客户端库的4.0.1版本重新生成令牌,并且您的代码应能按预期工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM