Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when deploying a Flex Consumption Function App #26672

Open
1 task done
oWretch opened this issue Jul 17, 2024 · 10 comments
Open
1 task done

Error when deploying a Flex Consumption Function App #26672

oWretch opened this issue Jul 17, 2024 · 10 comments

Comments

@oWretch
Copy link
Contributor

oWretch commented Jul 17, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.9.1

AzureRM Provider Version

3.112.0

Affected Resource(s)/Data Source(s)

azurerm_linux_function_app

Terraform Configuration Files

resource "azurerm_linux_function_app" "this" {
  name                = "test-function-app-234asf"
  resource_group_name = azurerm_resource_group.test.name
  location            = azurerm_resource_group.test.location
  service_plan_id     = azurerm_service_plan.test.id

  storage_account_name       = azurerm_storage_account.test.name
  storage_account_access_key = azurerm_storage_account.test.primary_access_key

  site_config {
    application_stack {
      python_version = "3.11"
    }
  }
}

resource "azurerm_service_plan" "test" {
  name                = "test-service-plan"
  location            = azurerm_resource_group.test.location
  resource_group_name = azurerm_resource_group.test.name

  sku_name = "FC1"
  os_type  = "Linux"
}

resource "azurerm_storage_account" "test" {
  name                     = "testsa234asf"
  resource_group_name      = azurerm_resource_group.test.name
  location                 = azurerm_resource_group.test.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_resource_group" "test" {
  name     = "terraform-test-rg"
  location = "East US"
}

Debug Output/Panic Output

Error: creating Linux App Service (Subscription: "00000000-0000-0000-0000-000000000000"
│ Resource Group Name: "terraform-test-rg"
│ Site Name: "test-function-app-234asf"): performing CreateOrUpdate: unexpected status 400 (400 Bad Request) with response: {"Code":"BadRequest","Message":"Site.FunctionAppConfig is invalid.  The FunctionAppConfig section was not specified in the request, which is required for Flex Consumption sites. To proceed, please add the FunctionAppConfig section in your request.","Target":null,"Details":[{"Message":"Site.FunctionAppConfig is invalid.  The FunctionAppConfig section was not specified in the request, which is required for Flex Consumption sites. To proceed, please add the FunctionAppConfig section in your request."},{"Code":"BadRequest"},{"ErrorEntity":{"ExtendedCode":"51021","MessageTemplate":"{0} is invalid.  {1}","Parameters":["Site.FunctionAppConfig","The FunctionAppConfig section was not specified in the request, which is required for Flex Consumption sites. To proceed, please add the FunctionAppConfig section in your request."],"Code":"BadRequest","Message":"Site.FunctionAppConfig is invalid.  The FunctionAppConfig section was not specified in the request, which is required for Flex Consumption sites. To proceed, please add the FunctionAppConfig section in your request."}}],"Innererror":null}
│ 
│   with azurerm_linux_function_app.this,
│   on azurerm.tf line 1, in resource "azurerm_linux_function_app" "this":
│    1: resource "azurerm_linux_function_app" "this" {

After adding support for the FC1 SKU to the azurerm_service_plan in #26351 as part of #26043 I attempted to also create a flex consumption function app. This failed with the above error.

Resolution of this is dependant upon hashicorp/go-azure-sdk#1017 ,which may be dependant upon an upstream fix - I haven't investigated that far.

I'm mostly raising this issue as a placeholder for a known issue.

As an aside, it seems that Microsoft are making some significant changes to the way the Function App is provisioned - many of the old settings are deprecated and replaced with new settings inside the functionAppConfig structure. Reference: https://learn.microsoft.com/en-us/azure/azure-functions/flex-consumption-plan.

Also, from further testing, the functionAppConfig structure is only supported on the flex consumption function apps.

@oWretch oWretch changed the title Cannot Deploy a Flex Consumption Function App Error when deploying a Flex Consumption Function App Jul 17, 2024
@xiaxyi
Copy link
Contributor

xiaxyi commented Jul 19, 2024

Thanks @oWretch for raising this issue, just curious about whether you are able to create the function app via Azure portal? Seems I'm having issue creating the flex consumption function app via any methods.

@oWretch
Copy link
Contributor Author

oWretch commented Jul 21, 2024

Hi @xiaxyi. Yes, I have been able to create Flex Consumption Function Apps both via the portal and code. I've written a blog post on how to do it with the AzAPI provider: https://solideogloria.tech/azure/deploy-a-flex-consumption-function-app-with-terraform/

@JameySteinmann
Copy link

Also worth noting that this sample code from the Azure-Samples works with the AzAPI provider as well. I have tested this code and confirm it works.
https://github.com/Azure-Samples/azure-functions-flex-consumption-samples/blob/main/IaC/terraform/main.tf

Now we just need the AzureRM provider to be current with this feature.

@rcomar-cit
Copy link

Hi guys! I also need to deploy a function app in consumption plan, are there plans for these adjustments to be included in AzureRM provider in a near future ?

@tonysanchez64
Copy link

tonysanchez64 commented Sep 11, 2024

Hello, The problem still occurirng. From what I understand that the feature it isn't implemented yet. Will it be included in the provider soon? Thanks you very much!

@LeastOne
Copy link

Just encountered this attempting to apply a [email protected] and [email protected] configuration. Any chance someone could indicate where this lands on the roadmap?

@binpanoutlook
Copy link

I encounter the same issue, if there is a solution without using azapi to create the Flex Consumption Function app?

@jonny-ibdr
Copy link

This issue persists to azurerm provider version 4.3.0. We really need this fixed :/

@TravisHunting
Copy link

Running into this issue as well

@dvasdekis
Copy link

Probably best to wait for #27531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants