Azure Functions 2.0 - EventHubTrigger - System.Private.CoreLib:无法加载文件或程序集“FunctionsProject.dll" [英] Azure Functions 2.0 - EventHubTrigger - System.Private.CoreLib: Could not load file or assembly "FunctionsProject.dll"

查看:29
本文介绍了Azure Functions 2.0 - EventHubTrigger - System.Private.CoreLib:无法加载文件或程序集“FunctionsProject.dll"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够运行具有来自本地和 West US2 Consumption 计划的 eventhub 绑定的函数应用程序.从过去 4 天开始,在我们将所有依赖项目移动到 x64 中构建并将所有 nuget 更新到最新之后 - 函数应用程序开始失败.它甚至无法启动,也无法加载functionsproject.dll 本身.即使我将位部署到消费计划,也会出现同样的问题.

  • 此处为函数项目名称 - EventHubConsumers
  • Azure 函数版本 - 2.0
  • Azure 函数工具版本 - 2.28
  • 项目构建配置 - x64
  • 网络版本 - NET CORE 2.1
  • Visual Studio 2019 &2017
Nuget 依赖项:

<PackageReference Include="Microsoft.Azure.Functions.Extensions" 版本="1.0.0"/><PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.6"/><PackageReference Include="Microsoft.Extensions.Caching.Memory" 版本="2.2.0"/><PackageReference Include="Microsoft.Jarvis" Version="20190426.1.0-rc"/><PackageReference Include="Microsoft.NET.Sdk.Functions" 版本="1.0.29"/><PackageReference Include="Newtonsoft.Json" Version="12.0.2"/><PackageReference Include="Polly" Version="7.1.0"/>

我无法拉出 FusionLog.我猜函数框架 StartLocator 有自定义逻辑来加载不填充融合日志的库.

我尝试在 FunctionAssemblyLoadContext.cs 中调试 LoadFromAssemblyPath(string assemblyPath, bool addProbingPath),这会引发此异常.我可以看到该程序集 bin 路径并验证我的函数应用程序是否已内置到该文件夹​​本身中.我什至通过在 IlSpy 中打开来验证 dll 的版本和其他详细信息.我无法弄清楚为什么程序集(函数应用程序 dll)按预期存在于该路径中时无法加载.

  • 在 Github 上记录的问题:链接

  • 试用旧版本的 Microsoft.Azure.Webjobs.Extensions.Eventhubs,即试用 3.0.5 版

  • 清理、删除obj、bin然后运行
  • 删除 LocalAppData 中除 2.28 之外的所有旧版本 AzureFunctionsTools.
  • 从 vs2017 运行

