Trying to download the file from azure file storage in blazor web assembly application. when checking whether cloudFileShare.Exists(), application gets hanged.
Code snippet to reproduce the issue.
string fileReference = "GiantPanda.docx";
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(connectionString);
CloudFileClient fileClient = cloudStorageAccount.CreateCloudFileClient();
//Get file share
CloudFileShare cloudFileShare = fileClient.GetShareReference(shareReference);
if (cloudFileShare.Exists())
{
//Get the related directory
CloudFileDirectory dir = cloudFileShare.GetRootDirectoryReference();
if (dir.Exists())
{
//Get the file reference
CloudFile file = dir.GetFileReference(fileReference);
FileStream memoryStream = new FileStream("wwwroot/sample-data/GiantPandasaved.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
//Download file to local disk
await file.DownloadToStreamAsync(memoryStream);
}
}
Microsoft.Azure.Storage.File - 11.1.6
Microsoft.AspNetCore.Components.WebAssembly - 3.2.0-preview2.20160.5

NET Core SDK (reflecting any global.json):
Version: 3.1.300
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
Host (useful for support):
@pakrym do you want to create a new issue tracking this on your side?
@harinichellappa1921 if you switch to the async implementation of the APIs you're using, things may get fixed. Try to use ExistsAsync() instead.
I think it's the case of using sync APIs that end up doing sync-over-async because of lack of better alternatives.
ExistsAsync doesn't work in this case. Maybe change in the nuget package?
Why doesn't ExistsAsync work? Do you get the same error?
Oh, wait, my bad, you are using version 11 of the package. There is a new set of storage client libraries that do work with blazor, take a look at https://www.nuget.org/packages/Azure.Storage.Blobs / https://www.nuget.org/packages/Azure.Storage.Files
Yes it works for me now, i dont know for @harinichellappa1921. It wasn't Azure.Storage.Files, but Azure.Storage.Files.Shares that did the trick. Thank you.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
See our Issue Management Policies for more information.
Most helpful comment
Oh, wait, my bad, you are using version 11 of the package. There is a new set of storage client libraries that do work with blazor, take a look at https://www.nuget.org/packages/Azure.Storage.Blobs / https://www.nuget.org/packages/Azure.Storage.Files