Dynamic settings (auto update)
Hey! To put it very basic, I have a static class in my project
Constants
with a static property Settings
my settings property is a class with a lot of properties such as connection strings and other relevant settings for our app.
The goal is to update this entire class dynamically during run time. To put it very simple, can I just register a worker that pulls the new settings every x minutes and just replaces the Settings
object in my Constants
class or am I going to run into thread safety issues?7 Replies
Trying to achieve https://learn.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-aspnet-core?tabs=core6x#reload-data-from-app-configuration but not using Azure App Configuration
Tutorial: Use dynamic configuration in an ASP.NET Core app - Azure ...
In this tutorial, you learn how to dynamically update the configuration data for ASP.NET Core apps.
why do you have connection strings and other configurations that changes so often ?
It was rather a very basic example, we have other settings that we would like to update runtime without restarting the application. Another example would be toggling certain features/functions etc
Static class doesnt look good solution for me, you can store your configurations in json or config file
you can create an endpoint which will reload the configuration into application memory when its called
I assume you would use ConfigurationManager to read json/config file into memory and inject it to your classes
Once that endpoint triggered, it can call ConfigurationManager.RefreshSection or other helper similar to that
Stack Overflow
Reloading configuration without restarting application using Config...
Has anyone got this working in a web application?
No matter what I do it seems that my appSettings section (redirected from web.config using appSettings file=".\Site\site.config") does not get re...
We use a class because its easier to use the values that way, statically typed instead of IConfiguration etc..
how do you feed that static class, and do you change your configurations manually or its fired from code
in either case, consider using Config File with ConfigurationManager and ConfigurationManager.RefreshSection. This looks good solution for you imo