Azure Feature Manager UseFeatureFlags filter by label not working as expected .net Core

709 Views Asked by At

I am trying to setup Azure Feature Manager in my .net core api project. I have two flags setup in azure. One with 'Development' label and one without a label. enter image description here

I am trying to retrieve only the feature flags with development label. But it returns me all two flags in azure. I am trying to figure out where I done something wrong. If anybody has any idea on how to fix this would be really helpful.

 var settings = config.Build();
 var connection = settings.GetConnectionString("AppConfig");
                  config.AddAzureAppConfiguration(options =>
                    options
                    .Connect(connection)
                    .UseFeatureFlags(opt => {
                        opt.Select(KeyFilter.Any, "Development");
                    }));

Code to retrieve all feature flags available.

    var featureNames = _featureManager.GetFeatureNamesAsync();

    await foreach (var name in featureNames)
    {
        var isEnabled = await _featureManager.IsEnabledAsync(name);
        featureList.Add(new FeatureFlag()
        {
            Feature = name,
            IsEnabled = isEnabled
        });
    }

Which returns,

enter image description here

1

There are 1 best solutions below

0
On

Try it with the label property. (https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.configuration.azureappconfiguration.featuremanagement.featureflagoptions.label?view=azure-dotnet)

Like so:

var settings = config.Build();
var connection = settings.GetConnectionString("AppConfig");
              config.AddAzureAppConfiguration(options =>
                options
                .Connect(connection)
                .UseFeatureFlags(opt => {
                    opt.Label =  "Development";
                }));