When should I store configuration data in a database, not my web.config?

I usually save all application configuration data in web / app.config files and related xml configuration files. But I thought that perhaps this is not necessarily the best way to process all configuration data.

Are there any suggestions as to when it would be more appropriate to use one or the other?

+4
source share
3 answers

I do not have a clear rule, but my "rule of thumb" is to locally only store the configuration specific to the computer on which the program is running, and to store all the general configuration data in the database.

We have developed a small library for storing and editing / version of our configuration in the database. We also developed a repository of common configurations with separate areas for each application and the ability to reuse configuration entries in multiple applications. We store high-level configuration entries such as rules, request definitions, etc. In the database.

A location-specific configuration, such as the location of plug-in collections, the connection string for the database-based configuration library, logging options, etc. included in the "normal" web / app.config files. This allows us to maintain a relatively clean separation of local and general configuration.

+2
source

If the configuration contains sensitive data and needs another level of security (i.e. RDBMS security), then save the configuration to the database. Conversely, if client administrators need easy and quick access and do not have to hack the database using UPDATE commands, then it would be wise to save the config in the configuration file.

+2
source

If you want to change the configuration values โ€‹โ€‹without restarting the website, save them in the database. But this adds a copmlexity layer, which most developers will not want to find them first when looking for configuration values. The standard, at least in my store, is to put all the values โ€‹โ€‹that can be changed in the web.config file and encrypt them if necessary (credentials for third-party services, databases, etc.). If someone had to set the configuration values โ€‹โ€‹to the database, the developer, during the first immersion in the code, would spend some time searching where the configuration values โ€‹โ€‹are stored (but this is just a one-time thing, but still a nuisance).

0
source

Source: https://habr.com/ru/post/1390440/


All Articles