diff --git a/internal/services/appservice/helpers/fx_strings.go b/internal/services/appservice/helpers/fx_strings.go index dbb9498ab532..02468f12e540 100644 --- a/internal/services/appservice/helpers/fx_strings.go +++ b/internal/services/appservice/helpers/fx_strings.go @@ -63,6 +63,9 @@ func decodeApplicationStackLinux(fxString string) ApplicationStackLinux { if strings.HasPrefix(javaParts[0], "17") { result.JavaVersion = "17" } + if strings.HasPrefix(javaParts[0], "21") { + result.JavaVersion = "21" + } result.JavaServerVersion = javaParts[0] case FxStringPrefixTomcat: @@ -278,6 +281,22 @@ func JavaLinuxFxStringBuilder(javaMajorVersion, javaServer, javaServerVersion st default: return pointer.To(fmt.Sprintf("%s|%s-java17", javaServer, javaServerVersion)), nil } + case "21": + switch javaServer { + case LinuxJavaServerJava: + if len(strings.Split(javaServerVersion, ".")) == 3 { + return pointer.To(fmt.Sprintf("%s|%s", LinuxJavaServerJava, javaServerVersion)), nil // "JAVA|21.0.4" + } else { + return pointer.To(fmt.Sprintf("%s|%s-java21", LinuxJavaServerJava, javaServerVersion)), nil // "JAVA|21-21" + } + + case LinuxJavaServerTomcat: + return pointer.To(fmt.Sprintf("%s|%s-java21", LinuxJavaServerTomcat, javaServerVersion)), nil // e,g, TOMCAT|10.0-java21 / TOMCAT|10.0.20-java21 + case LinuxJavaServerJboss: + return nil, fmt.Errorf("java 21 is not supported on %s", LinuxJavaServerJboss) + default: + return pointer.To(fmt.Sprintf("%s|%s-java21", javaServer, javaServerVersion)), nil + } default: return pointer.To(fmt.Sprintf("%s|%s-%s", javaServer, javaServerVersion, javaMajorVersion)), nil diff --git a/internal/services/appservice/linux_web_app_resource_test.go b/internal/services/appservice/linux_web_app_resource_test.go index 70e7cc54004c..c93fb0edd654 100644 --- a/internal/services/appservice/linux_web_app_resource_test.go +++ b/internal/services/appservice/linux_web_app_resource_test.go @@ -1225,7 +1225,7 @@ func TestAccLinuxWebApp_withJre21Java(t *testing.T) { Config: r.java(data, "21", "JAVA", "21"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("site_config.0.linux_fx_version").HasValue("JAVA|21-21"), + check.That(data.ResourceName).Key("site_config.0.linux_fx_version").HasValue("JAVA|21-java21"), ), }, data.ImportStep("site_credential.0.password"),