Deploying v2 Azure Functions with Terraform

 

You would not think this would be super difficult or, at the least Terraform’s documentation would cover such a common use case. But, I found it to be false, so I figured I would share the necessary changes needed.

First, some background – I am using a Terraform script to deploy a variety of Azure resources to support an internal bootcamp I will be giving at West Monroe in August.

Here is the completed Terraform block to deploy the V2 Azure Function:

resource "azurerm_function_app" "main" {
name = "${var.resource-prefix}-analyticsapp"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
app_service_plan_id = "${azurerm_app_service_plan.main.id}"
storage_connection_string = "${azurerm_storage_account.main.primary_connection_string}"
version = "~2"
app_settings {
FUNCTIONS_EXTENSION_VERSION = "~2"
FUNCTIONS_WORKER_RUNTIME = "dotnet"
}
site_config {
always_on = true
linux_fx_version = "DOCKER|mcr.microsoft.com/azure-functions/dotnet:2.0-appservice"
use_32_bit_worker_process = true
}
}

view raw
main.tf
hosted with ❤ by GitHub

This isnt something that is covered in the documentation that, in addition to specifying version we also need to include the linux_fx_version​in site_config.

I do not know if this is necessary if you use a Windows based App Service Plan (I am using Linux and sharing it with my App Service).

I found immense frustration in figuring this out and found myself annoyed that I could not find anything by V1 examples in the Terraform docs.

One thought on “Deploying v2 Azure Functions with Terraform

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s