[英]Azure Storage File share dll causing runtime.compiler.unsafe error at runtime when working with Azure Function V1
Azure.Storage.Files.Shares v12.0.0 - 12.5.0 is giving runtime error Azure.Storage.Files.Shares v12.0.0 - 12.5.0 出现运行时错误
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,
Microsoft.Azure.WebJobs.Host.FunctionInvocationException:执行函数时出现异常:Function2 ---> System.IO.FileNotFoundException:无法加载文件或程序集“System.Runtime.CompilerServices.Unsafe,版本 = 4.0.4.1,
When we include this via Nuget in Azure Function V1.当我们通过 Nuget 在 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.在 Download() 上,它给出了这个错误。
Azure function v1 seems to conflict with the latest version of the package, please use Microsoft.WindowsAzure.Storage.File
. Azure 函数 v1 似乎与最新版本的包冲突,请使用
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);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.