0

Wondering if it's possible for an Azure Function to set a value of an app setting. For example whilst developing locally or in production one can read custom settings by binding it to a class

builder.Services.AddOptions<SomeSettingClass>()
                .Configure<IConfiguration>((settings, configuration) =>
                {                        configuration.GetSection(nameof(SomeSettingClass)).Bind(settings);
                });

and obviously use the settings at the main function method. However, is it possible to set a value and persist it for the next run?

nlv
  • 791
  • 7
  • 28

1 Answers1

0

There many solutions to this, Azure has Azure app configuration. it basically has all the plumbing and provides the appropriate configuration sources and providers to plugin into the ConfigurationRoot. This enables you use use the IOptionsMonitor feature to get real-time updates of configuration changes. Also there should be away to programmatically update it, however I have never tried it.

However, I find that service completely overpriced and clunky for what it is.

On that note, if you are handy with a bit of code, you could create your own ConfigurationSource and ConfigurationProvider to point to anywhere you like, for instance a CosmosDb container and do exactly the same thing. You could even use a trigger and signalR to publish those changes to any listening ConfigurationSource.

There are also various ways you can update a functions or apps configuration at runtime through the CLI etc (I am not sure if there C# management libraries for this, though I guess there is somewhere). However, they will not be real-time and have no inbuilt way of notifying as far as I know.

Which leaves you with the option of just doing a real time look up on a datastore ¯\_(ツ)_/¯. This way you can update and query at your own will, and will persist naturally.

halfer
  • 19,824
  • 17
  • 99
  • 186
TheGeneral
  • 79,002
  • 9
  • 103
  • 141