Can we write the merged ocelot.json file to memory instead to disk? #295
Unanswered
Suneetha-BA
asked this question in
Q&A
Replies: 1 comment
-
This is definitely a must have feature to be able to deploy to containers and in general cloud environment where the processes [must not / do not] have permission to write to the file system |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In ocelot 23.2 documentation, they mention that you can write the ocelot.json (primary file) to memory, is that possible using AddOcelotWithSwaggerSupport method?
Here is the snippet from the documentation:
Merging files to memory [2]
By default, Ocelot writes the merged configuration to disk as ocelot.json (the primary configuration file) by adding the file to the ASP.NET configuration provider.
If your web server lacks write permissions for the configuration folder, you can instruct Ocelot to use the merged configuration directly from memory. Here’s how:
// It implicitly calls ASP.NET AddJsonStream extension method for IConfigurationBuilder
// config.AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(json)));
config.AddOcelot(context.HostingEnvironment, MergeOcelotJson.ToMemory);
This feature proves exceptionally valuable in cloud environments like Azure, AWS, and GCP, especially when the app lacks sufficient write permissions to save files. Furthermore, within Docker container environments, permissions can be scarce, necessitating substantial DevOps efforts to enable file write operations. Therefore, save time by leveraging this feature! [2]
Beta Was this translation helpful? Give feedback.
All reactions