From 04555dbb3997d6e885fec4f7635e376985d32aed Mon Sep 17 00:00:00 2001 From: Tom Pallister Date: Tue, 27 Feb 2018 08:41:58 +0000 Subject: [PATCH] docs for multiple environments (#250) --- docs/features/configuration.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/features/configuration.rst b/docs/features/configuration.rst index 3bd4da2f..5aa054f8 100644 --- a/docs/features/configuration.rst +++ b/docs/features/configuration.rst @@ -78,6 +78,29 @@ Set it true if the request should automatically follow redirection responses fro - _UseCookieContainer_ is a value that indicates whether the handler uses the CookieContainer property to store server cookies and uses these cookies when sending requests. The default value is true. +Multiple environments +^^^^^^^^^^^^^^^^^^^^^ + +Like any other asp.net core project Ocelot supports configuration file names such as configuration.dev.json, configuration.test.json etc. In order to implement this add the following +to you + +.. code-block:: csharp + + .ConfigureAppConfiguration((hostingContext, config) => + { + config + .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath) + .AddJsonFile("appsettings.json", true, true) + .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true) + .AddJsonFile("configuration.json") + .AddJsonFile($"configuration.{hostingContext.HostingEnvironment.EnvironmentName}.json") + .AddEnvironmentVariables(); + }) + +Ocelot should now use the environment specific configuration and fall back to configuration.json if there isnt one. + +You also need to set the corresponding environment variable which is ASPNETCORE_ENVIRONMENT. More info on this can be found in the `asp.net core docs `_. + Store configuration in consul ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^