I have an Azure Service and I'm using .cscfg files for my configurations. When my service loads the .cscfg, it expects to have there at least 1 connection string.
The problem is, more connection strings may be added later to the cscfg file and I do not want to change my code in order to handle them too.
I couldn't find a way to write the cscfg in a way that it'll build a list of connection strings. Do you know if this is possible? if not, what would you suggest I do? How would I process all the connection strings without changing the code every time that I add another connection string to the cscfg?
Thanks a lot .
Unlike
app/web.config
files where you have a dedicatedConnectionStrings
element, it isNOT
possible to do the same with a service config file. As far as settings are concerned, it is simplename/value
pair.Just thinking out loud, you could possibly save all the connection strings in a serialized JSON array and have just one key named something like
ConnectionStrings
and have your code parse this JSON array and create different connection strings based on the keys in this JSON array.