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

Update of Azure Web App using runtime NodeJS can unset the NodeJS version leading to crash #25452

Closed
1 task done
Apokalypt opened this issue Mar 28, 2024 · 2 comments · Fixed by #25488
Closed
1 task done

Comments

@Apokalypt
Copy link
Contributor

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 and review the contribution guide to help.

Terraform Version

1.7.5

AzureRM Provider Version

3.86.0 (verified on 3.87.1)

Affected Resource(s)/Data Source(s)

azurerm_windows_web_app

Terraform Configuration Files

terraform {
  required_version = ">= 0.13"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2"
    }
    random = {
      source  = "hashicorp/random"
      version = "~> 3"
    }
  }
}

provider "azurerm" {
  features {}
}

provider "random" {}

resource "random_string" "unique" {
  length  = 4
  lower   = true
  number  = true
  upper   = false
  special = false
}

resource "azurerm_resource_group" "windows" {
  name     = "rg-windows-${random_string.unique.result}"
  location = "centralus"
}

resource "azurerm_app_service_plan" "windows" {
  name                = "plan-windows-${random_string.unique.result}"
  location            = azurerm_resource_group.windows.location
  resource_group_name = azurerm_resource_group.windows.name
  kind                = "Windows"
  reserved            = false # Must be false (the default value) for Windows plans

  sku {
    tier     = "Free"
    size     = "F1"
    capacity = 0
  }
}

resource "azurerm_app_service" "windows" {
  name                = "app-windows-${random_string.unique.result}"
  location            = azurerm_resource_group.windows.location
  resource_group_name = azurerm_resource_group.windows.name
  app_service_plan_id = azurerm_app_service_plan.windows.id

  site_config {
    use_32_bit_worker = true

    application_stack {
      current_stack = "node"
      node_version  = "~18"
    }
  }

  app_settings = {
    "RANDOM_KEY": "random-value"
  }
}

Debug Output/Panic Output

N/A
(I'm not the manager of the terraform file and can't get these informations)

Expected Behaviour

When we need to update the IP restriction, only the IP restriction should be updated and not the App Settings. At the same time, if we need to update the App Settings the node version should not be lost in the process

Actual Behaviour

If the environment variable for NodeJS version is set and we start to update our ip restriction of the windows web app, it's lost in the update without notification leading to Azure using the NodeJS version 0.16.1 (all of our applications instantly crash).
However, if the environment variable for NodeJS version isn't set, Terraform correctly add it

--> Right now, we need to make 2 deployment if we have to change something in App Settings or Site Configuration leading to unacceptable downtime

Steps to Reproduce

  1. terraform plan
  2. terraform apply

(I'm not the manager of the terraform file and can't get all the commands in details, so you have only the idea indicated)

Important Factoids

N/A

References

Seems related/similar to #16681

@Apokalypt
Copy link
Contributor Author

I took some time to identify the problem in order to provide a fix. Here is what I understood

Problem Analysis

The main problem comes from the deletion of the NodeJS version environment variable (WEBSITE_NODE_DEFAULT_VERSION) while reading the data (code). From my understanding, this is done to avoid detection of changes in AppSettings during an update since this environment variable should not be set manually and should be automatically handled using application_stack.

And the real problem happen when we are updating the AppSettings information (code). In fact, if we are making a change in AppSettings, "health_check_eviction_time_in_min" or any site configuration (e.g. ip restriction) we enter in this condition and upload AppSetings without setting the appropriate environment variable for the node version
FYI, the NodeJS version environment variable is only set if a change is detected in node_version. For this reason, the problem is solved using a second deployment...

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 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.