I want to load appsettings from app.config or web.config,
without using the Configuration manager or configuration settings.
Instead I want it to use from Memory cache directly.
Since memory cache holds the current running project app data :
Is there a way to load it directly from it?
Related
I am converting a working WebApp project to use a Function App instead. While I can use SQLite with EF Core on the Web App, the Function App fails. I used the latest EntityFramework.SQLite.Core libraries. I am deploying to a local Docker container so the folder structure is as it would be on Azure. Here is my test project showing the issue.
I copied the database to the /home directory but to no avail. I expect the Seed process to pass the check for !Employees.Any() and if true then seed the database with the CSV mock data file. But the first attempt to access the database with Employees.Any() gives the error:
DllNotFoundException: Unable to load shared library 'e_sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libe_sqlite3: cannot open shared object file: No such file or directory
How to get around this? It would be a way to cheaply host an API.
I have exported the IIS settings from the Shared Configuration section.
I believe that the exported file contains all the IIS settings, app pool/settings, website/settings which can be restored onto another IIS server to replicate the configuration (for example - in case the 1st server crashes permanently).
How to import them onto another IIS?
When we Export the configuration and if you have stored it on the network drive(shared location) it will create 3 files like below.
You could check Enable Shared Configuration option and pass the shared location path and credentials.
It will give you some pop-ups, you could read them and take action.
After that, the configuration will be taken from those files.
Reference: Shared Configuration
I know that a good way to store data like db passwords, etc. is via environment variables, but setting environment variables manually for every server instance created is time consuming.
I'm planning to deploy my project to the cloud (using aws ebs or heroku).
where should I store my db password?
I think the .ebextensions file isn't a good option because it's tracked in vcs
Don't ever store secrets in source control. A common practice is to either put them in a secure file or in something like https://www.vaultproject.io/ then inject them (programmatically via a script or some other deployment/configuration tool) into the environment when you bring up your VM (or container or whatever).
My recommendation is to create a properties file which can be stored in the resources folder of your application and the code can access the resources. do not need environment variable. One property file can contain all db's userid and passwords. Deploy job based on url mapping in the properties file. For example, look at a spring hibernate example project which uses a property file. Or look at ant deploy scripts. Hope it helps.
Part 1: I've been trying to load a (XML) file as a resource from disk using bundle class loader. I can't package the file in a bundle beforehand as it'll be generated at runtime. I tried searching too, and almost always, people talk about loading resources from within a bundle (either same or different). So is it even possible to load a resource from disk in an OSGi environment using bundle classloader? If yes, how can it be done?
Part 2: Now I need to add a constraint to the above. In my complete scenario, while I'd be generating the file, it would be loaded by a third-party bundle. In this case, what could be done (generate in a certain location, any changes to classpath etc.) so that the third-party bundle's class loader could find the generated file?
Using: apache karaf 3.0.2, ubuntu 12.
Part 1:
So is it even possible to load a resource from disk in an OSGi environment using bundle classloader?
Resources (read-only files on the classpath) can be loaded with classloaders, not ordinary files from any folder of the disk. When you want to process the content of files from the ClassPath, you should use the classloader.
You want to generate a temporary file (generated and processed at runtime) so you should use the standard Java API for that:
File myTmpFile = File.createTempFile(...);
For more info, see the javadoc of this function: https://docs.oracle.com/javase/7/docs/api/java/io/File.html#createTempFile(java.lang.String,%20java.lang.String)
Part 2:
The third bundle should have an API that either accepts a File, URL, Path or other type instance that can point to a file in the file system.
On a project I am working on, we usually keep our application settings defined in a separate file. This is how it has been done for many years, and going forward we would like to keep all system configurations in one file. I was considering to use the web.config section so I can just load the configurations that I need from my C# code running on the server using the ConfigurationManager class.
If I use our own way for the application settings, I would load it in a session and have it available for the application by loading values from the session. After some reading online it looks like some of the performance issues behind using the session is that we have to deserialize the values from the session object.
Does IIS deserialize the web.config values each time we read values using the ConfigurationManager?
Thank you,
Vijay Selvaraj
Web.config is read once upon loading of the AppDomain. It is refreshed if any changes are made to it or any referenced files (you can put sections into external files by using the configsection= attribute on a section)
No, configuration sections are deserialized into the custom classes that reflect them only when the configuration file is re-read (such as when the app pool is recycled, a change to web.config is detected, and a couple of other conditions).
See also this question.