I have this application that uses the appsettings.json
to store some configurations like API addresses, tokens, paths to save files, etc.
We don't have DevOps, so for each change we do in the appsettings, we need to ask infrastructure team to deploy the changes to production.
That said, I'm thinking if it's possible to place some of this configuration in database and in the Startup
constructor or in ConfigureServices
to get this information from database and use it in the application.
That's just to don't need a new deploy every time I add a new key to the appsettings for example. I would simply create a new record in the database and the app will use this configuration as if it is in the appsettings.
Today we have this:
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
And I want to know if there is viable, or possible something like this:
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.GetConfigFromDataBase() /// And this will be the method to get from DB the dynamic configuration
.AddEnvironmentVariables();
Configuration = builder.Build();
}
Is it possible? Or I'm trying to reinvent the wheel?
Thank you in advance for your time !