Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
In our deployments, we use multiple folders for different configuration values.
/var/configs/database1/connectionString
/var/configs/database2/connectionString
The KeyPerFile mechanism seems unable to load data recursively and cannot add a prefix to each key named by a file.
We cannot change some configuration names, such as “connectionString”. If we want to use two different databases, the keys may conflict.
Describe the solution you'd like
I'd like to add a custom prefix to every variable
new ConfigurationBuilder()
.AddKeyPerFile("/var/configs/database1", optional: true, keyPrefix: "db1:")
.AddKeyPerFile("/var/configs/database2", optional: true, keyPrefix: "canary:");
Using following file structure:
/var/configs/database1/connectionString
/var/configs/database1/someValue
/var/configs/database2/connectionString
/var/configs/database2/someOtherValue
The configuration will now have following keys:
db1:connectionString
db1:someValue
canary:connectionString
canary:someOtherValue
As an alternative for the same structure above:
new ConfigurationBuilder()
.AddKeyPerFile("/var/configs", optional: true, recursive: true);
Would lead to following configuration.
database1:connectionString
database1:someValue
database2:connectionString
database2:someOtherValue
Additional context
No response