Azure.Storage.Files.Shares v12.0.0 - 12.5.0 is giving runtime error
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Function2 ---> System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1,
When we include this via Nuget in Azure Function V1.
Any workaround to use this?
I am using
ShareFileClient file = directory.GetFileClient(filename);
ShareFileDownloadInfo download = file.Download();
On Download() it gives this error.
Azure function v1 seems to conflict with the latest version of the package, please use Microsoft.WindowsAzure.Storage.File
.
You can refer to this code to download your file:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(<storage-connect-string>);
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
CloudFileShare share = fileClient.GetShareReference(<share-name>);
if (share.Exists())
{
// Get a reference to the root directory for the share.
CloudFileDirectory rootDir = share.GetRootDirectoryReference();
// Get a reference to the directory we created previously.
CloudFileDirectory sampleDir = rootDir.GetDirectoryReference(<directory-name>);
// Ensure that the directory exists.
if (sampleDir.Exists())
{
// Get a reference to the file we created previously.
CloudFile file = sampleDir.GetFileReference("test.txt");
// Ensure that the file exists.
if (file.Exists())
{
log.Info(file.DownloadTextAsync().Result);
}
}
}