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

azurerm_linux_function_app broken if running terraform apply a second time #16396

Closed
1 task done
sebader opened this issue Apr 14, 2022 · 4 comments · Fixed by #16442
Closed
1 task done

azurerm_linux_function_app broken if running terraform apply a second time #16396

sebader opened this issue Apr 14, 2022 · 4 comments · Fixed by #16442

Comments

@sebader
Copy link
Contributor

sebader commented Apr 14, 2022

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 "+1" or "me too" comments, 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

Terraform Version

1.1.7

AzureRM Provider Version

3.1.0

Affected Resource(s)/Data Source(s)

azurerm_linux_function_app

Terraform Configuration Files

resource "azurerm_linux_function_app" "regional" {
  name                        = "${var.prefix}-loadgen-${var.location}-func"
  location                    = var.location
  resource_group_name         = var.resource_group_name
  service_plan_id             = azurerm_service_plan.regional.id
  storage_account_name        = azurerm_storage_account.regional.name
  storage_account_access_key  = azurerm_storage_account.regional.primary_access_key
  functions_extension_version = "~4"
  https_only                  = true

  identity {
    type         = "UserAssigned"
    identity_ids = [var.function_user_managed_identity_resource_id]
  }

  key_vault_reference_identity_id = var.function_user_managed_identity_resource_id

  site_config {
    application_stack {
      node_version = "14"
    }
    application_insights_connection_string = var.application_insights_connection_string
  }

  app_settings = merge(
    var.additional_app_settings,
    {
      "PLAYWRIGHT_BROWSERS_PATH"       = "0"
      "ENABLE_ORYX_BUILD"              = "true"
      "SCM_DO_BUILD_DURING_DEPLOYMENT" = "true"
      "WEBSITE_MOUNT_ENABLED"          = "1"
  })
}

Debug Output/Panic Output

n/a

Expected Behaviour

Terraform should not break the function

Actual Behaviour

After the first deployment of the Function app, plus the actual Function code, using the Function core tools are complete, it looks like this and all is good:
image

From the ARM template export:
image

Next time I run terraform apply, the plan wants to (and will) remove the RUN_FROM_PACAKGE app setting.

image

Afterwards, not only is the package setting gone, but also all the app settings regarding the runtime version. Result: Function is not working anymore.
image

image

Even after running the Function core tools deployment again (which is successful), the Function is still broken beyond repair.

The sample shows a Node Function, but I have the same behavior on a dotnet6 function

Steps to Reproduce

  1. Create a new Function app using Terraform
  2. deploy app to it using Function core tools. I'm using func azure functionapp publish my-func --build local --javascript
  3. Run terraform apply again

Important Factoids

No response

References

No response

@sebader sebader added the bug label Apr 14, 2022
@github-actions github-actions bot removed the bug label Apr 14, 2022
@sebader
Copy link
Contributor Author

sebader commented Apr 14, 2022

I just realized: If I run apply a third time, it put the runtime settings back:
image

//edit: It appears like on every other apply run Terraform removes the application_stack (without saying so in the plan!) and the next time it will add it again.

@AaldertVanWijk-TomTom
Copy link
Contributor

Hi @sebader can you share with us what the input into var.additional_app_settings is?

In general I have the experience with Java that you have to be careful not to set app_settings that conflict with or duplicate the application stack

@sebader
Copy link
Contributor Author

sebader commented Apr 14, 2022

Sure, the entire code is here, but the extra App setting is actually only just one more
Custom setting, nothing conflicting with the publish settings:

https://github.com/Azure/Mission-Critical-Online/blob/fix/load-gen-function-tf3/src/testing/userload-generator/infra/modules/regional_function/functionapp.tf

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants