28

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?

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Rakesh Kumar
  • 2,701
  • 9
  • 38
  • 66

2 Answers2

25

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.

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • 5
    I wish it were consistent with AspNet: appsettings.json for local and prod settings. appsettings.{environment}.json for settings that override/add to appsettings.json. Then when {environment} is development, you get the same effect as local.settings.json. – MarkD May 19 '21 at 18:46
  • 3
    Does the Host.json settings get deployed to the Azure Function? – Joe Sep 08 '21 at 19:09
  • 1
    @Joe yes you are right – Vipin Oct 11 '21 at 04:23
  • 3
    Documentation doesn't share a key detail... where in Azure Function is host.json deployed to/visible? Answer: follow these in the left-nav: YourFuncAppRoot\App files\host.json – Don Cheadle Jan 28 '22 at 17:56
  • 1
    @DonCheadle: I've been looking for that detail, about where the host.json is within a Function App. It was very difficult to find anything about where it's deployed to. Thanks. – Simon Elms Mar 28 '22 at 00:15
  • My host.json wasn't deploying until I set the file to 'copy always' in properties. – codah Jul 19 '22 at 06:02
  • To override a host.json setting in slot settings: `AzureFunctionsJobHost__` – JoeBrockhaus Jan 29 '23 at 06:29
6

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.

R Jain
  • 486
  • 3
  • 9