Open cliedeman opened 2 days ago
Thanks for raising this. We're working on improved .NET 9.0 support now on main
branch as part of our 5.0.0 release.
Would you consider opening a PR?
Sure. which approach should I use?
Not sure tbqh. @jamescrosswell opinions?
If the type cast is safe, maybe that's the simplest as no new API needed
It looks like it'd be easy to break with the cast option if someone called this incorrectly from an app that used the older IHostBuilder
:
else
{
throw new ArgumentException("builder is not a IHostApplicationBuilder");
}
Ideally we wouldn't find out at runtime what we could prevent with static types.
SentryFunctionsWorkerApplicationBuilderExtensions
doesn't actually need HostBuilderContext
or an IHostApplicationBuilder
... ultimately the dependency it's after is IConfiguration
. I think it makes sense to have one overload (where the real work happens) that takes an IConfiguration
parameter... and then wrap this with some other overloads that are built to work specifically with either HostBuilderContext
or IHostApplicationBuilder
.
Hi guys,
How about change extension "base" interface from IFunctionsWorkerApplicationBuilder
to IHostApplicationBuilder
? It would simplify code, and it could be reusable in other sentry integrations (not only azure function).
public static IHostApplicationBuilder UseSentry(
this IHostApplicationBuilder builder,
Action<SentryAzureFunctionsOptions>? optionsConfiguration)
{
var services = builder.Services;
var section = builder.Configuration.GetSection("Sentry");
#if NET8_0_OR_GREATER
services.AddSingleton<IConfigureOptions<SentryAzureFunctionsOptions>>(_ =>
new SentryAzureFunctionsOptionsSetup(section)
);
#else
services.Configure<SentryAzureFunctionsOptions>(options =>
section.Bind(options));
#endif
...
}
PS @cliedeman many thanks for workaround.
Problem Statement
Dotnet 9 has included support for using the IHostApplicationBuilder style for app creation
https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=ihostapplicationbuilder%2Cwindows#start-up-and-configuration
With the new style we dont have access to the
HostBuilderContext
Temporary workaround:
I see 2 obvious solutions:
Either add a builder extension with using
FunctionsApplicationBuilder
or do a cast
Solution Brainstorm
No response