1
votes

I have an event hub that has a load of events in it. I also have an Azure function written in C#, but it's not receiving any events. This is what the setup looks like:

Function:

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
            }
        }
    }
}

Output when running:

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'.

I'm using netcoreapp3.1 with Azure Functions 3. I have the following NuGet packages installed:

enter image description here

Does anyone know why I'm not receiving any events? The connection string is correct and it can find the settings in my settings file.

1
Did you run with --verbose? Hope event hub is not paused? Though that might give you explicit errors. Last thing I recommend is to deploy to cloud and see logs in Portal A) YourApp->Functions->YourFunction->Monitor if it's invokved B) Goto Logs tab and set level to verbose and wait, I've seen "polling logs" there which I've not seen anywhere else. Finally though you said The connection string is correct and it can find the settings in my settings file., would be good if you post the settings. NOTE: Set samplingSettings.isEnabled to false while you're developing. HTH. - Kashyap
Any error output? - Cindy Pau
Please make you're using the event hub namespace level connection string, and you can also create a new consumer group and use the new consumer group in your azure function. - Ivan Yang
@Kashyap thank you. When running it manually from the console (func start --build) it suddenly works. I expect it's a rider issue. - Leon Cullens
@LeonCullens Hello, if the answer is helpful, could you please accept it as answer? Thanks. - Ivan Yang

1 Answers

0
votes

Your code seems correct. Here are some points you can check:

1.Please make you're using the event hub namespace level connection string.

2.you can also create a new consumer group and use the new consumer group in your azure function.

3.It may be a temp issue. Just restart your function or create a new function to see if it can work.