-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathProgram.cs
More file actions
47 lines (42 loc) · 1.66 KB
/
Program.cs
File metadata and controls
47 lines (42 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Microsoft.AspNetCore;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
namespace FeatureFlagDemo
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((ctx, builder) =>
{
var settings = builder.Build();
if (!string.IsNullOrEmpty(settings["AppConfiguration:ConnectionString"]))
{
//
// This section can be used to pull feature flag configuration from Azure App Configuration
builder.AddAzureAppConfiguration(o =>
{
o.Connect(settings["AppConfiguration:ConnectionString"]);
o.Select(KeyFilter.Any);
o.UseFeatureFlags();
});
}
else
{
//
// Disable Azure App Configuration provider when connection string is not configured
// This enables feature flag retrieval solely from appsettings.json
Environment.SetEnvironmentVariable("AZURE_APP_CONFIGURATION_PROVIDER_DISABLED", "true");
}
})
.UseStartup<Startup>();
}
}
}