Change function app configuration programmatically?

arunabha bhattacharya 181 Reputation points
2020-12-08T11:34:29.533+00:00

Given a function app, is it possible to programmatically add/update/delete a configuration value and refresh the function app so that if we go from Portal to My function app, Configuration, Application settings and click that name I see the new value?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

Accepted answer
  1. JayaC-MSFT 5,606 Reputation points
    2020-12-08T16:29:40.117+00:00

    @arunabha bhattacharya You can use the .Net core configuration : Microsoft.Extensions.Configuration. In the function you may add a parameter of type Microsoft.Azure.WebJobs.ExecutionContext context, where you can then build an IConfigurationRoot :

    var config = new ConfigurationBuilder()  
            .SetBasePath(context.FunctionAppDirectory)  
            .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)  
            .AddEnvironmentVariables()  
            .Build();  
    

    Please refer to : https://www.koskila.net/how-to-access-azure-function-apps-settings-from-c/

    Or, if you just want to avoid manual entry in the portal you may consider azure cli as an option. You can also consider ARM Template.

    I am sharing couple of relevant reference link as how to parameterize the app settings in the script :

    https://stackoverflow.com/questions/59383303/arm-templates-for-azure-functions-with-many-appsettings-for-different-environmen

    https://blogs.perficient.com/2016/03/17/azure-arm-template-define-web-app-application-settings/

    https://microsoft.github.io/AzureTipsAndTricks/blog/tip163.html

    https://kalcik.net/2019/11/21/merge-azure-app-service-app-settings-in-arm-template/

    If the answer helps, please "Accept the answer" and " up-vote" so that it helps others in the community!


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.