【问题标题】:Azure File Share ListFilesAndDirectoriesSegmentedAsync() Fails AuthenticationAzure 文件共享 ListFilesAndDirectoriesSegmentedAsync() 身份验证失败
【发布时间】:2019-01-26 22:31:24
【问题描述】:

我正在使用 c#.net api 处理 azure 文件存储,但无法成功列出文件共享中的所有文件。我的代码错误:

Microsoft.WindowsAzure.Storage:服务器未能验证 要求。确保形成 Authorization 标头的值 正确包括签名。

以下代码完美运行,因此我与文件共享“temp”的连接很好:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();   
CloudFileShare share = fileClient.GetShareReference("temp");
CloudFile f = share.GetRootDirectoryReference().GetFileReference("Report-461fab0e-068e-42f0-b480-c5744272e103-8-14-2018.pdf");  
log.Info("size " + f.StreamMinimumReadSizeInBytes.ToString());

下面的代码导致所讨论的身份验证错误:

FileContinuationToken continuationToken = null;
do
{
    var response = await share.GetRootDirectoryReference().ListFilesAndDirectoriesSegmentedAsync(continuationToken);
    continuationToken = response.ContinuationToken;
}
while (continuationToken != null);

任何帮助将不胜感激。

谢谢。

【问题讨论】:

  • 可以分享创建fileClient的代码吗?
  • 谢谢。我已经更新了问题中的代码。
  • 您的代码在我看来没问题。我能想到的 2 个原因会导致 403 错误:1)您的帐户密钥不正确,2)运行代码的计算机上的时钟运行缓慢(大约 15 分钟或更长时间)。你能检查一下这两件事吗?
  • 我使用的是密钥 2,它适用于单个文件,但不适用于列出文件。我将其更改为键 1 并且它有效。感谢您的帮助!

标签: c# azure azure-storage fileshare


【解决方案1】:

使用 key 1 代替 key 解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-04
    • 2021-10-16
    • 1970-01-01
    • 2017-05-13
    • 1970-01-01
    • 2021-12-11
    • 1970-01-01
    相关资源
    最近更新 更多