C# Azure文件共享列表文件和目录SegmentedAsync()身份验证失败
我正在使用c#.net api处理azure文件存储,但无法成功列出文件共享中的所有文件。我的代码错误与: Microsoft.WindowsAzure.Storage:服务器无法验证 要求确保已形成授权标头的值 正确地包括签名 以下代码工作正常,因此我与文件共享“temp”的连接正常:C# Azure文件共享列表文件和目录SegmentedAsync()身份验证失败,c#,azure,azure-storage,fileshare,C#,Azure,Azure Storage,Fileshare,我正在使用c#.net api处理azure文件存储,但无法成功列出文件共享中的所有文件。我的代码错误与: Microsoft.WindowsAzure.Storage:服务器无法验证 要求确保已形成授权标头的值 正确地包括签名 以下代码工作正常,因此我与文件共享“temp”的连接正常: CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); CloudFileClient fileCli
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);
任何帮助都将不胜感激
谢谢。使用键1而不是键解决了问题。您能分享创建
文件客户端的代码吗?谢谢。我已经更新了问题中的代码。我看你的代码还行。我能想到的两个原因会导致403错误:1)您的帐户密钥不正确,2)运行代码的计算机上的时钟运行缓慢(大约15分钟或更长)。你能检查一下这两件事吗?我用的是键2,它适用于单个文件,但不适用于列出文件。我把它改成了键1,它成功了。谢谢你的帮助!