Reputation: 167
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?
Upvotes: 2
Views: 1877
Reputation: 1556
I found this thread when looking for this answer. You could use app configuration service so you could dynamically update that. The azure function https://learn.microsoft.com/en-us/azure/azure-app-configuration/overview
Watch out that on a free tier app configuration service it allows 1,000 requests a day where standard allows 20,000 an hour. It seems in .NET you can cache some.
Upvotes: 0
Reputation: 12538
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.
Upvotes: 5
Reputation: 43193
You cannot dynamically add App Settings to a Function App. The way to add them is to add Azure App Settings either via Portal, ARM API, or CLI tool.
Upvotes: 3