Home > Enterprise >  Set functionTimeout using terraform
Set functionTimeout using terraform

Time:04-21

I need to add below property to my host.json file for azure function. Is it possible to add the property using terraform or by passing it using app_setting?

{
    "functionTimeout": "00:10:00"
}

CodePudding user response:

You can use the azurerm_app_configuration to add the configuration values in an Azure App Service. And azurerm_app_configuration_key is used to add the key-value pair in an Azure App Service using terraform.

You can use the below key-value pair for adding the timeout values in Azure

key : AzureFunctionsJobHost__functionTimeout 
Value : 00:10:00

Example

Note: App Configuration Keys are provisioned using a Data Plane API which requires the role App Configuration Data Owner on either the App Configuration or a parent scope (such as the Resource Group/Subscription).

resource "azurerm_resource_group" "rg" {
  name     = "example-resources"
  location = "example-location"
}

resource "azurerm_app_configuration" "appconf" {
  name                = "appConf1"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
}

## Adding the App Configuration Data Owner role
data "azurerm_client_config" "current" {}

resource "azurerm_role_assignment" "appconf_dataowner" {
  scope                = azurerm_app_configuration.appconf.id
  role_definition_name = "App Configuration Data Owner"
  principal_id         = data.azurerm_client_config.current.object_id
}


## Adding the App Settings config values
resource "azurerm_app_configuration_key" "test" {
  configuration_store_id = azurerm_app_configuration.appconf.id
  key                    = "<Your host.json timeout key "AzureFunctionsJobHost__functionTimeout">"
  label                  = "somelabel"
  value                  = "<Your timeout value "00:10:00">"

  depends_on = [
    azurerm_role_assignment.appconf_dataowner
  ]
}

Refer blog for adding multiple key-value pair.

  • Related