Is there any way to use Ocelot with multiple Configuration files and environments like ocelot.service1.Development.json
?
Unfortunately the documentation seems to be outdated and also it doesn't handle my specific request. I saw that it is able to have multiple files that will be merged Documentation:
ocelot.service1.json
ocelot.service2.json
//Program.cs
return WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((host, config) => {
config
.AddOcelot(host.HostingEnvironment)
.AddEnvironmentVariables();
})
.UseStartup<Startup>();
}
It works but doesn't meet my requirements.
The documentation also describes following setup Documentation:
ocelot.Development.json
ocelot.Staging.json
//Program.cs
return WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((host, config) => {
config
.AddJsonFile("ocelot.{host.HostingEnvironment.EnvironmentName}.json", true, true)
.AddEnvironmentVariables();
})
.UseStartup<Startup>();
}
But this solution also doesn't meet my requirements.
Is there any way how I can combine both ways?
I've come up with a solution:
I edited the extension method .AddOcelot(folder, env)
. I've added a new parameter appNames
which is an array of the names in the files to read from appName.ocelot.Dev.json
to find the files.
Screenshots:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With