How to read the configuration from a separate file?
See original GitHub issueNow the configuration is in the appsettings.json file in the section: “Finbuckle:MultiTenant:Stores:ConfigurationStore”
Is it possible to use a separate file for the “Finbuckle:MultiTenant:Stores:ConfigurationStore”?
I pack my app to the Docker image and it may be useful to locate the config file in a mapped folder to provide user possibility to edit the configuration.
I have made: moved the section “Finbuckle:MultiTenant:Stores:ConfigurationStore” to the appsettings2.json file
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile(@"..\Config\appsettings2.json", optional: true)
.Build();
services.AddMultiTenant<DerivedTenantInfo>()
.WithStore<ConfigurationStore<DerivedTenantInfo>>(ServiceLifetime.Singleton)
.WithHostStrategy(tenantSettings.HostTemplate)
.WithPerTenantOptions<S3ConfigOptions>((options, tenantInfo) =>
{
options.ServiceURL = tenantInfo.S3ServiceURL;
});
But when I run the app it gives an exception:
Finbuckle.MultiTenant.MultiTenantException: Section name provided to the Configuration Store is invalid.
at Finbuckle.MultiTenant.Stores.ConfigurationStore`1..ctor(IConfiguration configuration, String sectionName)
at Finbuckle.MultiTenant.Stores.ConfigurationStore`1..ctor(IConfiguration configuration)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Reading settings from separate config file - asp.net
I used a configuration helper in a shared DLL, and an app.config file in the DLL that uses the Settings.Properties.Default stuff by editing...
Read more >How to: Read application settings - .NET Framework
NET Framework project, right-click on your project in Solution Explorer and choose Add > New Item. Choose the Application Configuration File ...
Read more >Store custom information from a configuration file - C# | ...
In the Name text box, type App.config, and then select Add. You can use an application configuration file to collect custom application settings...
Read more >Read a configuration file
The task is to read a configuration file in standard configuration file format, and set variables accordingly. ... You are encouraged to solve...
Read more >From Novice to Expert: How to Write a Configuration file ...
You can use FORCE_ENV_FOR_DYNACONF to let the application read a different section in your settings file, or use monkeypatch to replace a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @Oleg26Dev Thanks for the details. Two things:
The path to your json file should be
@".\Config\appsettings2.json"
(only a single leading dot) based on your folder configuration.You create a config in
Main
, but that is a totally separate configuration from the one ASP.NET Core creates and uses. To add your json file to the built-in configuration callConfigureAppConfiguration
as a part of yourCreateHostBuilder
method:Give that a try, that should get you going. I was able to run the app like that.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.