C
C#2y ago
zuf

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
zuf
zuf2y ago
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.
atakancracker
atakancracker2y ago
why do you have connection strings and other configurations that changes so often ?
zuf
zuf2y ago
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
atakancracker
atakancracker2y ago
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
atakancracker
atakancracker2y ago
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...
zuf
zuf2y ago
We use a class because its easier to use the values that way, statically typed instead of IConfiguration etc..
atakancracker
atakancracker2y ago
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
Want results from more Discord servers?
Add your server
More Posts