Function App Problems

I was trying to get a Function deployed to Azure and I found the following sample code in the documentation and I had modified it to match up with the names I was planning on using for my test deployment and it failed to run as it was presented in the documentation. As I received a message about an unsupported argument around the storage_account_name not being expected in the resource block.

I recently took the entire sample and tried to run it as is for a test and there the following errors popped up in the planning phase of the testing.

These were the errors:
Error: Missing required argument

      on functionsample.tf line 30, in resource "azurerm_function_app" "example":
      30: resource "azurerm_function_app" "example" {

    The argument "storage_connection_string" is required, but no definition was
    found.

    Error: Unsupported argument

      on functionsample.tf line 35, in resource "azurerm_function_app" "example":
      35:   storage_account_name       = azurerm_storage_account.example.name

    An argument named "storage_account_name" is not expected here.

    Error: Unsupported argument

      on functionsample.tf line 36, in resource "azurerm_function_app" "example":
      36:   storage_account_access_key = azurerm_storage_account.example.primary_access_key

    An argument named "storage_account_access_key" is not expected here.

This was the sample I was trying to get working in creating a function app in a consumption plan

resource "azurerm_resource_group" "example" {

name = “azure-functions-cptest-rg”
location = “westus2”
}

resource “azurerm_storage_account” “example” {
name = “functionsapptestsa”
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = “Standard”
account_replication_type = “LRS”
}

resource “azurerm_app_service_plan” “example” {
name = “azure-functions-test-service-plan”
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
kind = “FunctionApp”

sku {
tier = “Dynamic”
size = “Y1”
}
}

resource “azurerm_function_app” “example” {
name = “test-azure-functions”
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
storage_account_name = azurerm_storage_account.example.name
storage_account_access_key = azurerm_storage_account.example.primary_access_key
}

I have searched high and low and have yet to find any answers in regards to creating a function app successfully in Azure.

Just wanted to say that this is the only entry I found on Google relating to this problem, and I’m having the same one.

My best guess is that you are using an old version of the azurerm provider somehow… how are you defining the azurerm provider version?

terraform {
  required_version = "0.14.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=2.38.0"
    }
  }
}

As a quick test, what do you get as output to terraform version?

terraform version
Terraform v0.14.0
+ provider registry.terraform.io/hashicorp/azurerm v2.38.0

Your version of Terraform is out of date! The latest version
is 0.14.2. You can update by downloading from https://www.terraform.io/downloads.html

Hi!

I just got the answer on Stack Overflow as well.

The problem was indeed an old version of the Azure provider. I was using v2.2.0. I was reading documentation for version 2.40.0 which contains changes from 2.2.0. It now works.

Thank you!

1 Like

Sorry for the late response, with the holidays and being diverted to another project I somehow missed your response.

I did have an outdated version of Terraform and this was found discovered by running the test you had listed, now that I am coming back to this project after the holidays and I retested the template with the new version but got other errors due to some other depreciated functions within it I will need to update in order to fully test.

I updated my providers declaration block to what you had listed and got it updated to the version of terraform I just downloaded but its giving me the following error:

Error: “features”: required field is not set

You need to specify a features block even if it is empty

provider "azurerm" {
  features {}
}
1 Like

That worked, I only had one other depreciated thing that I was able to correct in regards to the connection string for the storage account tied to a function. I am off and running again just need to finish off the QNA settings like what the developers had manually created in development which is what I am trying to recreate via templates.