host.json reference for Azure Functions 2.x

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 for the v2 runtime.

Note

This article is for Azure Functions 2.x. For a reference of host.json in Functions 1.x, see host.json reference for Azure Functions 1.x.

Other function app configuration options are managed in your app settings.

Some host.json settings are only used when running locally in the local.settings.json file.

Sample host.json file

The following sample host.json files have all possible options specified.

{
    "version": "2.0",
    "aggregator": {
        "batchSize": 1000,
        "flushTimeout": "00:00:30"
    },
    "extensions": {
        "cosmosDb": {},
        "durableTask": {},
        "eventHubs": {},
        "http": {},
        "queues": {},
        "sendGrid": {},
        "serviceBus": {}
    },
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[1.*, 2.0.0)"
    },
    "functions": [ "QueueProcessor", "GitHubWebHook" ],
    "functionTimeout": "00:05:00",
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    },
    "logging": {
        "fileLoggingMode": "debugOnly",
        "logLevel": {
          "Function.MyFunction": "Information",
          "default": "None"
        },
        "applicationInsights": {
            "samplingSettings": {
              "isEnabled": true,
              "maxTelemetryItemsPerSecond" : 20
            }
        }
    },
    "managedDependency": {
        "enabled": true
    },
    "singleton": {
      "lockPeriod": "00:00:15",
      "listenerLockPeriod": "00:01:00",
      "listenerLockRecoveryPollingInterval": "00:01:00",
      "lockAcquisitionTimeout": "00:01:00",
      "lockAcquisitionPollingInterval": "00:00:03"
    },
    "watchDirectories": [ "Shared", "Test" ]
}

The following sections of this article explain each top-level property. All are optional unless otherwise indicated.

aggregator

Specifies how many function invocations are aggregated when calculating metrics for Application Insights.

{
    "aggregator": {
        "batchSize": 1000,
        "flushTimeout": "00:00:30"
    }
}
Property Default Description
batchSize 1000 Maximum number of requests to aggregate.
flushTimeout 00:00:30 Maximum time period to aggregate.

Function invocations are aggregated when the first of the two limits are reached.

applicationInsights

This setting is a child of logging.

Controls the sampling feature in Application Insights.

{
    "applicationInsights": {
        "samplingSettings": {
          "isEnabled": true,
          "maxTelemetryItemsPerSecond" : 20
        }
    }
}

Note

Log sampling may cause some executions to not show up in the Application Insights monitor blade.

Property Default Description
isEnabled true Enables or disables sampling.
maxTelemetryItemsPerSecond 20 The threshold at which sampling begins.
EnableLiveMetrics true Enables live metrics collection.
EnableDependencyTracking true Enables dependency tracking.
EnablePerformanceCountersCollection true Enables Kudu performance counters collection.

cosmosDb

Configuration setting can be found in Cosmos DB triggers and bindings.

durableTask

Configuration setting can be found in bindings for Durable Functions.

eventHub

Configuration settings can be found in Event Hub triggers and bindings.

extensions

Property that returns an object that contains all of the binding-specific settings, such as http and eventHub.

extensionBundle

Extension bundles lets you add a compatible set of Functions binding extensions to your function app. To learn more, see Extension bundles for local development.

{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[1.*, 2.0.0)"
    }
}

The following properties are available in extensionBundle:

Property Description
id The namespace for Microsoft Azure Functions extension bundles.
version The version of the bundle to install. The Functions runtime always picks the maximum permissible version defined by the version range or interval. The version value above allows all bundle versions from 1.0.0 up to but not including 2.0.0. For more information, see the interval notation for specifying version ranges.

Bundle versions increment as packages in the bundle change. Major version changes occur when packages in the bundle increment by a major version. Major version changes in the bundle usually coincide with a change in the major version of the Functions runtime.

The current set of extensions installed by the default bundle is enumerated in this extensions.json file.

functions

A list of functions that the job host runs. An empty array means run all functions. Intended for use only when running locally. In function apps in Azure, you should instead follow the steps in How to disable functions in Azure Functions to disable specific functions rather than using this setting.

