You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there is IVariantServiceProvider that provides feature-based injection. But it relies on using complicated variants and allocation concepts which might not be needed. So it would be great to have simpler solution compatible with .NET feature management schema.
I see this as some IFeatureServiceProvider with similar API to IVariantServiceProvider where method GetServiceAsync works by simpler algorithm:
evaluate feature state
if disabled return default
if enabled return new
While DI could be configured with new method WithFeatureService:
But it relies on using complicated variants and allocation concepts which might not be needed.
I can understand that. But if you use Azure App Configuration to create variant feature flags, we offers a wizard UI to create variant feature for you. You won't need to worry about the complicated configurations for variants and allcoations.
But your feature request seems to be valid, I will bring it to my team.
The main blocker i see here is lazy feature service instantiation. After that the implementation of FeatureServiceProvider class will be really trivial.
I'd like to clarify the underlying scenario.
Feature-based DI only makes sense when the enabled/disabled state of the flag can change at runtime. If the flag's state is fixed at startup, you don't need a service provider abstraction at all. The whole point of IVariantServiceProvider<TService> is to re-evaluate on each resolution so that toggling the flag (or its targeting/filters) takes effect without restarting the app.
I think instead of having a new API WithFeatureService, we can achieve this through default_when_disabled and default_when_enabled variant allocation with the existing WithVariantService API.
Besides, we want to promote variant feature flag usage, so we don't intentd to introduce a new WithFeatureService that is driven only by feature flag status.
Activity
zhiyuanliang-ms commentedon May 14, 2026
Hey, Степан (@Stepami) Thanks for reaching out.
I can understand that. But if you use Azure App Configuration to create variant feature flags, we offers a wizard UI to create variant feature for you. You won't need to worry about the complicated configurations for variants and allcoations.
But your feature request seems to be valid, I will bring it to my team.
Stepami commentedon May 14, 2026
Zhiyuan Liang (@zhiyuanliang-ms) Thanks for the feedback! I use FM without Azure 😅 so main points are:
The main blocker i see here is lazy feature service instantiation. After that the implementation of
FeatureServiceProviderclass will be really trivial.zhiyuanliang-ms commentedon May 26, 2026
Hey, Степан (@Stepami)
I'd like to clarify the underlying scenario.
Feature-based DI only makes sense when the enabled/disabled state of the flag can change at runtime. If the flag's state is fixed at startup, you don't need a service provider abstraction at all. The whole point of
IVariantServiceProvider<TService>is to re-evaluate on each resolution so that toggling the flag (or its targeting/filters) takes effect without restarting the app.I think instead of having a new API
WithFeatureService, we can achieve this throughdefault_when_disabledanddefault_when_enabledvariant allocation with the existingWithVariantServiceAPI.{ "id": "variantFeatureA", "enabled" : true, "variants": [ { "name": "DefaultImpl" }, { "name": "NewImpl" } ], "allocation": { "default_when_disabled": "DefaultImpl", "default_when_enabled": "NewImpl" } }Besides, we want to promote variant feature flag usage, so we don't intentd to introduce a new
WithFeatureServicethat is driven only by feature flag status.Stepami commentedon May 26, 2026
Hey, Zhiyuan Liang (@zhiyuanliang-ms)
The underlying scenario is correct. It's about being able to change the state of the flag at runtime.
But with addition of .NET feature management schema compatibility
So instead of this 13 lines of json you provided as example one can use simple
"variantFeatureA": trueconfigurationzhiyuanliang-ms commentedon May 27, 2026
Hey, Степан (@Stepami)
So you are not using any feature filter?
Could you check this PR: #607
This PR enhance the existing variant service provider and
WithVariantServiceapi to achieve the "FeatureServiceProvider`Stepami commentedon Jun 4, 2026
Still deciding on the design
Stepami commentedon Jun 6, 2026
in addition to #605 (comment)
it'd be really cool to resolve services by status with context allowing featurefilters and "EnabledFor" stuff: