host.json (v2)

Jeff Hollan edited this page Aug 31, 2018 · 8 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.

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": {
        "sendGrid": {
            "from": "Azure Functions <samples@functions.com>"
        },
        "http": {
            "routePrefix": "api",
            "maxConcurrentRequests": 5,
            "maxOutstandingRequests": 30
        },
        "queues": {
            "visibilityTimeout": "00:00:10",
            "maxDequeueCount": 3
        },
        "eventHubs": {
            "maxBatchSize": 256,
            "prefetchCount": 512
        },
        "serviceBus": {
            "prefetchCount": 100,
            "messageHandlerOptions": {
                "maxConcurrentCalls": 32
            }
        }
    }
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.