DEV Community

Cover image for Azure Functions Tips: override the host.json settings!!
Massimo Bonanni
Massimo Bonanni

Posted on

15

Azure Functions Tips: override the host.json settings!!

The host.json file in Azure Functions is a configuration file that provides runtime-specific settings for your function app.
This file is located at the root of a function app project.
Some of the settings that can be configured in the host.json file include the version of the Azure Functions runtime, logging settings, function timeout duration, and settings for bindings and triggers.
The settings in the host.json file apply to all functions within a function app.

Every time you need to change some settings inside it, you need to redeploy the entire Functions App (I know that you can access to the files in the deploy directly from the portal, but it isn't a good idea!!). Fortunately, you can override the values you have in the host.json thought the appsettigs.json file (or using the configuration blade in the portal).

In particular, you can set the configuration value similar to the following:

AzureFunctionsJobHost__<HOST-CONFIG-VALUE> = value
Enter fullscreen mode Exit fullscreen mode

where <HOST-CONFIG-VALUE> is the host.json value you want to override.
For example, suppose you have the following host.json:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "functionTimeout": "00:05:00",
  ....
}
Enter fullscreen mode Exit fullscreen mode

In that file, you set the timeout for your functions to 5 minutes. If you want to override that value to have 3 minutes of timeout, you can add the following setting in the appsetting.json file:

{
  "IsEncrypted": false,
  "Values": {
    ...
    "AzureFunctionsJobHost__functionTimeout": "00:03:00",
    ...
  }
}
Enter fullscreen mode Exit fullscreen mode

In that case <HOST-CONFIG-VALUE> is functionTimeout.
If the value you want to override is a property of a section in the host.json config, you need to use the __ string to describe the hierarchy.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay