【Azure Function】Function App出现System.IO.FileNotFoundException异常

问题描述

Function App出现System.IO.FileNotFoundException异常,报错:

Exception while executing function: xxxxxxx,The type initializer for 'xxxxxx.Storage.Adls2.StoreDataLakeGen2Reading' threw an exception. Could not load file or assembly 'Microsoft.Extensions.Configuration, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

 

问题解答

根据错误的Stock Trace信息看,异常似乎来源于Azure Function的代码中引用了Microsoft.Extensions.Configuration依赖,它的版本是9.0,而在Function所运行的托管主机环境中,没有这个文件。所以无法加载。

 

根据官网文档显示,Function App的In-Process (进程内模式),不支持 .NET 9.0。所以,无法加载 Microsoft.Extension.Configuration v9.0, 在项目的引用中调整依赖项的版本或者是把Funciton配置切换为Isolated worker(独立进程模式)。

 

 

参考资料

Develop C# class library functions using Azure Functions: https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library?tabs=v4%2Ccmd#supported-versions

 

posted @   路边两盏灯  阅读(4)  评论(1编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示