You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET 6 Azure函数中KustoIngestFactory加载依赖程序集失败排查

.NET 6 Azure函数使用Kusto流式摄入时System.TypeInitializationException异常处理

问题场景

现有一个.NET 6 Azure函数应用,原本通过Microsoft.Azure.Kusto.Data(v12.2.1)包的管理员命令向Kusto写入记录。尝试替换为数据流式摄入方案,安装Microsoft.Azure.Kusto.Ingest包并完成代码修改后,本地测试时在以下代码行触发异常:

kustoIngestProvider = KustoIngestFactory.CreateStreamingIngestClient(kustoIngestServer);

异常详情

抛出System.TypeInitializationException,内部嵌套FileNotFoundException:

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for 'Kusto.Ingest.KustoIngestFactory' threw an exception.
  Source=Kusto.Ingest
  StackTrace:
   at Kusto.Ingest.KustoIngestFactory.CreateStreamingIngestClient(String connectionString, Boolean autoCorrectEndpoint)
   at WorkloadReview.Utilities.KustoClient..ctor(ILogger`1 logger, String kustoServer, String kustoIngestServer, String tenant, String msiClientId) in C:\src\AzureCXP-CXObserve-BE\src\Common\WorkloadReview\KustoClient.cs:line 63
   at ReviewManagement.Utilities.ReviewKustoClient..ctor(ILogger`1 logger) in C:\src\AzureCXP-CXObserve-BE\src\ReviewManagement\ReviewManagement\Utilities\ReviewKustoClient.cs:line 28
   at DryIoc.Scope.TryGetOrAdd(ImMap`1 items, Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Scope.GetOrAdd(Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Scope.TryGetOrAdd(ImMap`1 items, Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Scope.GetOrAdd(Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate(Type serviceType, IfUnresolved ifUnresolved)
   at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
   at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IServiceProvider serviceProvider)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.CreateInstance(IFunctionInstanceEx functionInstance)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ParameterHelper.Initialize()
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<TryExecuteAsync>d__18.MoveNext()

Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

排查情况

  • System.Diagnostics.DiagnosticSource 8.0.0包已安装在NuGet缓存,程序集也已复制到项目bin目录
  • 其他依赖该程序集的包(如Microsoft.Azure.Kusto.Data)未出现报错
  • 两台不同开发机器测试结果一致,排除环境本地问题

临时解决方案

将Microsoft.Azure.Kusto.Data和Microsoft.Azure.Kusto.Ingest包降级至11.3.5版本后,类型初始化时不再抛出FileNotFoundException,推测Ingest包最新版本存在兼容性bug。

内容的提问来源于stack exchange,提问作者jkindwall

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 14:20:15