{
    "functions": [ "QueueProcessor", "GitHubWebHook" ]
}

functionTimeout

Indicates the timeout duration for all functions. It follows the timespan string format. In a serverless Consumption plan, the valid range is from 1 second to 10 minutes, and the default value is 5 minutes.

In the Premium plan the valid range is from 1 second to 60 minutes, and the default value is 30 minutes.

In a Dedicated (App Service) plan, there is no overall limit, and the default value is 30 minutes. A value of -1 indicates unbounded execution, but keeping a fixed upper bound is recommended.

{
    "functionTimeout": "00:05:00"
}

healthMonitor

Configuration settings for Host health monitor.

{
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    }
}
Property Default Description
enabled true Specifies whether the feature is enabled.
healthCheckInterval 10 seconds The time interval between the periodic background health checks.
healthCheckWindow 2 minutes A sliding time window used in conjunction with the healthCheckThreshold setting.
healthCheckThreshold 6 Maximum number of times the health check can fail before a host recycle is initiated.
counterThreshold 0.80 The threshold at which a performance counter will be considered unhealthy.

http

Configuration settings can be found in http triggers and bindings.

logging

Controls the logging behaviors of the function app, including Application Insights.

"logging": {
    "fileLoggingMode": "debugOnly"
    "logLevel": {
      "Function.MyFunction": "Information",
      "default": "None"
    },
    "console": {
        ...
    },
    "applicationInsights": {
        ...
    }
}
Property Default Description
fileLoggingMode debugOnly Defines what level of file logging is enabled. Options are never, always, debugOnly.
logLevel n/a Object that defines the log category filtering for functions in the app. Version 2.x follows the ASP.NET Core layout for log category filtering. This lets you filter logging for specific functions. For more information, see Log filtering in the ASP.NET Core documentation.
console n/a The console logging setting.
applicationInsights n/a The applicationInsights setting.

console

This setting is a child of logging. It controls the console logging when not in debugging mode.

{
    "logging": {
    ...
        "console": {
          "isEnabled": "false"
        },
    ...
    }
}
Property Default Description
isEnabled false Enables or disables console logging.

managedDependency

Managed dependency is a feature that is currently only supported with PowerShell based functions. It enables dependencies to be automatically managed by the service. When the enabled property is set to true, the requirements.psd1 file is processed. Dependencies are updated when any minor versions are released. For more information, see Managed dependency in the PowerShell article.

{
    "managedDependency": {
        "enabled": true
    }
}

queues

Configuration settings can be found in Storage queue triggers and bindings.

sendGrid

Configuration setting can be found in SendGrid triggers and bindings.

serviceBus

Configuration setting can be found in Service Bus triggers and bindings.

singleton

Configuration settings for Singleton lock behavior. For more information, see GitHub issue about singleton support.

{
    "singleton": {
      "lockPeriod": "00:00:15",
      "listenerLockPeriod": "00:01:00",
      "listenerLockRecoveryPollingInterval": "00:01:00",
      "lockAcquisitionTimeout": "00:01:00",
      "lockAcquisitionPollingInterval": "00:00:03"
    }
}
Property Default Description
lockPeriod 00:00:15 The period that function level locks are taken for. The locks auto-renew.
listenerLockPeriod 00:01:00 The period that listener locks are taken for.
listenerLockRecoveryPollingInterval 00:01:00 The time interval used for listener lock recovery if a listener lock couldn't be acquired on startup.
lockAcquisitionTimeout 00:01:00 The maximum amount of time the runtime will try to acquire a lock.
lockAcquisitionPollingInterval n/a The interval between lock acquisition attempts.

version

The version string "version": "2.0" is required for a function app that targets the v2 runtime.

watchDirectories

A set of shared code directories that should be monitored for changes. Ensures that when code in these directories is changed, the changes are picked up by your functions.

{
    "watchDirectories": [ "Shared" ]
}

Next steps