[英]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.