host.json Reference¶
The host.json file configures the Azure Functions runtime behaviour. It lives in the root of your function app (same directory as function_app.py) and applies to all functions in the app. This reference covers the most important settings for Python function apps.
flowchart TD
A[host.json] --> B[Global runtime settings]
A --> C[logging]
A --> D[extensions]
A --> E[concurrency]
D --> F[http settings]
D --> G[queue settings]
B --> H[Function host applies config at startup]
C --> H
D --> H
E --> H Queue settings note: In this annotated sample,
"maxPollingInterval": "00:00:02"and"visibilityTimeout": "00:00:30"are custom overrides for faster dequeue and retry behavior. Azure Functions defaults aremaxPollingInterval = "00:01:00"andvisibilityTimeout = "00:00:00".
Complete Annotated Example¶
{
"version": "2.0",
"logging": {
"logLevel": {
"default": "Information",
"Host.Results": "Error",
"Function": "Information",
"Host.Aggregator": "Trace"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"maxTelemetryItemsPerSecond": 20,
"excludedTypes": "Request;Exception"
},
"enableLiveMetrics": true,
"httpAutoCollectionOptions": {
"enableHttpTriggerExtendedInfoCollection": true,
"enableW3CDistributedTracing": true,
"enableResponseHeaderInjection": true
}
}
},
"extensions": {
"http": {
"routePrefix": "api",
"maxOutstandingRequests": 200,
"maxConcurrentRequests": 100,
"dynamicThrottlesEnabled": false
},
"queues": {
"maxPollingInterval": "00:00:02",
"visibilityTimeout": "00:00:30",
"batchSize": 16,
"maxDequeueCount": 5,
"newBatchThreshold": 8
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
},
"functionTimeout": "00:05:00",
"concurrency": {
"dynamicConcurrencyEnabled": true,
"snapshotPersistenceEnabled": true
}
}
Key Settings¶
version (Required)¶
Always set to "2.0" for Azure Functions v4 runtime. This is the only supported version for the v2 Python programming model.
extensionBundle (Required for non-HTTP extensions)¶
{
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
The extension bundle provides pre-compiled binding extensions (Cosmos DB, Storage, Event Grid, etc.) without requiring you to install them individually. The version range [4.*, 5.0.0) means any 4.x version but not 5.x.
Important: Include
extensionBundlewhen your app uses trigger/binding extensions beyond HTTP. HTTP-only apps can run without an extension bundle because HTTP is in the core runtime.
functionTimeout¶
Maximum execution time for a single function invocation. The format is hh:mm:ss.
| Plan | Default | Minimum | Maximum |
|---|---|---|---|
| Consumption | 5 minutes | 1 second | 10 minutes |
| Flex Consumption | 30 minutes | 1 second | Unlimited (-1) |
| Premium | 30 minutes | 1 second | Unlimited (set functionTimeout to -1) |
| Dedicated | 30 minutes | 1 second | Unlimited |
For the Consumption plan, if a function exceeds the timeout, the host terminates the process. Flex Consumption defaults to 30 minutes and supports unbounded execution (-1); if a bounded timeout is set, the host terminates the process when it is exceeded.
Tip: Set the timeout to the maximum your plan allows, then handle timeouts gracefully in your code. For long-running operations, consider Durable Functions instead.
logging¶
Control log verbosity and Application Insights behaviour:
{
"logging": {
"logLevel": {
"default": "Information",
"Host.Results": "Error",
"Function": "Information",
"Function.my_func": "Debug"
}
}
}
| Category | Controls | Recommended Level |
|---|---|---|
default | All log sources not explicitly configured | Information |
Host.Results | Function execution results (success/failure) | Error (reduces noise) |
Function | All function-level logs | Information |
Function.<function_name> | Logs for a specific function | Debug (only when troubleshooting) |
Host.Aggregator | Aggregated metrics | Trace or Information |
logging.applicationInsights.samplingSettings¶
Control how much telemetry is sent to Application Insights:
{
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"maxTelemetryItemsPerSecond": 20,
"excludedTypes": "Request;Exception"
}
}
}
}
| Setting | Default | Description |
|---|---|---|
isEnabled | true | Enable adaptive sampling |
maxTelemetryItemsPerSecond | 20 | Target telemetry rate per second per instance |
excludedTypes | "" | Telemetry types to never sample. Options: Dependency, Event, Exception, PageView, Request, Trace |
Cost Tip: Set
excludedTypesto"Request;Exception"to ensure you never lose error data, while allowing traces and dependencies to be sampled. See Cost Optimization.
extensions.http¶
Configure HTTP trigger behaviour:
{
"extensions": {
"http": {
"routePrefix": "api",
"maxOutstandingRequests": 200,
"maxConcurrentRequests": 100,
"dynamicThrottlesEnabled": false
}
}
}
| Setting | Default | Description |
|---|---|---|
routePrefix | "api" | URL prefix for all HTTP functions. Set to "" to remove the /api prefix |
maxOutstandingRequests | Consumption: 200; Premium/Dedicated: -1 (unbounded) | Max pending requests at any given time |
maxConcurrentRequests | Consumption: 100; Premium/Dedicated: -1 (unbounded) | Max HTTP functions executing in parallel per instance |
dynamicThrottlesEnabled | Consumption: true | Check system performance counters and reject requests when thresholds are exceeded |
To remove the /api prefix (so routes are https://your-func.azurewebsites.net/health instead of https://your-func.azurewebsites.net/api/health):
extensions.queues¶
Configure Queue trigger behaviour (see Queue recipe):
Important: The next snippet intentionally shows custom override values. Runtime defaults are
"maxPollingInterval": "00:01:00"and"visibilityTimeout": "00:00:00".
{
"extensions": {
"queues": {
"maxPollingInterval": "00:00:02",
"visibilityTimeout": "00:00:30",
"batchSize": 16,
"maxDequeueCount": 5,
"newBatchThreshold": 8
}
}
}
concurrency¶
Enable dynamic concurrency for supported triggers:
When enabled, the runtime automatically adjusts concurrency for supported triggers (Blob, Queue, and Service Bus). snapshotPersistenceEnabled persists learned concurrency settings across restarts.
Minimal host.json¶
The minimum viable host.json for an HTTP-only Python function app:
Local vs. Production Differences¶
The host.json file is deployed with your code and applies in both local and production environments. For settings that should differ between environments, use app settings (environment variables) and reference them in your code rather than putting environment-specific values in host.json.