I am trying to access my settings in order to configure my services. I am using AWS systems manager to store my settings
// Settings class
public class Settings
{
public string Url { get; set; }
}
// my Program.cs code
var builder = WebApplication.CreateBuilder();
// Clear default sources
builder.Configuration.Sources.Clear();
// Get configuration
builder.Configuration.AddSystemsManager(source =>
{
source.Path = $"/{env}";
source.ParameterProcessor = new DefaultParameterProcessor();
});
// Load up the settings
builder.Services.Configure<Settings>(builder.Configuration.GetSection(appName));
// Access the settings to use for configuring the services
var settings = builder.Configuration.Get<Settings>();
When I check the settings object, the values are null. However when I inject the settings into an endpoint using IOptions<Setting>, the values are populated.
I tried the .Get<Settings> after I called Build();, but that also returned null values. Is there something I am missing?