Skip to content

host.json

Mathew Charles edited this page Oct 8, 2018 · 46 revisions

Note: This page is no longer being updated, as it has been replaced by the host.json page on docs.microsoft.com.

In the root script directory, there should be a host.json metadata file that contains the global configuration options affecting all functions. The Script runtime will map these settings into their corresponding WebHobs SDK JobHostConfiguration settings when initializing the host.

If you're running on Azure Functions, one of the easiest ways to edit your host.json is through App Service Editor. Simply navigate to https://<yourfunctionappname>.scm.azurewebsites.net/dev/wwwroot/host.json in your web browser.

In addition to the below configuration settings, some things are configurable via App Settings / Environment variables. See here for a list of those.

Important: even though the sample below has comments to explain the settings, comments are not valid in JSON, and you should exclude them in your actual host.json.

{
    // The unique ID for this job host. Can be a lower case GUID
    // with dashes removed. When running in Azure Functions, an explicit id
    // should generally NOT be set, in which case one gets generated automatically.
    "id": "9f4ea53c5136457d883d685e57164f08",
    // Value indicating the timeout duration for all functions.
    // In Dynamic SKUs, the valid range is from 1 second to 10 minutes and the default value is 5 minutes.
    // In Paid SKUs there is no limit and the default is no timeout.
    "functionTimeout": "00:05:00",
    // Configuration settings for 'http' triggers. (Optional)
    "http": {
        // Defines the default route prefix that applies to all routes. Default is 'api'.
        // Use an empty string to remove the prefix.
        "routePrefix": "api",
        // the maximum number of outstanding requests that will be held at any given time. The default is unbounded (-1).
        "maxOutstandingRequests": 20,
        // the maximum number of http functions that will be executed in parallel. The default is unbounded (-1).
        "maxConcurrentRequests": 
        // The default is false.
        "dynamicThrottlesEnabled": false
    },
    // Set of shared code directories that should be monitored for changes to ensure that
    // when code in these directories is changed, it is picked up by your functions
    "watchDirectories": [ "Shared" ],
    // Array of functions to load. Only functions in this list will be enabled.
    // If not specified, all functions are enabled.
    "functions": [ "QueueProcessor", "GitHubWebHook" ]
    // Configuration settings for 'queue' triggers. (Optional)
    "queues": {
      // The maximum interval in milliseconds between
      // queue polls. The default is 1 minute.
      "maxPollingInterval": 2000,
      // The visibility timeout that will be applied to messages that fail processing
      // (i.e. the time interval between retries). The default is zero.
      "visibilityTimeout" : "00:00:30",
      // The number of queue messages to retrieve and process in
      // parallel (per job function). The default is 16 and the maximum is 32.
      "batchSize": 16,
      // The number of times to try processing a message before
      // moving it to the poison queue. The default is 5.
      "maxDequeueCount": 5,
      // The threshold at which a new batch of messages will be fetched.
      // The default is batchSize/2. Increasing this value will increase the
      // level of concurrency and therefore throughput. New batches of messages
      // will be pulled until the number of messages being processed is greater
      // than this threshold. When the number dips below this threshold, new
      // batches will be fetched.
      "newBatchThreshold": 8
    },
    // Configuration settings for 'serviceBus' triggers. (Optional)
    "serviceBus": {
      // The maximum number of concurrent calls to the callback the message
      // pump should initiate. The default is 16.
      "maxConcurrentCalls": 16,
      // The default PrefetchCount that will be used by the underlying MessageReceiver.
      "prefetchCount": 100,
      // the maximum duration within which the message lock will be renewed automatically.
      "autoRenewTimeout": "00:05:00",
      // whether messages should be completed automatically after the function finishes (true), or whether
      // the function will handle this (false). The default is true.
      "autoComplete": true
    },
    // Configuration settings for 'eventHub' triggers. (Optional)
    "eventHub": {
      // The maximum event count received per receive loop. The default is 64.
      "maxBatchSize": 64,
      // The default PrefetchCount that will be used by the underlying EventProcessorHost.
      "prefetchCount": 256,
      // The number of event batches to process before creating an EventHub cursor checkpoint.
      "batchCheckpointFrequency": 1
    },
    // Configuration settings for logging/tracing behavior. (Optional)
    "tracing": {
      // The tracing level used for console logging.
      // The default is 'info'. Options are: { off, error, warning, info, verbose }
      "consoleLevel": "verbose",
      // Value determining what level of file logging is enabled.
      // The default is 'debugOnly'. Options are: { never, always, debugOnly }
      "fileLoggingMode": "debugOnly"
    },
    // Configuration settings for Singleton lock behavior. (Optional)
    "singleton": {
      // The period that function level locks are taken for (they will auto renew)
      "lockPeriod": "00:00:15",
      // The period that listener locks are taken for
      "listenerLockPeriod": "00:01:00",
      // The time interval used for listener lock recovery if a listener lock
      // couldn't be acquired on startup
      "listenerLockRecoveryPollingInterval": "00:01:00",
      // The maximum amount of time the runtime will try to acquire a lock
      "lockAcquisitionTimeout": "00:01:00",
      // The interval between lock acquisition attempts
      "lockAcquisitionPollingInterval": "00:00:03"
    },
    "logger": {
        // Filtering for logs written by an ILogger object.
        "categoryFilter": {
            "defaultLevel": "Information",
            // Log level to filter all categories not specified under categoryLevels.
            "categoryLevels": {
            // Log level to filter for specific categories.
                "Host": "Error",
                // Example: Filter categories that begin with "Host" at Error level, except Host.Aggregator.
                "Function": "Error",
                // Example: Filter categories that begin with "Function" at Error level.
                "Host.Aggregator": "Information"
                // Example: Overrides the above "Host" item because the category is longer.
            }
        }
    },
    "aggregator": {
        // How many function invocations are aggregated when calculating metrics for Application Insights. 
        "batchSize": 1000,
        "flushTimeout": "00:00:30"
    },
    "applicationInsights": {
        "sampling": {
          // Controls sampling feature in Application Insights
          "isEnabled": true,
          "maxTelemetryItemsPerSecond" : 5
        }
    },
    // See https://github.com/Azure/azure-webjobs-sdk-script/wiki/Host-Health-Monitor
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    }
}

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