hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

Support for Java 21 for azurerm_linux_web_app #25490

Open christian-anker-larsen opened 8 months ago

christian-anker-larsen commented 8 months ago

Is there an existing issue for this?

Community Note

Description

As evidenced from the screenshot below taken in Azure Portal on 2nd April 2024, Azure Web Apps now support Java 21. For this reason, it would be great if Java 21 is supported in the azurerm_linux_web_app resource as well. Would it be possible to implement this any time in the foreseeable future? 🙏🏻

image

Thank you.

New or Affected Resource(s)/Data Source(s)

azurerm_linux_web_app

Potential Terraform Configuration

application_stack {
      java_version = 21
    }

References

No response

christian-anker-larsen commented 8 months ago

I did some further investigation in Azure Portal, and it seems that even though Java 21 is selectable in my web app's configuration, I am unable to save the changes. I then attempted to create a new Linux-based resource manually via Azure Portal with Java 21. As per the screenshot below, selecting this version disables the Linux option in the Operating System field. This seems to indicate that Java 21 is not yet supported on Linux based Web Apps.

In other words, this issue is not an actual issue (yet), so I am closing it for now.

image

ppa-fyayc commented 7 months ago

The announcement is here: https://techcommunity.microsoft.com/t5/apps-on-azure-blog/announcing-java-21-and-tomcat-10-1-on-azure-app-service/ba-p/4105714

ppa-fyayc commented 7 months ago

@christian-anker-larsen are you going to reopen this issue?

christian-anker-larsen commented 7 months ago

@ppa-fyayc I made another attempt in Azure Portal to create a Web App in Linux OS, but I am still seeing this, when selecting Java 21:

image

To me, it looks like that the announcement implicitly only applies for Windows OS. Not sure if it makes sense to reopen this issue until Linux is supported as well.

ppa-fyayc commented 7 months ago

Oh, I see what you mean :( That's a shame! Let's wait then.

ppa-fyayc commented 7 months ago

I was able to upgrade my linux web app to Java 21 using

resource "azapi_update_resource" "backend-webapp-java-21" {
  type        = "Microsoft.Web/sites@2023-01-01"
  resource_id = azurerm_linux_web_app.backend.id
  body        = jsonencode({
    properties = {
      siteConfig = {
        linuxFxVersion = "JAVA|21-java21"
      }
    }
  })
}
iAMSagar44 commented 7 months ago

@christian-anker-larsen - I had encountered the same issue, but I can now see that Java 21 is supported for Azure App Service on Linux.

image

@ppa-fyayc - I am unable to upgrade to Java 21 with the below terraform script -

site_config {
    application_stack {
      java_server         = "JAVA"
      java_version        = "21"
      java_server_version = "21"
    }
  }

It fails Terraform validation.

@christian-anker-larsen - I think this issue should be reopened. Thoughts?

ppa-fyayc commented 7 months ago

@iAMSagar44 Right, the site_config you posted does not work yet. That's why I posted the workaround via the azapi provider.

christian-anker-larsen commented 7 months ago

@iAMSagar44 I just checked Azure Portal, and it's now possible to create Web Apps on Linux w/ Java 21. Also tried modifying an existing web app, and there it was also possible to change to Java 21, so, yes, I am reopening this issue.

onclebendusud commented 7 months ago

Good morning, is there a plan(ning) for adding java21 in azurerm_linux_web_app ? It's just to have an expected date for the availability.

ghost commented 5 months ago

Just to build on the work-around provided by @ppa-fyayc: You might want to add the replace_triggered_by lifecycle to azapi_update_resource. I'm experiencing that if any fields in the azurerm_linux_web_app is later changed by Terraform, for instance, site_config, then the application stack is set to JAVA|21- and not JAVA|21-java21. JAVA|21- is an invalid value, and will most likely cause your app to stop working. Here's a complete example for reference:

resource "azapi_update_resource" "backend-webapp-java-21" {
  type        = "Microsoft.Web/sites@2023-01-01"
  resource_id = azurerm_linux_web_app.backend.id
  body        = jsonencode({
    properties = {
      siteConfig = {
        linuxFxVersion = "JAVA|21-java21"
      }
    }
  })
  lifecycle {
    replace_triggered_by = [
      azurerm_linux_web_app.backend
    ]
  }
}

This will force azapi_update_resource to be recreated, setting the application stack back to JAVA|21-java21.

sudeepvarma2017 commented 4 months ago

Is there any ETA for this issue ?

MarcelTemp commented 1 month ago

What is the status here?

computerlove commented 1 month ago

The status is that I have a PR that has a failing test, that I have no idea how to resolve.