Michiel van Oosterhout
Michiel van Oosterhout

Reputation: 23094

Why is the Azure App Configuration feature flag not found?

Azure Functions app, runtime v3.

The application has a FunctionsStartup class that first enables Azure App Configuration in its ConfigureAppConfiguration method:

builder.ConfigurationBuilder.AddAzureAppConfiguration(options =>
{
    options
        .Connect(appConfigurationConnectionString)
        .UseFeatureFlags();
});

And in its Configure method it enables feature management, and it adds the Azure App Configuration services (so we can refresh settings at runtime):

builder.Services
    .AddAzureAppConfiguration()
    .AddFeatureManagement()
    .AddFeatureFilter<ContextualTargetingFilter>();

On the Azure Portal there is a feature flag, which is enabled, called CardExpirationNotice. The code uses IFeatureManagerSnapshot to check if the feature is enabled:

feature = nameof(Features.CardExpirationNotice);
var isEnabled = await _featureManagerSnapshot.IsEnabledAsync(feature);

isEnabled is false, and this log message is output:

The feature declaration for the feature 'CardExpirationNotice' was not found.

I tried configuring a flag locally in local.settings.json:

"FeatureManagement__CardExpirationNotice": true

Then isEnabled is true, so I can narrow the problem to Azure App Configuration, and exclude the feature management implementation.

Upvotes: 3

Views: 2521

Answers (1)

Michiel van Oosterhout
Michiel van Oosterhout

Reputation: 23094

As it turns out, when you add a feature flag in Azure App Configuration, you can set a label. But if you do that, then you need to specify that label in your code as well:

builder.ConfigurationBuilder.AddAzureAppConfiguration(options =>
{
    options
        .Connect(appConfigurationConnectionString)
        .UseFeatureFlags(options => options.Label = "payments");
});

Upvotes: 8

Related Questions