I'm wanting to use Azure feature management to drive whether services are added to dependencies during startup .ConfigureServices(hostcontext, services =>
The only way I can find to do this is to call .BuildServiceProvider to get the IFeatureManagement.
var featureManager = services.BuildServiceProvider().GetRequiredService<IFeatureManager>();
if (featureManager.IsEnabledAsync(Features.MY_FEATURE).GetAwaiter().GetResult())
{
services.AddFeatureDependencies();
}
There has got to be a better way to do this. Is there a service extension I'm missing somewhere? Something like below?
services.IfFeatureEnabled(Features.MY_FEATURE) {
services.AddFeatureDependencies();
}
Or maybe by using the IConfiguration interface which can get other configuration values?
hostContext.Configuration.GetValue<bool>($"FeatureManager:{FeatureManagement.MY_FEATURE}");