Azure Feature Manager Feature Toggle To Evaluate Using Label During Runtime

148 Views Asked by At

Using feature toggles in Azure Feature Manager gives the option to configure a label when creating a feature, in .NET to use that label the only option I could find is to set the label during startup when configuring Azure App Configuration which can be done like:

 config.AddAzureAppConfiguration(
                        options =>
                        {
                            options.Connect(settings.GetConnectionString("Config"))
                                .UseFeatureFlags(o =>
                                {
                                    o.Label = "Test";
                                    o.CacheExpirationInterval = TimeSpan.FromSeconds(1);
                                });
                        },

The problem with that approach is during runtime we can't change the label, as it is pre-configured during startup. The question is how can we manage different labels, let's say I have 100 labels and I want my application to evaluate feature toggle with respect to its label there is no way I could find to achieve that. To evaluate feature toggle we call feature manager like so await _featureManager.IsEnabledAsync(setting);

1

There are 1 best solutions below

0
On

I'd say you can't, and this is not a bad thing. Labels are there so that you can have one feature flag saved two times, possible with different values and filters. E.g.:

  • MyFlag (Label: test) true
  • MyFlag (Label: production) false

or

  • MyFlag (Label: america) true
  • MyFlag (Label: asia) false

So you should use labels to save different values for one feature for different stages or for different regions or whatever other use cases you may have. You are not supposed to switch between labels in a running application.