First you need to deploy a Linux-based App Service Plan into Azure. This can be done as follows:
# Create Azure App Service Plan using Consumption pricing
resource azurerm_app_service_plan "primary" {
name = local.app_service_plan_name
location = azurerm_resource_group.primary.location
resource_group_name = azurerm_resource_group.primary.name
kind = "Linux"
reserved = true
sku {
tier = "Dynamic"
size = "Y1"
}
}
Once the Linux-based App Service Plan is deployed, you can then deploy a Linux-based Azure Function App as follows that is hosted using the Linux-based App Service Plan:
# Create an Azure Function App on Linux
resource azurerm_function_app "primary" {
name = local.function_app_name
resource_group_name = azurerm_resource_group.primary.name
location = azurerm_resource_group.primary.location
app_service_plan_id = azurerm_app_service_plan.primary.id
storage_account_name = azurerm_storage_account.primary.name
storage_account_access_key = azurerm_storage_account.primary.primary_access_key
os_type = "linux"
version = "~3"
site_config {
always_on = true
}
}
For more explanation and expanded Terraform snippets for deploying an Azure Function App on Linux, please reference this link: https://build5nines.com/terraform-deploy-azure-function-app-with-consumption-plan/