1

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.

4

1 回答 1

2

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");
});
于 2021-10-21T11:15:18.977 回答