I am using the c#.net api to work with azure file storage but cannot successfully list all files in a fileshare. My code errors with:
Microsoft.WindowsAzure.Storage: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
The following code works perfectly, so my connection to the fileshare 'temp' is fine:
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());
The code below results in the discussed authentication error:
FileContinuationToken continuationToken = null;
do
{
var response = await share.GetRootDirectoryReference().ListFilesAndDirectoriesSegmentedAsync(continuationToken);
continuationToken = response.ContinuationToken;
}
while (continuationToken != null);
Any help would be appreciated.
Thanks.
fileClient
? – Gaurav Mantri