【问题标题】:Why is the Azure App Configuration feature flag not found?为什么找不到 Azure 应用程序配置功能标志?
【发布时间】:2021-12-08 03:48:24
【问题描述】:

Azure Functions 应用,运行时 v3。

应用程序有一个 FunctionsStartup 类,它首先在其 ConfigureAppConfiguration 方法中启用 Azure 应用配置:

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

在其Configure 方法中,它启用了功能管理,并添加了 Azure 应用配置服务(因此我们可以在运行时刷新设置):

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

在 Azure 门户上有一个已启用的功能标志,称为 CardExpirationNotice。代码使用IFeatureManagerSnapshot检查该功能是否开启:

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

isEnabledfalse,输出这条日志信息:

未找到功能“CardExpirationNotice”的功能声明。

我尝试在 local.settings.json 中本地配置一个标志:

"FeatureManagement__CardExpirationNotice": true

那么isEnabledtrue,所以我可以将问题缩小到 Azure 应用配置,并排除功能管理实现。

【问题讨论】:

    标签: azure-app-configuration feature-flags


    【解决方案1】:

    事实证明,当您在 Azure 应用配置中添加功能标志时,您可以设置标签。但如果你这样做,那么你也需要在代码中指定该标签:

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

    【讨论】:

      猜你喜欢
      • 2020-07-25
      • 2021-11-08
      • 1970-01-01
      • 2020-10-17
      • 2022-01-06
      • 2019-01-30
      • 1970-01-01
      • 2011-12-04
      • 1970-01-01
      相关资源
      最近更新 更多