使用 Azure 功能管理器与 "true" 和 "false" 的常规配置值相比有什么好处

What is the benefit of using the Azure Feature Manager vs regular configuration value of "true" and "false"

据我所见here如果我设置了 Azure App Config 并希望在其中包含一个功能标志,为了读取它的值或利用它我必须:

  1. 安装一个 nuget,与 Microsoft.Extensions.Configuration 我已经需要的 App Config
  2. 分开
  3. 在“CreateHostBuilder”中添加“UseFeatureFlags”
  4. 在启动服务中注册功能管理
  5. 有一个枚举,专门为每个标志设计
  6. 在“_ViewImports”中注册功能管理器

而且我看不出所有这些给我带来什么好处,而不是让标准配置值带有“真”或“假”并跳过所有前面的步骤,只去“if (featureValue)”。

那么,我不知道的好处是什么值得经历那么多麻烦?

简而言之,这里有一些优点:

  • 管理功能标志的集中位置
  • 标签选项
  • 功能过滤器

A Targeting filter is a built-in filter which allows dynamic enabling or disabling of features for specific users or groups. For example, you can use a targeting filter to enable a feature for only a specific user during a demo. You could also use it to progressively roll out new features to users in custom groups or "rings", or to set a default rollout percentage to release features to all users.

除此之外,功能管理可帮助开发人员解决以下问题:

  • Code branch management: Use feature flags to wrap new application functionality currently under development. Such functionality is "hidden" by default. You can safely ship the feature, even though it's unfinished, and it will stay dormant in production. Using this approach, called dark deployment, you can release all your code at the end of each development cycle. You no longer need to maintain code branches across multiple development cycles because a given feature requires more than one cycle to complete.
  • Test in production: Use feature flags to grant early access to new functionality in production. For example, you can limit access to team members or to internal beta testers. These users will experience the full-fidelity production experience instead of a simulated or partial experience in a test environment.
  • Flighting: Use feature flags to incrementally roll out new functionality to end users. You can target a small percentage of your user population first and increase that percentage gradually over time.
  • Instant kill switch: Feature flags provide an inherent safety net for releasing new functionality. You can turn application features on and off without redeploying any code. If necessary, you can quickly disable a feature without rebuilding and redeploying your application.
  • Selective activation: Use feature flags to segment your users and deliver a specific set of features to each group. You may have a feature that works only on a certain web browser. You can define a feature flag so that only users of that browser can see and use the feature. With this approach, you can easily expand the supported browser list later without having to make any code changes.

来源:Feature management overview

关键功能可能是使用 条件 功能标志,https://docs.microsoft.com/en-us/azure/azure-app-configuration/howto-feature-filters-aspnet-core,这比仅在配置中存储布尔值要复杂得多。

使用一致支持两者的库是一个更好的主意。

但是,如果您只打算使用静态功能标志,您可能会认为付出的努力超过了它的价值。