I am using pre-compiled Azure Functions and I know I can read values in the App Settings using the ConfigurationManager.AppSettings["keyname"].
I have been trying to create an additional App Setting using something like the below:
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
settings.Add(pair.Key, pair.Value);
However when I try this I get the following error message:
exePath must be specified when not running inside a stand alone exe.
Any ideas if this is even possible? Or able to provide a pointer as how to get it working?
The Azure Functions runtime configuration file is not writable, but as it runs App Service, it inherits the App Settings feature supported by it, which gives you access to manage settings that will be injected as both, application settings and environment variables at runtime through the portal.
You can manage those settings programmatically via ARM, or through the CLI.
Keep in mind that changes to those settings will trigger a site restart, so depending on your scenario, if you need settings that will be dynamically updated, you may want to consider using a different configuration/settings source, including a caching option like Redis to maintain shared state.
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