Repository: microsoft/onefuzz
File: src/ApiService/ApiService/Program.cs (C#)

Code before:
        }
    }

    //Move out expensive resources into separate class, and add those as Singleton
    // ArmClient, Table Client(s), Queue Client(s), HttpClient, etc.
    public static async Async.Task Main() {
        var configuration = new ServiceConfiguration();

        using var host =
            new HostBuilder()
            .ConfigureAppConfiguration(builder => {
                var _ = builder.AddAzureAppConfiguration(options => {
                    var _ = options.Connect(new Uri(configuration.AppConfigurationEndpoint!), new ManagedIdentityCredential())
                        .ConfigureRefresh(refreshOptions =>
                            refreshOptions.SetCacheExpiration(TimeSpan.FromMinutes(1)));
                });
            })
            .ConfigureFunctionsWorkerDefaults(builder => {
                builder.UseMiddleware<LoggingMiddleware>();
                builder.AddApplicationInsights(options => {
                    options.ConnectionString = $"InstrumentationKey={configuration.ApplicationInsightsInstrumentationKey}";
                });
                builder.UseAzureAppConfiguration();
            })
            .ConfigureServices((context, services) => {
                services.AddAzureAppConfiguration();
                services.Configure<JsonSerializerOptions>(options => {
                    options = EntityConverter.GetJsonSerializerOptions();
                });

                services.Configure<WorkerOptions>(options => {
                    options.Serializer = new JsonObjectSerializer(EntityConverter.GetJsonSerializerOptions());
                });

                services
                .AddScoped<ILogTracer>(s => {
                    var logSinks = s.GetRequiredService<ILogSinks>();
                    var cfg = s.GetRequiredService<IServiceConfig>();
                    return new LogTracerFactory(logSinks.GetLogSinks())
                        .CreateLogTracer(
                            Guid.Empty,
                            severityLevel: cfg.LogSeverityLevel);
                })
                .AddScoped<IAutoScaleOperations, AutoScaleOperations>()
                .AddScoped<INodeOperations, NodeOperations>()
                .AddScoped<IEvents, Events>()
                .AddScoped<IWebhookOperations, WebhookOperations>()
                .AddScoped<IWebhookMessageLogOperations, WebhookMessageLogOperations>()
                .AddScoped<ITaskOperations, TaskOperations>()
                .AddScoped<ITaskEventOperations, TaskEventOperations>()
                .AddScoped<IQueue, Queue>()

Review comment (suggestion):
Not sure if you found this while enabling AppConfiguration but with the AppConfiguration stuff there's also [explicit feature flag support](https://learn.microsoft.com/en-us/azure/azure-app-configuration/quickstart-feature-flag-azure-functions-csharp?tabs=in-process) via `AddFeatureManagement` which gives you an `IFeatureManagerSnapshot` injected to use instead of having to parse the configuration settings manually out of e.g. `context.AppConfiguration[FeatureFlagConstants.EnableJinjaConvert]` (instead it would be something like `_features.IsEnabledAsync(FeatureFlagConstants.EnableJinjaConvert)`). 

Code after:
            await next(context);
        }
    }

    //Move out expensive resources into separate class, and add those as Singleton
    // ArmClient, Table Client(s), Queue Client(s), HttpClient, etc.
    public static async Async.Task Main() {
        var configuration = new ServiceConfiguration();

        using var host =
            new HostBuilder()
            .ConfigureAppConfiguration(builder => {
                var _ = builder.AddAzureAppConfiguration(options => {
                    var _ = options
                        .Connect(new Uri(configuration.AppConfigurationEndpoint!), new DefaultAzureCredential())
                        .UseFeatureFlags(ffOptions => ffOptions.CacheExpirationInterval = TimeSpan.FromMinutes(1));
                });
            })
            .ConfigureFunctionsWorkerDefaults(builder => {
                builder.UseMiddleware<LoggingMiddleware>();
                builder.AddApplicationInsights(options => {
                    options.ConnectionString = $"InstrumentationKey={configuration.ApplicationInsightsInstrumentationKey}";
                });
            })
            .ConfigureServices((context, services) => {
                services.AddAzureAppConfiguration();
                _ = services.AddFeatureManagement();
                services.Configure<JsonSerializerOptions>(options => {
                    options = EntityConverter.GetJsonSerializerOptions();
                });

                services.Configure<WorkerOptions>(options => {
                    options.Serializer = new JsonObjectSerializer(EntityConverter.GetJsonSerializerOptions());
                });

                services
                .AddScoped<ILogTracer>(s => {
                    var logSinks = s.GetRequiredService<ILogSinks>();
                    var cfg = s.GetRequiredService<IServiceConfig>();
                    return new LogTracerFactory(logSinks.GetLogSinks())
                        .CreateLogTracer(
                            Guid.Empty,
                            severityLevel: cfg.LogSeverityLevel);
                })
                .AddScoped<IAutoScaleOperations, AutoScaleOperations>()
                .AddScoped<INodeOperations, NodeOperations>()
                .AddScoped<IEvents, Events>()
                .AddScoped<IWebhookOperations, WebhookOperations>()
                .AddScoped<IWebhookMessageLogOperations, WebhookMessageLogOperations>()
                .AddScoped<ITaskOperations, TaskOperations>()
                .AddScoped<ITaskEventOperations, TaskEventOperations>()