#c# #azure-functions #azure-storage #azure-storage-files #.net-4.7.2
#c# #azure-функции #azure-хранилище #azure-storage-files #.net-4.7.2
Вопрос:
Azure.Хранение.Файлы.Общие ресурсы v12.0.0 — 12.5.0 выдают ошибку во время выполнения
Майкрософт.Azure.WebJobs.Host.Исключение FunctionInvocationException : исключение при выполнении функции: Function2 —> System.IO.FileNotFoundException : не удалось загрузить файл или сборку ‘System.Runtime.Службы компилятора.Небезопасно, версия = 4.0.4.1,
Когда мы включаем это через Nuget в Azure Function V1.
Есть ли обходной путь для использования этого?
Я использую
ShareFileClient file = directory.GetFileClient(filename);
ShareFileDownloadInfo download = file.Download();
При загрузке () выдает эту ошибку.
Ответ №1:
Функция Azure v1, похоже, конфликтует с последней версией пакета, пожалуйста, используйте Microsoft.WindowsAzure.Storage.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);
}
}
}
Комментарии:
1. ДА… спасибо, я уже использовал это, 1 за правильный ответ