Created
January 25, 2020 20:04
-
-
Save kasunkv/0632e2d43d16f863e4b29a49f6c14821 to your computer and use it in GitHub Desktop.
Using a label to filter feature flags on Azure App Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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