简体   繁体   English

Azure Microsoft.FeatureManagement.FeatureManager 未检索到具有 Label 的应用程序配置功能标志

[英]Azure App Configuration Feature Flag with Label is not retrieved by Microsoft.FeatureManagement.FeatureManager

I started using Azure App Configuration service and Feature Flags functionality in my project.我开始在我的项目中使用 Azure App Configuration 服务和 Feature Flags 功能。 The thing that I saw is whenever I define a new feature flag and set some value for the label field then it's not retrieved by the _featureManager.GetFeatureNamesAsync();我看到的是,每当我定义一个新功能标志并为 label 字段设置一些值时,它就不会被_featureManager.GetFeatureNamesAsync();检索到。 for some reason.因为某些原因。 I created a FeatureFlagManager for sake of feature flag management, which looks like this:为了功能标志管理,我创建了一个FeatureFlagManager ,它看起来像这样:

public class FeatureFlagManager: IFeatureFlagManager
{
    private readonly IFeatureManager _featureManager;

    public FeatureFlagManager(IFeatureManager featureManager)
    {
        _featureManager = featureManager;
    }

    public async Task<IEnumerable<FeatureFlag>> GetFeatureFlags()
    {
        var featureList = new List<FeatureFlag>();           
        var featureNames = _featureManager.GetFeatureNamesAsync();

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

        return featureList;
    }
}

The REST API endpoint: REST API 端点:

[HttpGet]
[Route("featureFlags")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<FeatureFlag>))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetFeatureFlags()
{
    using (new Tracer(Logger, $"{nameof(ConfigurationController)}.{nameof(GetFeatureFlags)}"))
    {
        return Ok(await _featureFlagManager.GetFeatureFlags());

    }
}

I have 5 feature flags defined in the Azure Configuration:我在 Azure 配置中定义了 5 个功能标志: 在此处输入图像描述

but whenever I call my endpoint to get all the feature flags with values, the one that has label defined is get ignored;但是每当我调用我的端点以获取所有具有值的功能标志时,定义了 label 的那个将被忽略; 在此处输入图像描述

Is there any reason why it works this way or am I missing something?它以这种方式工作有什么原因还是我遗漏了什么? The other thing that I noticed is once you create a new feature flag in Azure and define a label, there is no further option to edit it.我注意到的另一件事是,一旦您在 Azure 中创建了一个新功能标志并定义了一个 label,就没有进一步的选项来编辑它了。 Cheers干杯

In program.cs you need to tell the configuration to return the Flags with labels.在 program.cs 中,您需要告诉配置返回带标签的标志。

                    if (!string.IsNullOrEmpty(settings["AppConfigConnectionString"]))
                {
                    builder.AddAzureAppConfiguration(options => {
                        options.Connect(settings["AppConfigConnectionString"]);
                        options.UseFeatureFlags(opt => opt.Label = "WHAT_EVER_LABEL_YOU_WANT");
                    });
                }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 Spring 引导获取具有特定 label 的 Azure 应用程序配置功能标志的值? - How to get the value of Azure App Configuration Feature Flag with specific label from Spring boot? 刷新Azure 基于Label的App配置 - Refreshing Azure App Configuration Based on Label Key和Label对Azure App配置的限制 - Limitations of Key and Label for Azure App Configuration 部署Azure function到微软Azure中的应用服务 - Deploy Azure function to app service in Microsoft Azure 无法更新 Azure App 中的配置设置 - Unable to Update Configuration Settings in Azure App .Net App in Docker - Startup Can't Find Azure App Configuration - .Net App in Docker - Startup Can't Find Azure App Configuration 使用 Azure 功能管理器与常规配置值“true”和“false”相比有什么好处 - What is the benefit of using the Azure Feature Manager vs regular configuration value of "true" and "false" Dockerized NGINX 配置 ReactJS App 在 Azure 上运行(容器实例) - Dockerized NGINX Configuration with ReactJS App Running on Azure (Container Instances) Azure 服务总线功能 - Azure Service Bus Feature Angular Azure应用服务SSR配置 - Angular SSR configuration on Azure app service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM