I'm using an Azure Durable Function to orchestrate other functions, currently contained in the same project. I want to configure services and logging for those orchestrated functions. How can I do that?
Here is some more detail:
In a "normal" Azure Function I have a Program.cs
and a Main
method with the following code that sets up the environment for the function execution:
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureLogging(loggingBuilder => { loggingBuilder.SetMinimumLevel(LogLevel.Trace); })... etc. pp.
Using the HostBuilder
I can add additional logging providers, add caching services etc. Those services are then injected via the constructor of the Azure Function.
Now in comparison when creating a Durable Function project via the VS Code "Durable Function Orchestration" template there is no Program.cs
, no HostBuilder
and no constructor. There are just some static methods representing the orchestrator and an orchestrated function.
As there is no out-of-the-box HostBuilder
in the "Durable Function Orchestration" template - how does the HostBuilder
equivalent look like for Durable Functions? Whats the pattern or convention here? Do I write it myself? Or is there some instance floating around or initialization I can hook into? Or should orchestrated functions be put into separate Azure Function projects where I can make use of the HostBuilder
?
Any hints are appreciated.