Skip to content

host.json (v2)

Jeff Hollan edited this page Apr 29, 2020 · 12 revisions

The schema for host.json has changed enough in Azure Functions v2+ that the functions host will throw an exception if the file is missing the "version": "2.0" property. Please note that this requires the value as a string and "version":2.0 will not work. "version": "2.0" is still the valid schema for Azure Functions v3.

This page provides a migration guide for the sections that have changed. For full definitions of those sections, see https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json. The official documentation will be updated with the v2 schema soon.

All application-level extension settings now live under "extensions"

This means that the following settings that were in the root of the json object in v1, now live under extensions in v2:

{
  "extensions": {
    "cosmosDB": { },
    "eventHubs": { },
    "http": { },
    "queues": { },
    "sendGrid": { },
    "serviceBus": { },
    "durableTask": { }
  }
}

All logging settings now live under "logging"

This means that the "tracing" and "logger" have been removed.

{
  "logging": {
    "fileLoggingMode": { },
    "applicationInsights": { }
  }
}

Log category filtering follows .NET Core layout

Filtering now follows the same pattern as documented by the JSON settings here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1#log-filtering.

For example, the following will disable all logging except the logs coming from the function named 'MyFunction'

{
  "logging": {
    "logLevel": {
      "Function.MyFunction": "Information",
      "default": "None"
    }
  }
}

Sample host.json

{
    "version": "2.0",
    "watchDirectories": [ "Shared", "Test" ],
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    },
    "functionTimeout": "00:05:00",
    "logging": {
        "fileLoggingMode": "debugOnly"
    },
    "extensions": {
        "cosmosDB": {
            "connectionMode": "Gateway",
            "protocol": "Https",
            "leaseOptions": {
                "leasePrefix": "prefix1"
            }
        },
        "sendGrid": {
            "from": "Azure Functions <[email protected]>"
        },
        "http": {
            "routePrefix": "api",
            "maxConcurrentRequests": 5,
            "maxOutstandingRequests": 30
        },
        "queues": {
            "visibilityTimeout": "00:00:10",
            "maxPollingInterval": "00:00:15",
            "maxDequeueCount": 3
        },
        "eventHubs": {
            "batchCheckpointFrequency": 5,
            "eventProcessorOptions": {
                "maxBatchSize": 256,
                "prefetchCount": 512
            }
        },
        "serviceBus": {
            "prefetchCount": 100,
            "messageHandlerOptions": {
                "maxConcurrentCalls": 32,
                "maxAutoRenewDuration": "00:55:00"
            }
        }
    }
}

Learn

Azure Functions Basics

Advanced Concepts

Dotnet Functions

Java Functions

Node.js Functions

Python Functions

Host API's

Bindings

V2 Runtime

Contribute

Functions host

Language workers

Get Help

Other

Clone this wiki locally