azureazure-functions

What is the settings file called for an Azure function app?


I have a function app in azure. When i develop locally on VS it is called local.settings.json

But when i deploy the app to Azure , does the settings file name change ?

what is the file called where all the application-specific settings are stored ?

I want to be able to read the file and extract some values ?


Solution

  • As the name implies, the local.settings.json file is used for local development only. The file should not be included in source control. From the documentation:

    The local.settings.json file stores app settings and settings used by local development tools1. Settings in the local.settings.json file are used only when you're running your project locally. When you publish your project to Azure, be sure to also add any required settings to the app settings for the function app.

    Instead, settings should created under the application settings tab of the function app. These settings will then be available to you in-code through environment variables. From the documentation:

    In addition to the predefined app settings used by Azure Functions, you can create any number of app settings, as required by your function code. For more information, see App settings reference for Azure Functions.

    You may then use the application setting by referencing the environment variable with its name. The exact implementation depends on the programming language that your function app uses. See the documentation for details per language.

    // a typescript example
    
    const myApplicationSettingValue = process.env['MY_APPLICATION_SETTING_NAME'];
    
    // .net example
    
    using System.Configuration.ConfigurationManager;
    
    string myApplicationSettingValue = ConfigurationManager.AppSetting['MY_APPLICATION_SETTING_NAME'];
    

    1 An example of one of these tools in Azure Function Core tools.