使用 terraform 设置函数超时

Set functionTimeout using terraform

我需要将下面的 属性 添加到我的 host.json 文件中以获得 azure 功能。是否可以使用 terraform 添加 属性 或使用 app_setting 传递它?

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

您可以使用 azurerm_app_configuration to add the configuration values in an Azure App Service. And azurerm_app_configuration_key 用于使用 terraform 在 Azure 应用服务中添加 key-value 对。

您可以使用下面的 key-value 对在 Azure

中添加 超时值
key : AzureFunctionsJobHost__functionTimeout 
Value : 00:10:00

示例

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
  ]
}

参考 blog 添加多个 key-value 对。