首页 > 解决方案 > 为 eventthub 触发器获取 Azure.WebJobs.Host.Listeners.FunctionListenerException

问题描述

我正在使用 azure webjobs v3 来触发 eventthub。直到某个时候一切正常。突然我变得低于错误。有人可以帮我解决这个问题吗?

public async Task Trigger00([EventHubTrigger("%eventhub-00%", Connection = "ConnectionString")] string message)
       {
          blah... 
       }
Host.Startup[0]
      The listener for function 'Trigger00' was unable to start.
Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function 'Trigger00' was unable to start. ---> System.MissingMethodException: Method not found: 'Void Microsoft.Azure.EventHubs.EventHubsException..ctor(Boolean, System.String, System.Exception)'.
   at Microsoft.Azure.EventHubs.Processor.EventProcessorConfigurationException..ctor(String message, Exception innerException)
   at Microsoft.Azure.EventHubs.Processor.PartitionManager.GetPartitionIdsAsync()
   at Microsoft.Azure.EventHubs.Processor.PartitionManager.GetPartitionIdsAsync()
   at Microsoft.Azure.EventHubs.Processor.PartitionManager.InitializeStoresAsync()
   at Microsoft.Azure.EventHubs.Processor.PartitionManager.StartAsync()
   at Microsoft.Azure.EventHubs.Processor.EventProcessorHost.RegisterEventProcessorFactoryAsync(IEventProcessorFactory factory, EventProcessorOptions processorOptions)
   at Microsoft.Azure.WebJobs.EventHubs.EventHubListener.StartAsync(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.EventHubs\Listeners\EventHubListener.cs:line 46
   at Microsoft.Azure.WebJobs.Host.Listeners.FunctionListener.StartAsync(CancellationToken cancellationToken, Boolean allowRetry) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\FunctionListener.cs:line 68
   --- End of inner exception stack trace ---

标签: azureazure-functionsazure-webjobsazure-eventhubazure-webjobssdk

解决方案


我通过删除对 Microsoft.Azure.EventHubs 4.1.0 的直接依赖解决了这个问题。

Microsoft.Azure.WebJobs.Extensions.EventHubs3.0.6 依赖于Microsoft.Azure.EventHubs2.1.0)的旧版本。我已阅读此包中有重大更改,这可能解释了该错误。

前:

    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.10.0" />
    <PackageReference Include="Microsoft.Azure.Cosmos" Version="3.1.1" />
    <PackageReference Include="Microsoft.Azure.EventHubs" Version="4.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.6" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />

后:

    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.10.0" />
    <PackageReference Include="Microsoft.Azure.Cosmos" Version="3.1.1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.6" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />

推荐阅读