Skip to content

Instantly share code, notes, and snippets.

@kasunkv
Created January 25, 2020 20:04
Show Gist options
  • Save kasunkv/0632e2d43d16f863e4b29a49f6c14821 to your computer and use it in GitHub Desktop.
Save kasunkv/0632e2d43d16f863e4b29a49f6c14821 to your computer and use it in GitHub Desktop.
Using a label to filter feature flags on Azure App Configuration
namespace MusicStore.Web
{
public class Program
{
...
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseStartup<Startup>();
})
.ConfigureAppConfiguration((context, config) => {
var settings = config.Build();
var appConfigConnection = settings["ConnectionStrings:AppConfiguration"];
if (!string.IsNullOrEmpty(appConfigConnection))
{
config.AddAzureAppConfiguration(options =>
{
options
.Connect(settings["ConnectionStrings:AppConfiguration"])
.UseFeatureFlags(opt => {
// Use the environment variable set on Azure App Service as the label.
opt.Label = Environment.GetEnvironmentVariable("REGION_NAME")?.ToLowerInvariant().Trim().Replace(' ', '_');
});
});
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment