@@ -26,18 +26,42 @@ public static IFunctionsWorkerApplicationBuilder UseSentry(this IFunctionsWorker
2626 public static IFunctionsWorkerApplicationBuilder UseSentry ( this IFunctionsWorkerApplicationBuilder builder , HostBuilderContext context , string dsn )
2727 => builder . UseSentry ( context , o => o . Dsn = dsn ) ;
2828
29+ /// <summary>
30+ /// Uses Sentry integration.
31+ /// </summary>
32+ public static IFunctionsWorkerApplicationBuilder UseSentry (
33+ this IFunctionsWorkerApplicationBuilder builder ,
34+ Action < SentryAzureFunctionsOptions > ? optionsConfiguration )
35+ {
36+ if ( builder is IHostApplicationBuilder appBuilder )
37+ {
38+ return builder . UseSentry ( appBuilder . Configuration , optionsConfiguration ) ;
39+ }
40+ throw new InvalidOperationException ( "Builder is not of type " + typeof ( IHostApplicationBuilder ) ) ;
41+ }
42+
2943 /// <summary>
3044 /// Uses Sentry integration.
3145 /// </summary>
3246 public static IFunctionsWorkerApplicationBuilder UseSentry (
3347 this IFunctionsWorkerApplicationBuilder builder ,
3448 HostBuilderContext context ,
3549 Action < SentryAzureFunctionsOptions > ? optionsConfiguration )
50+ => builder . UseSentry ( context . Configuration , optionsConfiguration ) ;
51+
52+
53+ /// <summary>
54+ /// Uses Sentry integration.
55+ /// </summary>
56+ public static IFunctionsWorkerApplicationBuilder UseSentry (
57+ this IFunctionsWorkerApplicationBuilder builder ,
58+ IConfiguration configuration ,
59+ Action < SentryAzureFunctionsOptions > ? optionsConfiguration )
3660 {
3761 builder . UseMiddleware < SentryFunctionsWorkerMiddleware > ( ) ;
3862
3963 var services = builder . Services ;
40- var section = context . Configuration . GetSection ( "Sentry" ) ;
64+ var section = configuration . GetSection ( "Sentry" ) ;
4165#if NET8_0_OR_GREATER
4266 services . AddSingleton < IConfigureOptions < SentryAzureFunctionsOptions > > ( _ =>
4367 new SentryAzureFunctionsOptionsSetup ( section )
0 commit comments