From 7314fc0a2d5097745b50d1b67e8f9323529d5c27 Mon Sep 17 00:00:00 2001 From: "Marvin B. Lillehaug" Date: Thu, 13 Jun 2024 10:17:40 +0200 Subject: [PATCH 1/4] Allow java_version 21 for app services and functions. fixes #25490, #24754 Signed-off-by: Marvin B. Lillehaug --- .../services/appservice/helpers/app_stack.go | 1 + .../appservice/helpers/function_app_schema.go | 10 +++--- .../linux_function_app_resource_test.go | 17 ++++++++++ .../appservice/linux_web_app_resource_test.go | 32 +++++++++++++++++++ .../windows_function_app_resource_test.go | 32 +++++++++++++++++++ .../windows_web_app_resource_test.go | 15 +++++++++ website/docs/r/function_app.html.markdown | 2 +- .../docs/r/linux_function_app.html.markdown | 2 +- website/docs/r/linux_web_app.html.markdown | 2 +- .../docs/r/windows_function_app.html.markdown | 2 +- 10 files changed, 107 insertions(+), 8 deletions(-) diff --git a/internal/services/appservice/helpers/app_stack.go b/internal/services/appservice/helpers/app_stack.go index e38a96e577a2..6d064263e9f5 100644 --- a/internal/services/appservice/helpers/app_stack.go +++ b/internal/services/appservice/helpers/app_stack.go @@ -537,6 +537,7 @@ func linuxApplicationStackSchema() *pluginsdk.Schema { "8", "11", "17", + "21", }, false), ExactlyOneOf: linuxApplicationStackConstraint, RequiredWith: []string{ diff --git a/internal/services/appservice/helpers/function_app_schema.go b/internal/services/appservice/helpers/function_app_schema.go index b2517a4611cb..76582b9e6f6d 100644 --- a/internal/services/appservice/helpers/function_app_schema.go +++ b/internal/services/appservice/helpers/function_app_schema.go @@ -1034,7 +1034,7 @@ type ApplicationStackLinuxFunctionApp struct { NodeVersion string `tfschema:"node_version"` // Supported values `12LTS`, `14LTS`, `16LTS`, `18LTS, `20LTS`` PythonVersion string `tfschema:"python_version"` // Supported values `3.12`, `3.11`, `3.10`, `3.9`, `3.8`, `3.7` PowerShellCoreVersion string `tfschema:"powershell_core_version"` // Supported values are `7.0`, `7.2` - JavaVersion string `tfschema:"java_version"` // Supported values `8`, `11`, `17` + JavaVersion string `tfschema:"java_version"` // Supported values `8`, `11`, `17`, `21` CustomHandler bool `tfschema:"use_custom_runtime"` // Supported values `true` Docker []ApplicationStackDocker `tfschema:"docker"` // Needs ElasticPremium or Basic (B1) Standard (S 1-3) or Premium(PxV2 or PxV3) LINUX Service Plan } @@ -1043,7 +1043,7 @@ type ApplicationStackWindowsFunctionApp struct { DotNetVersion string `tfschema:"dotnet_version"` // Supported values `v3.0`, `v4.0`, `v6.0`, `v7.0` and `v8.0` DotNetIsolated bool `tfschema:"use_dotnet_isolated_runtime"` // Supported values `true` for `dotnet-isolated`, `false` otherwise NodeVersion string `tfschema:"node_version"` // Supported values `12LTS`, `14LTS`, `16LTS`, `18LTS, `20LTS` - JavaVersion string `tfschema:"java_version"` // Supported values `8`, `11`, `17` + JavaVersion string `tfschema:"java_version"` // Supported values `8`, `11`, `17`, `21` PowerShellCoreVersion string `tfschema:"powershell_core_version"` // Supported values are `7.0`, `7.2` CustomHandler bool `tfschema:"use_custom_runtime"` // Supported values `true` } @@ -1171,6 +1171,7 @@ func linuxFunctionAppStackSchema() *pluginsdk.Schema { "8", "11", "17", + "21", }, false), ExactlyOneOf: []string{ "site_config.0.application_stack.0.dotnet_version", @@ -1181,7 +1182,7 @@ func linuxFunctionAppStackSchema() *pluginsdk.Schema { "site_config.0.application_stack.0.docker", "site_config.0.application_stack.0.use_custom_runtime", }, - Description: "The version of Java to use. Possible values are `8`, `11`, and `17`", + Description: "The version of Java to use. Possible values are `8`, `11`, `17`, and `21`", }, "docker": { @@ -1403,6 +1404,7 @@ func windowsFunctionAppStackSchema() *pluginsdk.Schema { "1.8", "11", "17", + "21", }, false), ExactlyOneOf: []string{ "site_config.0.application_stack.0.dotnet_version", @@ -1411,7 +1413,7 @@ func windowsFunctionAppStackSchema() *pluginsdk.Schema { "site_config.0.application_stack.0.powershell_core_version", "site_config.0.application_stack.0.use_custom_runtime", }, - Description: "The version of Java to use. Possible values are `1.8`, `11` and `17`", + Description: "The version of Java to use. Possible values are `1.8`, `11`, `17`, and `21`", }, "powershell_core_version": { diff --git a/internal/services/appservice/linux_function_app_resource_test.go b/internal/services/appservice/linux_function_app_resource_test.go index 6da7bf2f976a..fcae1e606826 100644 --- a/internal/services/appservice/linux_function_app_resource_test.go +++ b/internal/services/appservice/linux_function_app_resource_test.go @@ -1232,6 +1232,23 @@ func TestAccLinuxFunctionApp_appStackJava(t *testing.T) { }) } +func TestAccLinuxFunctionApp_appStackJava21(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_linux_function_app", "test") + r := LinuxFunctionAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.appStackJava(data, SkuBasicPlan, "21"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("kind").HasValue("functionapp,linux"), + check.That(data.ResourceName).Key("site_config.0.linux_fx_version").HasValue("JAVA|21"), + ), + }, + data.ImportStep("site_credential.0.password"), + }) +} + func TestAccLinuxFunctionApp_appStackJavaUpdate(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_linux_function_app", "test") r := LinuxFunctionAppResource{} diff --git a/internal/services/appservice/linux_web_app_resource_test.go b/internal/services/appservice/linux_web_app_resource_test.go index fca48ff5b4f1..202650fad3a9 100644 --- a/internal/services/appservice/linux_web_app_resource_test.go +++ b/internal/services/appservice/linux_web_app_resource_test.go @@ -1185,6 +1185,38 @@ func TestAccLinuxWebApp_withJava8JBOSSEAP73(t *testing.T) { }) } +func TestAccLinuxWebApp_withJre17Java(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_linux_web_app", "test") + r := LinuxWebAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.java(data, "17", "JAVA", "17"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("site_config.0.linux_fx_version").HasValue("JAVA|17-java17"), + ), + }, + data.ImportStep("site_credential.0.password"), + }) +} + +func TestAccLinuxWebApp_withJre21Java(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_linux_web_app", "test") + r := LinuxWebAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + 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"), + ), + }, + data.ImportStep("site_credential.0.password"), + }) +} + // TODO - finish known Java matrix combination tests...? func TestAccLinuxWebApp_withDocker(t *testing.T) { diff --git a/internal/services/appservice/windows_function_app_resource_test.go b/internal/services/appservice/windows_function_app_resource_test.go index 5b9cda581fe3..b5372dce58a0 100644 --- a/internal/services/appservice/windows_function_app_resource_test.go +++ b/internal/services/appservice/windows_function_app_resource_test.go @@ -1225,6 +1225,38 @@ func TestAccWindowsFunctionApp_appStackJava11(t *testing.T) { }) } +func TestAccWindowsFunctionApp_appStackJava17(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_windows_function_app", "test") + r := WindowsFunctionAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.appStackJava(data, SkuBasicPlan, "17"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("kind").HasValue("functionapp"), + ), + }, + data.ImportStep("site_credential.0.password"), + }) +} + +func TestAccWindowsFunctionApp_appStackJava21(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_windows_function_app", "test") + r := WindowsFunctionAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.appStackJava(data, SkuBasicPlan, "21"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("kind").HasValue("functionapp"), + ), + }, + data.ImportStep("site_credential.0.password"), + }) +} + func TestAccWindowsFunctionApp_appStackJavaUpdate(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_windows_function_app", "test") r := WindowsFunctionAppResource{} diff --git a/internal/services/appservice/windows_web_app_resource_test.go b/internal/services/appservice/windows_web_app_resource_test.go index 78a83bf5068c..a9e1f0511e12 100644 --- a/internal/services/appservice/windows_web_app_resource_test.go +++ b/internal/services/appservice/windows_web_app_resource_test.go @@ -961,6 +961,21 @@ func TestAccWindowsWebApp_withJava17Embedded(t *testing.T) { }) } +func TestAccWindowsWebApp_withJava21Embedded(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_windows_web_app", "test") + r := WindowsWebAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.java(data, "21"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("site_credential.0.password"), + }) +} + func TestAccWindowsWebApp_withJava1702Embedded(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_windows_web_app", "test") r := WindowsWebAppResource{} diff --git a/website/docs/r/function_app.html.markdown b/website/docs/r/function_app.html.markdown index 4fad99cea602..7ae1eb601baf 100644 --- a/website/docs/r/function_app.html.markdown +++ b/website/docs/r/function_app.html.markdown @@ -279,7 +279,7 @@ The `site_config` block supports the following: -> **NOTE** User has to explicitly set `ip_restriction` to empty slice (`[]`) to remove it. -* `java_version` - (Optional) Java version hosted by the function app in Azure. Possible values are `1.8`, `11` & `17` (In-Preview). +* `java_version` - (Optional) Java version hosted by the function app in Azure. Possible values are `1.8`, `11`, `17`, `21` (In-Preview). * `linux_fx_version` - (Optional) Linux App Framework and version for the AppService, e.g. `DOCKER|(golang:latest)`. diff --git a/website/docs/r/linux_function_app.html.markdown b/website/docs/r/linux_function_app.html.markdown index b494ea9b8656..f2a65634444e 100644 --- a/website/docs/r/linux_function_app.html.markdown +++ b/website/docs/r/linux_function_app.html.markdown @@ -176,7 +176,7 @@ A `application_stack` block supports the following: * `use_dotnet_isolated_runtime` - (Optional) Should the DotNet process use an isolated runtime. Defaults to `false`. -* `java_version` - (Optional) The Version of Java to use. Supported versions include `8`, `11` & `17`. +* `java_version` - (Optional) The Version of Java to use. Supported versions include `8`, `11`, `17`, `21` (In-Preview). * `node_version` - (Optional) The version of Node to run. Possible values include `12`, `14`, `16`, `18` and `20`. diff --git a/website/docs/r/linux_web_app.html.markdown b/website/docs/r/linux_web_app.html.markdown index 58ec9e0ba13f..07df5be2d8a1 100644 --- a/website/docs/r/linux_web_app.html.markdown +++ b/website/docs/r/linux_web_app.html.markdown @@ -166,7 +166,7 @@ An `application_stack` block supports the following: * `java_server_version` - (Optional) The Version of the `java_server` to use. -* `java_version` - (Optional) The Version of Java to use. Possible values include `8`, `11`, and `17`. +* `java_version` - (Optional) The Version of Java to use. Possible values include `8`, `11`, `17`, and `21`. ~> **NOTE:** The valid version combinations for `java_version`, `java_server` and `java_server_version` can be checked from the command line via `az webapp list-runtimes --linux`. diff --git a/website/docs/r/windows_function_app.html.markdown b/website/docs/r/windows_function_app.html.markdown index 6051e5056efc..43cbe8005de0 100644 --- a/website/docs/r/windows_function_app.html.markdown +++ b/website/docs/r/windows_function_app.html.markdown @@ -174,7 +174,7 @@ A `application_stack` block supports the following: * `use_dotnet_isolated_runtime` - (Optional) Should the DotNet process use an isolated runtime. Defaults to `false`. -* `java_version` - (Optional) The Version of Java to use. Supported versions include `1.8`, `11` & `17` (In-Preview). +* `java_version` - (Optional) The Version of Java to use. Supported versions include `1.8`, `11`, `17`, `21` (In-Preview). * `node_version` - (Optional) The version of Node to run. Possible values include `~12`, `~14`, `~16`, `~18` and `~20`. From 0f056eeb748bfeedd282803f46bebb24b2f74910 Mon Sep 17 00:00:00 2001 From: Marvin Bredal Lillehaug Date: Mon, 2 Dec 2024 20:24:15 +0100 Subject: [PATCH 2/4] Improved Preview for `java_version` Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> --- website/docs/r/linux_function_app.html.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/docs/r/linux_function_app.html.markdown b/website/docs/r/linux_function_app.html.markdown index 253df410a2c7..91c3fe632614 100644 --- a/website/docs/r/linux_function_app.html.markdown +++ b/website/docs/r/linux_function_app.html.markdown @@ -176,7 +176,9 @@ A `application_stack` block supports the following: * `use_dotnet_isolated_runtime` - (Optional) Should the DotNet process use an isolated runtime. Defaults to `false`. -* `java_version` - (Optional) The Version of Java to use. Supported versions include `8`, `11`, `17`, `21` (In-Preview). +* `java_version` - (Optional) The Version of Java to use. Supported versions include `8`, `11`, `17`, `21`. + +~> **NOTE:** The value `21` is currently in Preview for `java_version`. * `node_version` - (Optional) The version of Node to run. Possible values include `12`, `14`, `16`, `18` and `20`. From f32b19470c07ef49b51a4a075be17983004f3f29 Mon Sep 17 00:00:00 2001 From: Marvin Bredal Lillehaug Date: Mon, 2 Dec 2024 20:23:32 +0100 Subject: [PATCH 3/4] Revert documentation change in legacy function app. --- website/docs/r/function_app.html.markdown | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/website/docs/r/function_app.html.markdown b/website/docs/r/function_app.html.markdown index 0c0cde7ba3e4..f3d01cdd15c4 100644 --- a/website/docs/r/function_app.html.markdown +++ b/website/docs/r/function_app.html.markdown @@ -195,7 +195,7 @@ resource "azurerm_function_app" "example" { The following arguments are supported: -* `name` - (Required) Specifies the name of the Function App. Changing this forces a new resource to be created. Limit the function name to 32 characters to avoid naming collisions. For more information about [Function App naming rule](https://docs.microsoft.com/azure/azure-resource-manager/management/resource-name-rules#microsoftweb). +* `name` - (Required) Specifies the name of the Function App. Changing this forces a new resource to be created. Limit the function name to 32 characters to avoid naming collisions. For more information about [Function App naming rule](https://docs.microsoft.com/azure/azure-resource-manager/management/resource-name-rules#microsoftweb). * `resource_group_name` - (Required) The name of the resource group in which to create the Function App. Changing this forces a new resource to be created. @@ -279,7 +279,7 @@ The `site_config` block supports the following: -> **NOTE** User has to explicitly set `ip_restriction` to empty slice (`[]`) to remove it. -* `java_version` - (Optional) Java version hosted by the function app in Azure. Possible values are `1.8`, `11`, `17`, `21` (In-Preview). +* `java_version` - (Optional) Java version hosted by the function app in Azure. Possible values are `1.8`, `11` & `17` (In-Preview). * `linux_fx_version` - (Optional) Linux App Framework and version for the AppService, e.g. `DOCKER|(golang:latest)`. @@ -297,9 +297,9 @@ The `site_config` block supports the following: ~> **NOTE:** This setting is incompatible with the `source_control` block which updates this value based on the setting provided. -* `scm_use_main_ip_restriction` - (Optional) IP security restrictions for scm to use main. Defaults to `false`. +* `scm_use_main_ip_restriction` - (Optional) IP security restrictions for scm to use main. Defaults to `false`. --> **NOTE** Any `scm_ip_restriction` blocks configured are ignored by the service when `scm_use_main_ip_restriction` is set to `true`. Any scm restrictions will become active if this is subsequently set to `false` or removed. +-> **NOTE** Any `scm_ip_restriction` blocks configured are ignored by the service when `scm_use_main_ip_restriction` is set to `true`. Any scm restrictions will become active if this is subsequently set to `false` or removed. * `use_32_bit_worker_process` - (Optional) Should the Function App run in 32 bit mode, rather than 64 bit mode? Defaults to `true`. @@ -431,7 +431,7 @@ A `ip_restriction` block supports the following: * `priority` - (Optional) The priority for this IP Restriction. Restrictions are enforced in priority order. By default, the priority is set to 65000 if not specified. -* `action` - (Optional) Does this restriction `Allow` or `Deny` access for this IP range. Defaults to `Allow`. +* `action` - (Optional) Does this restriction `Allow` or `Deny` access for this IP range. Defaults to `Allow`. * `headers` - (Optional) The `headers` block for this specific `ip_restriction` as defined below. @@ -449,7 +449,7 @@ A `scm_ip_restriction` block supports the following: * `name` - (Optional) The name for this IP Restriction. -* `priority` - (Optional) The priority for this IP Restriction. Restrictions are enforced in priority order. By default, priority is set to 65000 if not specified. +* `priority` - (Optional) The priority for this IP Restriction. Restrictions are enforced in priority order. By default, priority is set to 65000 if not specified. * `action` - (Optional) Allow or Deny access for this IP range. Defaults to `Allow`. From 9566e473d9bce7ad03d4418400fcc8510835125e Mon Sep 17 00:00:00 2001 From: Marvin Bredal Lillehaug Date: Mon, 2 Dec 2024 21:09:19 +0100 Subject: [PATCH 4/4] Added necessary handling of java 21 in fx_strings.go --- .../services/appservice/helpers/fx_strings.go | 19 +++++++++++++++++++ .../appservice/linux_web_app_resource_test.go | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) 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"),