【发布时间】:2021-05-28 07:32:39
【问题描述】:
我有一个事件中心,其中包含大量事件。我还有一个用 C# 编写的 Azure 函数,但它没有收到任何事件。这是设置的样子:
功能:
private const string EventHubName = "eventhub";
private const string ConnectionStringName = "Settings:EventHubConsumerConnectionstring";
[FunctionName("InformationHandler")]
public async Task RunAsync(
[EventHubTrigger(EventHubName, Connection = ConnectionStringName)] EventData[] eventData,
ILogger log)
Host.json:
{
"version": "2.0",
"aggregator": {
"batchSize": 1000,
"flushTimeout": "00:01:00"
},
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
}
},
"extensions": {
"eventHubs": {
"batchCheckpointFrequency": 1,
"eventProcessorOptions": {
"maxBatchSize": 64,
"prefetchCount": 128
}
}
}
}
运行时的输出:
Functions:
InformationHandler: eventHubTrigger
For detailed output, run func with --verbose flag.
[2021-02-25T21:48:01.621Z] Host lock lease acquired by instance ID '000000000000000000000000DC59BDB5'.
我正在使用带有 Azure Functions 3 的 netcoreapp3.1。我安装了以下 NuGet 包:
有人知道为什么我没有收到任何活动吗?连接字符串正确,可以在我的设置文件中找到设置。
【问题讨论】:
-
您是否使用
--verbose运行过?希望事件中心没有暂停?尽管这可能会给您带来明显的错误。我建议的最后一件事是部署到云并在门户中查看日志 A)YourApp->Functions->YourFunction->Monitor 如果它被调用 B)转到日志选项卡并将级别设置为详细并等待,我已经看到“轮询日志”那里是我在其他任何地方都没有见过的。最后虽然你说The connection string is correct and it can find the settings in my settings file.,如果你发布设置会很好。注意:在开发时将samplingSettings.isEnabled设置为 false。 HTH。 -
任何错误输出?
-
请让你使用
event hub namespace level连接字符串,你也可以创建一个新的consumer group并在你的azure函数中使用新的consumer group。 -
@Kashyap 谢谢。当从控制台(
func start --build)手动运行它时,它突然起作用了。我预计这是骑手问题。 -
@LeonCullens 你好,如果这个答案有帮助,你能接受它作为答案吗?谢谢。
标签: c# azure function azure-functions azure-eventhub