I figured it out… all the pieces were there I just needed to glue them together.
- Create a new Project
- Define it as a Windows Service
- Do not define it to pull configuration values from Azure.
- Create a class (as shown) that will pull from Azure on demand
a. Make it a singleton
b. Start up with a timer.
c. Once configuration values are captured delete the timer.
d. Pass the singleton around everywhere that needs config values. - Map values pulled from Azure to local properties.
public bool Refresh() { bool result = false; try { string env = configuration.GetValue<string>($"CurrentEnvironment"); string endPoint = configuration.GetValue<string>($"AppConfigEndpoint_{env}"); IConfigurationBuilder configBuilder = new ConfigurationBuilder(); configBuilder.AddAzureAppConfiguration(options => { options.Connect(endPoint.Decrypt()) .Select(KeyFilter.Any, "Deployed") .Select(KeyFilter.Any, "Upload"); }); IConfiguration configs = configBuilder.Build(); foreach (var item in configs.GetChildren()) { // map values to properties Console.WriteLine($"{item.Key}: {item.Value}"); } result = true; } catch (Exception ex) { Exception = ex; } return result; }