Rakesh Kumar
Rakesh Kumar

Reputation: 3129

Azure Functions - What is the purpose of having host.json and local.settings.json

I can see two json files(host.json and local.settings.json) has been added in Azure Function directory.

host.json

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingExcludedTypes": "Request",
            "samplingSettings": {
                "isEnabled": true
            }
        }
    }
}

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  }
}

What is the purpose of having these two json files?

Upvotes: 32

Views: 41996

Answers (2)

R Jain
R Jain

Reputation: 608

Host.json is to set configs once you deploy Azure function on Azure. You can relate it to app.config/web.config. for example, you may need to define a AzureWebStorage connection string for a Storage in Azure for fucntion to run. Any other appsetting must be defined here too.

Whereas local.settings.json defines local settings which you will use for your development. For example AzureWebstorage defined is pointing to local storage. This file will be ignored during deployment. This is akin to your dev config file.

Upvotes: 9

Sajeetharan
Sajeetharan

Reputation: 222592

It is very clearly explained in the documentation , from the docs,

host.json

The host.json metadata file contains global configuration options that affect all functions for a function app. This article lists the settings that are available starting with version 2.x of the Azure Functions runtime.

Local settings

The local.settings.json file stores app settings, connection strings, and settings used by local development tools. Settings in the local.settings.json file are used only when you're running projects locally.

Upvotes: 28

Related Questions