How to set EventHubOptions in Isolated Azure Function

Sayed Reda 20 Reputation points
2024-09-18T14:05:12.73+00:00

I had in-process azure function with event hub trigger. I was configuring EventHubOptions programmatically as below:

            builder.Services.PostConfigure<EventHubOptions>(o =>
            {
                o.MaxEventBatchSize = maxBatchSizeValue;
                o.PrefetchCount = prefetchCountValue;
            });

But after migrating to isolated azure function, there is no EventHubOptions class so how can I configure it?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,029 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
643 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 27,341 Reputation points
    2024-09-19T15:23:56.69+00:00

    @Sayed Reda Thanks for reaching out. In the isolated worker model, you can’t change the host configuration in code because your function runs in a separate process from the host. Instead, you need to configure settings like maxBatchSize and prefetchCount in the host.json file.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs?tabs=isolated-process%2Cextensionv5&pivots=programming-language-csharp#hostjson-settings

    This is mentioned here please refer: https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=linux#configuration

    User's image

    do let me know incase of further queries, I would be happy to assist you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.