[FunctionName("WriteToStore")]public async Task Run([EventHubTrigger("activities", Connection = "EventHubConnectionAppSetting", ConsumerGroup = "%ConsumerGroup%")] EventData[] events,[EventHub("failed-activities", Connection = "EventHubConnectionAppSetting")]IAsyncCollector输出事件){//逻辑在这里}

来自函数控制台的更多详细信息:<块引用>

Azure 函数核心工具(2.7.1505 提交哈希:eb8182995562240ca83dd0e0e3394586cf5fdfa3)

函数运行时版本:2.0.12590.0

[8/4/2019 10:09:25 PM] 构建主机:启动抑制:假,配置抑制:假

[8/4/2019 10:09:26 PM] 发生主机错误

[8/4/2019 10:09:26 PM] System.Private.CoreLib:无法加载文件或程序集Microsoft..EventHubConsumers,版本=1.0.0.0,Culture=neutral,PublicKeyToken=null".

值不能为空.

参数名称:提供者

按任意继续....[8/4/2019 10:09:27 PM] 构建主机:启动被抑制:假,配置被抑制:假

[8/4/2019 10:09:27 PM] 发生主机错误

[8/4/2019 10:09:27 PM] System.Private.CoreLib:无法加载文件或程序集Microsoft..EventHubConsumers,版本=1.0.0.0,Culture=neutral,PublicKeyToken=null".

托管环境:生产

内容根路径:D:someEventHubConsumersinx64Debug etcoreapp2.1

正在收听:

功能应用程序不提供带有程序集加载问题的融合日志,这使得很难理解出了什么问题!

I was able to run function app which has eventhub binding from local as well as from West US2 Consumption plan. From last 4 days, after we moved all our dependent projects to build in x64 and updating all nugets to latest - function app started failing. It does not even start, it fails to load the functionsproject.dll itself. Same issue even If I deploy bits to Consumption Plan.

  • Functions Project Name here - EventHubConsumers
  • Azure function version - 2.0
  • Azure function tools version - 2.28
  • Project build configuration - x64
  • Net version - NET CORE 2.1
  • Visual Studio 2019 & 2017
Nuget dependencies:

<PackageReference Include="Microsoft.ApplicationInsights" Version="2.10.0" /> <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" /> <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.6" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" /> <PackageReference Include="Microsoft.Jarvis" Version="20190426.1.0-rc" /> <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> <PackageReference Include="Polly" Version="7.1.0" />

I was not able to pull FusionLog. I guess Functions framework StartLocator has custom logic to load libraries which does not fill fusion log.

I tried debugging LoadFromAssemblyPath(string assemblyPath, bool addProbingPath) in FunctionAssemblyLoadContext.cs which throws this exception. I could see that assembly bin path and verify that my functions app is getting built into that folder itself. I even verified version of the dll and other details by opening up in IlSpy. I cannot make out why assembly (function app dll) could not be loaded when it existed in that path as expected.

  • Logged issues on Github: Link

  • Trying out older versions of Microsoft.Azure.Webjobs.Extensions.Eventhubs i.e. trying out version 3.0.5

  • Clean, delete obj, bin and then running
  • Deleting all older versions of AzureFunctionsTools in LocalAppData except for 2.28.
  • Running from vs2017

[FunctionName("WriteToStore")]
public async Task Run([EventHubTrigger("activities", Connection = "EventHubConnectionAppSetting", ConsumerGroup = "%ConsumerGroup%")] EventData[] events,
             [EventHub("failed-activities", Connection = "EventHubConnectionAppSetting")]IAsyncCollector<EventData> outputEvents)
{
  //Logic here
}

More details from Functions Console:

Azure Functions Core Tools (2.7.1505 Commit hash: eb8182995562240ca83dd0e0e3394586cf5fdfa3)

Function Runtime Version: 2.0.12590.0

[8/4/2019 10:09:25 PM] Building host: startup suppressed:False, configuration suppressed: False

[8/4/2019 10:09:26 PM] A host error has occurred

[8/4/2019 10:09:26 PM] System.Private.CoreLib: Could not load file or assembly 'Microsoft..EventHubConsumers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Value cannot be null.

Parameter name: provider

Press any to continue....[8/4/2019 10:09:27 PM] Building host: startup suppressed:False, configuration suppressed: False

[8/4/2019 10:09:27 PM] A host error has occurred

[8/4/2019 10:09:27 PM] System.Private.CoreLib: Could not load file or assembly 'Microsoft..EventHubConsumers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Hosting environment: Production

Content root path: D:someEventHubConsumersinx64Debug etcoreapp2.1

Now listening on: http://0.0.0.0:7071

Application started. Press Ctrl+C to shut down.

[8/4/2019 10:09:29 PM] Building host: startup suppressed:False, configuration suppressed: False

[8/4/2019 10:09:29 PM] A host error has occurred

[8/4/2019 10:09:29 PM] System.Private.CoreLib: Could not load file or assembly 'Microsoft.some.EventHubConsumers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

解决方案

I got this working after fixing few issues. I will note issues and fixes which I followed.

To repeat, My function app is configured to build with x64 and run on .Netcore 2.1

  1. One of the dependent project (assembly) was built with netstandard 2.0 while all others were built as Netcore 2.1. This caused assembly loading issue with x64 (though that dependent assembly was built with x64 configuration). This sounds bit weird and I'm not convinced if this is a fix or even an issue in the first place.

  2. Visual studio runs x86 core tools probably and hence x64 function app fails with assembly load etc when run from visual studio (2017 and 19). You can set up project to run external app while debugging. You can set Properties->Debug to start 'func.exe host start'.

  3. I was getting "Value cannot be null. Argument - Path" exception after launching function app from Visual Studio.

    Fix -Explained (here - Github). npm path was missing in PATH. I updated npm root path in PATH environment variable.

  4. I had to update azure function core tools and run function app using 'func host start'. Now I run app using 'func host start' and attach debugger to func.exe (CTRL+ALT+P). You can find AzureFunctionTools folder in your local appdata folder - %LocalAPPDATA%AzureFunctionsTools. You can see all versions of azure function core tools in releases folder along with cli and func.exe example - AzureFunctionsToolsReleases2.28.0cli

  5. Major issue with deployment was with Application settings. I had to change application platform as 64 bit on azure portal. By default, function app was created with 32 bit platform setting. Explained here - Github.

Function app does not provide fusion log with assembly load issues which makes it too difficult to understand what is going wrong!

这篇关于Azure Functions 2.0 - EventHubTrigger - System.Private.CoreLib:无法加载文件或程序集“FunctionsProject.dll"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