-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathProgram.cs
41 lines (38 loc) · 1.55 KB
/
Program.cs
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using System;
namespace Microsoft.Extensions.Configuration.AzureAppConfiguration.Examples.ConfigStoreDemo
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
// 1. Load settings from a JSON file and Azure App Configuration
// 2. Retrieve the Azure App Configuration connection string from an environment variable
// 3. Set up the provider to listen for changes to the background color key-value in Azure App Configuration
var settings = config.AddJsonFile("appsettings.json").Build();
config.AddAzureAppConfiguration(options =>
{
options.Connect(settings["connection_string"])
.ConfigureRefresh(refresh =>
{
refresh.Register("Settings:BackgroundColor")
.SetRefreshInterval(TimeSpan.FromSeconds(10));
});
});
})
.UseStartup<Startup>()
.Build();
}
}
}