aspnet / MicrosoftConfigurationBuilders

Microsoft.Configuration.Builders
MIT License
122 stars 61 forks source link

ConfigurationBuilder refresh #190

Closed mcortellino closed 2 years ago

mcortellino commented 2 years ago

Hello, I am experimenting with a custom configuration builder that loads secrets from an external vault. Is there any way to force configuration reloading programmatically without restart the entire web application? I tried using ConfigurationManager.RefreshSettings methed but it seems that it has no effect, after calling it the Initial method nor the GetAllValues of my ConfigurationBuulder are called again. Is this kind of scenario supported?

Thanks

StephenMolloy commented 2 years ago

In a web app that uses the HttpConfigurationSystem.. no, there is no support for this. It shouldn't work at all.

In a client app that uses the base configuration system... maybe. The legacy config system had a few "pie-in-the-sky" ideas when it was first conceived over 20 years ago. Some of those ideas just flat out didn't get implemented. Some, like this "refresh" concept... well, it looks like it's sort of there. If you're curious, you could try it out in a console app. But there is so much code in desktop .Net that just assumes configuration is static that applying config builders the first time it loads has been a challenge at times. If it's just your code that directly cares about refreshed values, it might work.

But that possibility is probably moot in your case because you're in a web app, and the web config system does not support this scenario at all.