Restore Azure Functions App Settings for Local Development
    • Dark
      Light
    • PDF

    Restore Azure Functions App Settings for Local Development

    • Dark
      Light
    • PDF

    Article Summary

    #ServerlessTips - Azure Functions
    Author: Rahul Rai Microsoft MVP

    The local.settings.json file (documentation) stores configuration data, such as app settings, connection strings, etc., for local development in Azure Functions. Since it contains sensitive data, it is never checked into source control. However, you may need to download the app settings from the live function app for local development to save time copying configuration values from source control systems. You can easily do this with Azure Function Core Tools, which you can install by running the following command:

    $ npm install -g azure-functions-core-tools 
    

    While this exercise focuses on fetching app settings from a live function app, the Azure Function Core Tools can handle many other tasks, such as creating and deploying Azure Functions. The Azure Function Core Tools rely on the Azure CLI to log in (az login command) and set the current subscription (az account set command). Therefore, you must install the Azure CLI and complete the two operations before proceeding.

    Go to the source code of your Azure Function app and create a file named local.settings.json, where the settings will be saved. To download the settings, use the following command:

    $ func azure functionapp fetch-app-settings <function app name>
    

    This command will populate the file with encrypted setting values. An example of the state of the file after executing this command is shown in the following screenshot:
    MicrosoftTeams-image 513

    Figure 1 Encrypted setting values

    Execute the following command to replace encrypted values with decrypted values:

    $ func settings decrypt 
    

    You can now use the app settings with your function app for local debugging.

    MicrosoftTeams-image 491


    Was this article helpful?