【问题标题】:EventHubTrigger is not working in Azure FunctionsEventHubTrigger 在 Azure Functions 中不起作用
【发布时间】:2019-07-19 12:39:12
【问题描述】:

我正在尝试构建简单的 azure functions v2 应用程序,该应用程序将包含两个函数,一个基于 TimerTrigger 触发,另一个将由 触发EventHubTrigger。我也有使用 Startup.cs 类的 IoC 容器配置。 TimerTrigger - 工作正常,但我在使用 EventHubTrigger 时遇到了一些问题。 这是我的设置。事件中心函数:


namespace BgService
{
    public class MyFunctions
    {
        [FunctionName("MyFunction")]
        public async Task RunAsync([EventHubTrigger("myHubName", Connection = "hub")] string events, ILogger log)
        {

        }
    }
}

local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "*****",

    "hub": "Endpoint=sb://***.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=***"
  }
}

我的 Startup.cs:

[assembly: FunctionsStartup(typeof(BgService.Startup))]
namespace BgService
{
    public class Startup : FunctionsStartup
    {


        public override void Configure(IFunctionsHostBuilder builder)
        {
           // SomeConfiguration
        }
    }

当我运行我的 azure 函数项目时,出现下一个错误:

[19.07.2019 12:26:23] Microsoft.Azure.WebJobs.Host: Error indexing method 'MyFunction'. Microsoft.Azure.WebJobs.EventHubs: Value cannot be null.
[19.07.2019 12:26:23] Parameter name: receiverConnectionString.

使用的 Microsoft.NET.Sdk.Functions 版本 -> 1.0.29

现在是棘手的部分: 当我将 Microsoft.NET.Sdk.Functions 的版本降级到 1.0.25 而不对代码进行任何修改时 -> 它神奇地开始工作,但是 Startup.Configure()方法不再被调用(在 1.0.29 版本中它正在工作)。

感谢您的帮助,花了几个小时解决此问题。

【问题讨论】:

  • 您使用的是哪个版本的 Microsoft.Azure.WebJobs.Extensions.EventHubs?您可以尝试将EntityPath=<EventHubName> 附加到连接字符串吗?

标签: c# azure-functions azure-eventhub


【解决方案1】:

也许这可以帮助https://github.com/Azure/Azure-Functions/issues/1299

您应该将包 Microsoft.Azure.EventHubs 降级到 3.0.0 作为解决方法

【讨论】:

    猜你喜欢
    • 2018-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多