Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 372
Rakesh Kumar Avatar asked Jul 01 '20 04:07

Rakesh Kumar


People also ask

What is use of host json in Azure function?

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

What is the host json file for?

The host. json file is a configuration file containing the values that affect all the functions of a function app. This file is created as soon as we add an Azure Function project. This file will have at least one field to begin with, indicating the runtime version of Azure Functions.

What is AzureWebJobsStorage used for?

AzureWebJobsStorage. The Azure Functions runtime uses this storage account connection string for normal operation. Some uses of this storage account include key management, timer trigger management, and Event Hubs checkpoints. The storage account must be a general-purpose one that supports blobs, queues, and tables.


2 Answers

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.

like image 82
Sajeetharan Avatar answered Oct 17 '22 05:10

Sajeetharan


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.

like image 38
R Jain Avatar answered Oct 17 '22 03:10

R Jain