No Features Returned from Azure App Configuration

Jason Gaylord 6 Reputation points
2020-06-04T18:10:23.247+00:00

I followed the steps at https://learn.microsoft.com/en-us/azure/azure-app-configuration/quickstart-feature-flag-aspnet-core?tabs=core3x for getting a list of features. On my Home controller, if I call

var features = featureManager.GetFeatureNamesAsync();  

I don't see any features. Although, I have features setup. I do see that the app configuration resource in Azure is getting hit.

So, here are the steps I've followed:

  1. Created a new .NET Core MVC project targeting 3.1 (to eliminate the fact that .NET Core 5 may have issues)
  2. Add the Microsoft.Azure.AppConfiguration.AspNetCore and Microsoft.FeatureManagement.AspNetCore NuGet packages
  3. Update startup.cs > Configure > adding in app.UseAzureAppConfiguration();
  4. Update startup.cs > ConfigureServices > adding in services.AddFeatureManagement();
  5. In the Azure Portal, created a new Azure App Configuration resource in the free tier. Added a single feature called ShowAboutMe and set the value to On
  6. In the resource, go to AccessKeys and copy the primary read only key
  7. In my application, add a new key/value in appsettings.json called "AppConfigConnectionString" and set the value to the value I just copied.
  8. In Program.cs > CreateHostBuilder > added the following:
            Host.CreateDefaultBuilder(args)  
                .ConfigureAppConfiguration((context, builder) =>  
                {  
                    var settings = builder.Build();  
    
                    if (!string.IsNullOrEmpty(settings["AppConfigConnectionString"]))  
                    {  
                        builder.AddAzureAppConfiguration(options => {  
                            options.Connect(settings["AppConfigConnectionString"]);  
                            options.Select(KeyFilter.Any);  
                            options.UseFeatureFlags();  
                        });  
                    }  
                })  
                .ConfigureWebHostDefaults(webBuilder =>  
                {  
                    webBuilder.UseStartup<Startup>();  
                });  
    
  9. In Controllers\HomeController.cs, changed the top part of the controller class to resemble this:
        private readonly IFeatureManager _featureManager;  
        private readonly ILogger<HomeController> _logger;  
    
        public HomeController(ILogger<HomeController> logger, IFeatureManager featureManager)  
        {  
            _logger = logger;  
            _featureManager = featureManager;  
        }  
    
        public IActionResult Index()  
        {  
            var features = _featureManager.GetFeatureNamesAsync();  
    
            return View();  
        }  
    
  10. Set a breakpoint on the return View() line in the Index method, executed, and checked the results of features. When navigating, I only see this response: System.Collections.Generic.IAsyncEnumerator<string>.Current = null

Any ideas what I can be missing? I have tried .NET Core 5 MVC and .NET Core 5 Razor Pages applications as well with no luck.

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
210 questions
{count} vote

3 answers

Sort by: Most helpful
  1. Jason Gaylord 6 Reputation points
    2020-06-05T15:29:21.273+00:00

    After many failed attempts, I created a brand new Azure App Configuration resource. I noticed that like the above resource, this too seems to have a glitch within the portal. Notice the deployment name says 'NoMarketplace'

    9137-nomarketplace.jpg

    Then, I tried using the primary access key which then resulted in the following error:

    9251-error.jpg

    Finally, I used the secondary access key which worked.

    Is there an issue with Azure resource provisioning?

    0 comments No comments

  2. Ashok Tewatia 1 Reputation point
    2021-09-10T08:28:45.157+00:00

    I am facing exact problem.

    var list = _featureManager.GetFeatureNamesAsync(); // list is null

    var toggle2 = _featureManager.IsEnabledAsync("toggle2"); // it give me my value.

    Why GetFeatureNamesAsync is returning null? Any Clues?

    0 comments No comments

  3. Amr Elgarhy 1 Reputation point
    2021-12-04T05:51:03.727+00:00

    To start seeing the features list you will need to iterate through, something like that:
    var featureNames = _featureManager.GetFeatureNamesAsync();

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