功能管理、功能切换、功能标志不适用于 Azure App Configuration Store
Feature management, feature toggle, feature flags not working with Azure App Configuration Store
我正在尝试向 .net core 2.2 控制台应用程序添加功能标志。功能标志在 Azure 应用程序配置存储中定义。
当在 appsettings.json 文件中定义功能标志时,我遇到了一个问题,但它成功了。完整的控制台项目在我的 中定义。这不是问题。
我正在尝试关注 tutorial and this is driving me nuts. The problem here is this tutorial is not simple. Its a web app, on the top of it, he used Secret manager tool。
我根本无法让 webapp 按照教程中的描述工作,所以我尝试首先创建一个简单的控制台应用程序,但到目前为止无法成功使用 Azure App Config store。
这是到目前为止无法运行的控制台应用程序。非常感谢任何帮助。
以下是添加到控制台项目的包。
- Microsoft.Extensions.Configuration.AzureAppConfiguration
- Microsoft.Extensions.Configuration.Json
- Microsoft.Extensions.DependencyInjection
- Microsoft.FeatureManagement
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.FeatureManagement;
using Microsoft.FeatureManagement.FeatureFilters;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
namespace ConfigurationConsoleApp
{
class Program
{
static async Task Main(string[] args)
{
var builder = new ConfigurationBuilder();
var azureConnectionString = "<APP_CONFIGURATION_CONNECTION_STRING>";
//builder.AddAzureAppConfiguration(options =>
//{
// options.Connect(azureConnectionString).UseFeatureFlags();
//});
builder.AddAzureAppConfiguration(azureConnectionString);
var config = builder.Build();
Console.WriteLine(config["TestApp:Settings:Message"] ?? "Hello world!");
var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var services = new ServiceCollection();
//services.AddSingleton<IConfiguration>(configuration).AddFeatureManagement().AddFeatureFilter<PercentageFilter>().AddFeatureFilter<AccountIdFilter>();
services.AddSingleton<IConfiguration>(config).AddFeatureManagement();//.AddFeatureFilter<PercentageFilter>().AddFeatureFilter<AccountIdFilter>();
const string FeatureName = "Beta";
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
{
var featureManager = serviceProvider.GetRequiredService<IFeatureManager>();
var enabled = await featureManager.IsEnabledAsync(FeatureName);
Console.WriteLine($"The {FeatureName} feature is {(enabled ? "enabled" : "disabled")} ");
}
}
}
}
您是否看过 Microsoft.FeatureManagement GitHub 存储库中的示例应用程序?
https://github.com/microsoft/FeatureManagement-Dotnet/tree/master/examples/FeatureFlagDemo
https://github.com/microsoft/FeatureManagement-Dotnet/tree/master/examples/ConsoleApp
您的代码看起来应该可以工作。除非在名为 "Beta".
的 Azure 应用程序配置实例中创建功能标志,否则它不会工作
我正在尝试向 .net core 2.2 控制台应用程序添加功能标志。功能标志在 Azure 应用程序配置存储中定义。
当在 appsettings.json 文件中定义功能标志时,我遇到了一个问题,但它成功了。完整的控制台项目在我的
我正在尝试关注 tutorial and this is driving me nuts. The problem here is this tutorial is not simple. Its a web app, on the top of it, he used Secret manager tool。
我根本无法让 webapp 按照教程中的描述工作,所以我尝试首先创建一个简单的控制台应用程序,但到目前为止无法成功使用 Azure App Config store。
这是到目前为止无法运行的控制台应用程序。非常感谢任何帮助。
以下是添加到控制台项目的包。
- Microsoft.Extensions.Configuration.AzureAppConfiguration
- Microsoft.Extensions.Configuration.Json
- Microsoft.Extensions.DependencyInjection
- Microsoft.FeatureManagement
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.FeatureManagement;
using Microsoft.FeatureManagement.FeatureFilters;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
namespace ConfigurationConsoleApp
{
class Program
{
static async Task Main(string[] args)
{
var builder = new ConfigurationBuilder();
var azureConnectionString = "<APP_CONFIGURATION_CONNECTION_STRING>";
//builder.AddAzureAppConfiguration(options =>
//{
// options.Connect(azureConnectionString).UseFeatureFlags();
//});
builder.AddAzureAppConfiguration(azureConnectionString);
var config = builder.Build();
Console.WriteLine(config["TestApp:Settings:Message"] ?? "Hello world!");
var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var services = new ServiceCollection();
//services.AddSingleton<IConfiguration>(configuration).AddFeatureManagement().AddFeatureFilter<PercentageFilter>().AddFeatureFilter<AccountIdFilter>();
services.AddSingleton<IConfiguration>(config).AddFeatureManagement();//.AddFeatureFilter<PercentageFilter>().AddFeatureFilter<AccountIdFilter>();
const string FeatureName = "Beta";
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
{
var featureManager = serviceProvider.GetRequiredService<IFeatureManager>();
var enabled = await featureManager.IsEnabledAsync(FeatureName);
Console.WriteLine($"The {FeatureName} feature is {(enabled ? "enabled" : "disabled")} ");
}
}
}
}
您是否看过 Microsoft.FeatureManagement GitHub 存储库中的示例应用程序?
https://github.com/microsoft/FeatureManagement-Dotnet/tree/master/examples/FeatureFlagDemo https://github.com/microsoft/FeatureManagement-Dotnet/tree/master/examples/ConsoleApp
您的代码看起来应该可以工作。除非在名为 "Beta".
的 Azure 应用程序配置实例中创建功能标志,否则它不会工作