From 7157985dff49235b77cc336c42adfb9dfc375ee7 Mon Sep 17 00:00:00 2001 From: jackofallops Date: Mon, 8 Jan 2024 15:32:45 +0100 Subject: [PATCH 1/2] fix bug in app settings processing for application_stack --- .../helpers/linux_web_app_schema.go | 80 ++++++------ .../helpers/windows_web_app_schema.go | 120 +++++++++--------- .../appservice/linux_web_app_resource_test.go | 54 ++++++++ .../windows_web_app_resource_test.go | 53 ++++++++ 4 files changed, 205 insertions(+), 102 deletions(-) diff --git a/internal/services/appservice/helpers/linux_web_app_schema.go b/internal/services/appservice/helpers/linux_web_app_schema.go index f55bb88b746d..10d527584957 100644 --- a/internal/services/appservice/helpers/linux_web_app_schema.go +++ b/internal/services/appservice/helpers/linux_web_app_schema.go @@ -894,59 +894,57 @@ func (s *SiteConfigLinux) ExpandForUpdate(metadata sdk.ResourceMetaData, existin expanded.AppCommandLine = pointer.To(s.AppCommandLine) } - if metadata.ResourceData.HasChange("site_config.0.application_stack") { - if len(s.ApplicationStack) == 1 { - linuxAppStack := s.ApplicationStack[0] - if linuxAppStack.NetFrameworkVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("DOTNETCORE|%s", linuxAppStack.NetFrameworkVersion)) - } + if len(s.ApplicationStack) == 1 { + linuxAppStack := s.ApplicationStack[0] + if linuxAppStack.NetFrameworkVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("DOTNETCORE|%s", linuxAppStack.NetFrameworkVersion)) + } - if linuxAppStack.GoVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("GO|%s", linuxAppStack.GoVersion)) - } + if linuxAppStack.GoVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("GO|%s", linuxAppStack.GoVersion)) + } - if linuxAppStack.PhpVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("PHP|%s", linuxAppStack.PhpVersion)) - } + if linuxAppStack.PhpVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("PHP|%s", linuxAppStack.PhpVersion)) + } - if linuxAppStack.NodeVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("NODE|%s", linuxAppStack.NodeVersion)) - } + if linuxAppStack.NodeVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("NODE|%s", linuxAppStack.NodeVersion)) + } - if linuxAppStack.RubyVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("RUBY|%s", linuxAppStack.RubyVersion)) - } + if linuxAppStack.RubyVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("RUBY|%s", linuxAppStack.RubyVersion)) + } - if linuxAppStack.PythonVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("PYTHON|%s", linuxAppStack.PythonVersion)) - } + if linuxAppStack.PythonVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("PYTHON|%s", linuxAppStack.PythonVersion)) + } - if linuxAppStack.JavaServer != "" { - javaString, err := JavaLinuxFxStringBuilder(linuxAppStack.JavaVersion, linuxAppStack.JavaServer, linuxAppStack.JavaServerVersion) - if err != nil { - return nil, fmt.Errorf("could not build linuxFxVersion string: %+v", err) - } - expanded.LinuxFxVersion = javaString + if linuxAppStack.JavaServer != "" { + javaString, err := JavaLinuxFxStringBuilder(linuxAppStack.JavaVersion, linuxAppStack.JavaServer, linuxAppStack.JavaServerVersion) + if err != nil { + return nil, fmt.Errorf("could not build linuxFxVersion string: %+v", err) } + expanded.LinuxFxVersion = javaString + } - if !features.FourPointOhBeta() { - if linuxAppStack.DockerImage != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s:%s", linuxAppStack.DockerImage, linuxAppStack.DockerImageTag)) - } + if !features.FourPointOhBeta() { + if linuxAppStack.DockerImage != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s:%s", linuxAppStack.DockerImage, linuxAppStack.DockerImageTag)) } + } - if linuxAppStack.DockerImageName != "" { - expanded.LinuxFxVersion = pointer.To(EncodeDockerFxString(linuxAppStack.DockerImageName, linuxAppStack.DockerRegistryUrl)) - if appSettings == nil { - appSettings = map[string]string{} - } - appSettings["DOCKER_REGISTRY_SERVER_URL"] = linuxAppStack.DockerRegistryUrl - appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = linuxAppStack.DockerRegistryUsername - appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = linuxAppStack.DockerRegistryPassword + if linuxAppStack.DockerImageName != "" { + expanded.LinuxFxVersion = pointer.To(EncodeDockerFxString(linuxAppStack.DockerImageName, linuxAppStack.DockerRegistryUrl)) + if appSettings == nil { + appSettings = map[string]string{} } - } else { - expanded.LinuxFxVersion = pointer.To("") + appSettings["DOCKER_REGISTRY_SERVER_URL"] = linuxAppStack.DockerRegistryUrl + appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = linuxAppStack.DockerRegistryUsername + appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = linuxAppStack.DockerRegistryPassword } + } else { + expanded.LinuxFxVersion = pointer.To("") } expanded.AppSettings = ExpandAppSettingsForCreate(appSettings) diff --git a/internal/services/appservice/helpers/windows_web_app_schema.go b/internal/services/appservice/helpers/windows_web_app_schema.go index 55e1661d5594..1698519b4279 100644 --- a/internal/services/appservice/helpers/windows_web_app_schema.go +++ b/internal/services/appservice/helpers/windows_web_app_schema.go @@ -622,78 +622,76 @@ func (s *SiteConfigWindows) ExpandForUpdate(metadata sdk.ResourceMetaData, exist expanded.AppCommandLine = pointer.To(s.AppCommandLine) } - if metadata.ResourceData.HasChange("site_config.0.application_stack") { - if len(s.ApplicationStack) == 1 { - winAppStack := s.ApplicationStack[0] - if metadata.ResourceData.HasChange("site_config.0.application_stack.0.node_version") { - if appSettings == nil { - appSettings = make(map[string]string) - } - appSettings["WEBSITE_NODE_DEFAULT_VERSION"] = winAppStack.NodeVersion + if len(s.ApplicationStack) == 1 { + winAppStack := s.ApplicationStack[0] + if metadata.ResourceData.HasChange("site_config.0.application_stack.0.node_version") { + if appSettings == nil { + appSettings = make(map[string]string) } - if metadata.ResourceData.HasChanges("site_config.0.application_stack.0.dotnet_version", "site_config.0.application_stack.0.dotnet_core_version") { - switch { - case winAppStack.NetFrameworkVersion != "": - expanded.NetFrameworkVersion = pointer.To(winAppStack.NetFrameworkVersion) - case winAppStack.NetCoreVersion != "": - expanded.NetFrameworkVersion = pointer.To(winAppStack.NetCoreVersion) - default: - expanded.NetFrameworkVersion = nil - } + appSettings["WEBSITE_NODE_DEFAULT_VERSION"] = winAppStack.NodeVersion + } + if metadata.ResourceData.HasChanges("site_config.0.application_stack.0.dotnet_version", "site_config.0.application_stack.0.dotnet_core_version") { + switch { + case winAppStack.NetFrameworkVersion != "": + expanded.NetFrameworkVersion = pointer.To(winAppStack.NetFrameworkVersion) + case winAppStack.NetCoreVersion != "": + expanded.NetFrameworkVersion = pointer.To(winAppStack.NetCoreVersion) + default: + expanded.NetFrameworkVersion = nil } - if metadata.ResourceData.HasChange("site_config.0.application_stack.0.php_version") { - if winAppStack.PhpVersion != "" { - if winAppStack.PhpVersion != PhpVersionOff { - expanded.PhpVersion = pointer.To(winAppStack.PhpVersion) - } else { - expanded.PhpVersion = pointer.To("") - } + } + if metadata.ResourceData.HasChange("site_config.0.application_stack.0.php_version") { + if winAppStack.PhpVersion != "" { + if winAppStack.PhpVersion != PhpVersionOff { + expanded.PhpVersion = pointer.To(winAppStack.PhpVersion) + } else { + expanded.PhpVersion = pointer.To("") } } - if winAppStack.PythonVersion != "" || winAppStack.Python { - expanded.PythonVersion = pointer.To(winAppStack.PythonVersion) - } - if metadata.ResourceData.HasChange("site_config.0.application_stack.0.java_version") { - if winAppStack.JavaVersion != "" { - expanded.JavaVersion = pointer.To(winAppStack.JavaVersion) - switch { - case winAppStack.JavaEmbeddedServer: - expanded.JavaContainer = pointer.To(JavaContainerEmbeddedServer) - expanded.JavaContainerVersion = pointer.To(JavaContainerEmbeddedServerVersion) - case winAppStack.TomcatVersion != "": - expanded.JavaContainer = pointer.To(JavaContainerTomcat) - expanded.JavaContainerVersion = pointer.To(winAppStack.TomcatVersion) - case winAppStack.JavaContainer != "": - expanded.JavaContainer = pointer.To(winAppStack.JavaContainer) - expanded.JavaContainerVersion = pointer.To(winAppStack.JavaContainerVersion) - } - } else { - expanded.JavaVersion = nil - expanded.JavaContainer = nil - expanded.JavaContainerVersion = nil + } + if winAppStack.PythonVersion != "" || winAppStack.Python { + expanded.PythonVersion = pointer.To(winAppStack.PythonVersion) + } + if metadata.ResourceData.HasChange("site_config.0.application_stack.0.java_version") { + if winAppStack.JavaVersion != "" { + expanded.JavaVersion = pointer.To(winAppStack.JavaVersion) + switch { + case winAppStack.JavaEmbeddedServer: + expanded.JavaContainer = pointer.To(JavaContainerEmbeddedServer) + expanded.JavaContainerVersion = pointer.To(JavaContainerEmbeddedServerVersion) + case winAppStack.TomcatVersion != "": + expanded.JavaContainer = pointer.To(JavaContainerTomcat) + expanded.JavaContainerVersion = pointer.To(winAppStack.TomcatVersion) + case winAppStack.JavaContainer != "": + expanded.JavaContainer = pointer.To(winAppStack.JavaContainer) + expanded.JavaContainerVersion = pointer.To(winAppStack.JavaContainerVersion) } + } else { + expanded.JavaVersion = nil + expanded.JavaContainer = nil + expanded.JavaContainerVersion = nil } - if !features.FourPointOhBeta() { - if winAppStack.DockerContainerName != "" || winAppStack.DockerContainerRegistry != "" || winAppStack.DockerContainerTag != "" { - if winAppStack.DockerContainerRegistry != "" { - expanded.WindowsFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s/%s:%s", winAppStack.DockerContainerRegistry, winAppStack.DockerContainerName, winAppStack.DockerContainerTag)) - } else { - expanded.WindowsFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s:%s", winAppStack.DockerContainerName, winAppStack.DockerContainerTag)) - } + } + if !features.FourPointOhBeta() { + if winAppStack.DockerContainerName != "" || winAppStack.DockerContainerRegistry != "" || winAppStack.DockerContainerTag != "" { + if winAppStack.DockerContainerRegistry != "" { + expanded.WindowsFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s/%s:%s", winAppStack.DockerContainerRegistry, winAppStack.DockerContainerName, winAppStack.DockerContainerTag)) + } else { + expanded.WindowsFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s:%s", winAppStack.DockerContainerName, winAppStack.DockerContainerTag)) } } + } - if winAppStack.DockerImageName != "" { - expanded.WindowsFxVersion = pointer.To(EncodeDockerFxStringWindows(winAppStack.DockerImageName, winAppStack.DockerRegistryUrl)) - appSettings["DOCKER_REGISTRY_SERVER_URL"] = winAppStack.DockerRegistryUrl - appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = winAppStack.DockerRegistryUsername - appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = winAppStack.DockerRegistryPassword - - } + if winAppStack.DockerImageName != "" { + expanded.WindowsFxVersion = pointer.To(EncodeDockerFxStringWindows(winAppStack.DockerImageName, winAppStack.DockerRegistryUrl)) + appSettings["DOCKER_REGISTRY_SERVER_URL"] = winAppStack.DockerRegistryUrl + appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = winAppStack.DockerRegistryUsername + appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = winAppStack.DockerRegistryPassword - } else { - expanded.WindowsFxVersion = pointer.To("") } + + } else { + expanded.WindowsFxVersion = pointer.To("") } expanded.AppSettings = ExpandAppSettingsForCreate(appSettings) diff --git a/internal/services/appservice/linux_web_app_resource_test.go b/internal/services/appservice/linux_web_app_resource_test.go index 55c10e15683c..7eeb94abe3f8 100644 --- a/internal/services/appservice/linux_web_app_resource_test.go +++ b/internal/services/appservice/linux_web_app_resource_test.go @@ -1127,6 +1127,30 @@ func TestAccLinuxWebApp_withDockerImageMCR(t *testing.T) { }) } +func TestAccLinuxWebApp_withDockerUpdateSiteConfig(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_linux_web_app", "test") + r := LinuxWebAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.dockerImageName(data, "https://mcr.microsoft.com", "appsvc/staticsite:latest"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("site_config.0.linux_fx_version").HasValue("DOCKER|mcr.microsoft.com/appsvc/staticsite:latest"), + ), + }, + data.ImportStep(), + { + Config: r.dockerImageNameSiteConfigUpdate(data, "https://mcr.microsoft.com", "appsvc/staticsite:latest"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("site_config.0.linux_fx_version").HasValue("DOCKER|mcr.microsoft.com/appsvc/staticsite:latest"), + ), + }, + data.ImportStep(), + }) +} + func TestAccLinuxWebApp_withDockerImageDockerHub(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_linux_web_app", "test") r := LinuxWebAppResource{} @@ -2935,6 +2959,36 @@ resource "azurerm_linux_web_app" "test" { `, r.baseTemplate(data), data.RandomInteger, containerImage, registryUrl) } +func (r LinuxWebAppResource) dockerImageNameSiteConfigUpdate(data acceptance.TestData, registryUrl, containerImage string) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_linux_web_app" "test" { + name = "acctestWA-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + service_plan_id = azurerm_service_plan.test.id + + app_settings = { + "WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false" + } + + site_config { + application_stack { + docker_image_name = "%s" + docker_registry_url = "%s" + } + + vnet_route_all_enabled = true + } +} +`, r.baseTemplate(data), data.RandomInteger, containerImage, registryUrl) +} + func (r LinuxWebAppResource) autoHealRules(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/internal/services/appservice/windows_web_app_resource_test.go b/internal/services/appservice/windows_web_app_resource_test.go index ae22a8149e7b..665f62edc226 100644 --- a/internal/services/appservice/windows_web_app_resource_test.go +++ b/internal/services/appservice/windows_web_app_resource_test.go @@ -932,6 +932,29 @@ func TestAccWindowsWebApp_withDockerImageMCR(t *testing.T) { }) } +func TestAccWindowsWebApp_withDockerSiteConfigUpdate(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_windows_web_app", "test") + r := WindowsWebAppResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.dockerImageName(data, "https://mcr.microsoft.com", "azure-app-service/windows/parkingpage:latest"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("site_config.0.windows_fx_version").HasValue("DOCKER|mcr.microsoft.com/azure-app-service/windows/parkingpage:latest"), + ), + }, + data.ImportStep(), + { + Config: r.dockerImageNameSiteConfigUpdate(data, "https://mcr.microsoft.com", "azure-app-service/windows/parkingpage:latest"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("site_config.0.windows_fx_version").HasValue("DOCKER|mcr.microsoft.com/azure-app-service/windows/parkingpage:latest"), + ), + }, + data.ImportStep(), + }) +} + func TestAccWindowsWebApp_withDockerImageDockerHub(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_windows_web_app", "test") r := WindowsWebAppResource{} @@ -2493,6 +2516,36 @@ resource "azurerm_windows_web_app" "test" { `, r.premiumV3PlanContainerTemplate(data), data.RandomInteger, containerImage, registryUrl) } +func (r WindowsWebAppResource) dockerImageNameSiteConfigUpdate(data acceptance.TestData, registryUrl, containerImage string) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_windows_web_app" "test" { + name = "acctestWA-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + service_plan_id = azurerm_service_plan.test.id + + app_settings = { + "WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false" + } + + site_config { + application_stack { + docker_image_name = "%s" + docker_registry_url = "%s" + } + + vnet_route_all_enabled = true + } +} +`, r.premiumV3PlanContainerTemplate(data), data.RandomInteger, containerImage, registryUrl) +} + func (r WindowsWebAppResource) node(data acceptance.TestData, nodeVersion string) string { return fmt.Sprintf(` provider "azurerm" { From 380b5bab16b05f0f0137b105e95e3a89f934c08c Mon Sep 17 00:00:00 2001 From: jackofallops Date: Mon, 8 Jan 2024 15:38:47 +0100 Subject: [PATCH 2/2] fix bug in app settings processing for application_stack for slots --- .../appservice/helpers/web_app_slot_schema.go | 187 +++++++++--------- 1 file changed, 92 insertions(+), 95 deletions(-) diff --git a/internal/services/appservice/helpers/web_app_slot_schema.go b/internal/services/appservice/helpers/web_app_slot_schema.go index f0ccac9574bf..29760a2bdb24 100644 --- a/internal/services/appservice/helpers/web_app_slot_schema.go +++ b/internal/services/appservice/helpers/web_app_slot_schema.go @@ -710,62 +710,61 @@ func (s *SiteConfigLinuxWebAppSlot) ExpandForUpdate(metadata sdk.ResourceMetaDat expanded.AppCommandLine = pointer.To(s.AppCommandLine) } - if metadata.ResourceData.HasChange("site_config.0.application_stack") { - if len(s.ApplicationStack) == 1 { - linuxAppStack := s.ApplicationStack[0] - if linuxAppStack.NetFrameworkVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("DOTNETCORE|%s", linuxAppStack.NetFrameworkVersion)) - } + if len(s.ApplicationStack) == 1 { + linuxAppStack := s.ApplicationStack[0] + if linuxAppStack.NetFrameworkVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("DOTNETCORE|%s", linuxAppStack.NetFrameworkVersion)) + } - if linuxAppStack.GoVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("GO|%s", linuxAppStack.GoVersion)) - } + if linuxAppStack.GoVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("GO|%s", linuxAppStack.GoVersion)) + } - if linuxAppStack.PhpVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("PHP|%s", linuxAppStack.PhpVersion)) - } + if linuxAppStack.PhpVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("PHP|%s", linuxAppStack.PhpVersion)) + } - if linuxAppStack.NodeVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("NODE|%s", linuxAppStack.NodeVersion)) - } + if linuxAppStack.NodeVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("NODE|%s", linuxAppStack.NodeVersion)) + } - if linuxAppStack.RubyVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("RUBY|%s", linuxAppStack.RubyVersion)) - } + if linuxAppStack.RubyVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("RUBY|%s", linuxAppStack.RubyVersion)) + } - if linuxAppStack.PythonVersion != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("PYTHON|%s", linuxAppStack.PythonVersion)) - } + if linuxAppStack.PythonVersion != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("PYTHON|%s", linuxAppStack.PythonVersion)) + } - if linuxAppStack.JavaServer != "" { - javaString, err := JavaLinuxFxStringBuilder(linuxAppStack.JavaVersion, linuxAppStack.JavaServer, linuxAppStack.JavaServerVersion) - if err != nil { - return nil, fmt.Errorf("could not build linuxFxVersion string: %+v", err) - } - expanded.LinuxFxVersion = javaString + if linuxAppStack.JavaServer != "" { + javaString, err := JavaLinuxFxStringBuilder(linuxAppStack.JavaVersion, linuxAppStack.JavaServer, linuxAppStack.JavaServerVersion) + if err != nil { + return nil, fmt.Errorf("could not build linuxFxVersion string: %+v", err) } + expanded.LinuxFxVersion = javaString + } - if !features.FourPointOhBeta() { - if linuxAppStack.DockerImage != "" { - expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s:%s", linuxAppStack.DockerImage, linuxAppStack.DockerImageTag)) - } + if !features.FourPointOhBeta() { + if linuxAppStack.DockerImage != "" { + expanded.LinuxFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s:%s", linuxAppStack.DockerImage, linuxAppStack.DockerImageTag)) } + } - if linuxAppStack.DockerImageName != "" { - expanded.LinuxFxVersion = pointer.To(EncodeDockerFxString(linuxAppStack.DockerImageName, linuxAppStack.DockerRegistryUrl)) - - if appSettings == nil { - appSettings = make(map[string]string) - } + if linuxAppStack.DockerImageName != "" { + expanded.LinuxFxVersion = pointer.To(EncodeDockerFxString(linuxAppStack.DockerImageName, linuxAppStack.DockerRegistryUrl)) - appSettings["DOCKER_REGISTRY_SERVER_URL"] = linuxAppStack.DockerRegistryUrl - appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = linuxAppStack.DockerRegistryUsername - appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = linuxAppStack.DockerRegistryPassword + if appSettings == nil { + appSettings = make(map[string]string) } - } else { - expanded.LinuxFxVersion = pointer.To("") + + appSettings["DOCKER_REGISTRY_SERVER_URL"] = linuxAppStack.DockerRegistryUrl + appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = linuxAppStack.DockerRegistryUsername + appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = linuxAppStack.DockerRegistryPassword } + } else { + expanded.LinuxFxVersion = pointer.To("") } + expanded.AppSettings = ExpandAppSettingsForCreate(appSettings) if metadata.ResourceData.HasChange("site_config.0.auto_swap_slot_name") { @@ -1141,70 +1140,68 @@ func (s *SiteConfigWindowsWebAppSlot) ExpandForUpdate(metadata sdk.ResourceMetaD expanded.AppCommandLine = pointer.To(s.AppCommandLine) } - if metadata.ResourceData.HasChange("site_config.0.application_stack") { - if len(s.ApplicationStack) == 1 { - winAppStack := s.ApplicationStack[0] - if metadata.ResourceData.HasChange("site_config.0.application_stack.0.node_version") { - if appSettings == nil { - appSettings = make(map[string]string) - } - appSettings["WEBSITE_NODE_DEFAULT_VERSION"] = winAppStack.NodeVersion + if len(s.ApplicationStack) == 1 { + winAppStack := s.ApplicationStack[0] + if metadata.ResourceData.HasChange("site_config.0.application_stack.0.node_version") { + if appSettings == nil { + appSettings = make(map[string]string) } - if winAppStack.NetFrameworkVersion != "" { - expanded.NetFrameworkVersion = pointer.To(winAppStack.NetFrameworkVersion) + appSettings["WEBSITE_NODE_DEFAULT_VERSION"] = winAppStack.NodeVersion + } + if winAppStack.NetFrameworkVersion != "" { + expanded.NetFrameworkVersion = pointer.To(winAppStack.NetFrameworkVersion) + } + if winAppStack.NetCoreVersion != "" { + expanded.NetFrameworkVersion = pointer.To(winAppStack.NetCoreVersion) + } + if winAppStack.PhpVersion != "" { + if winAppStack.PhpVersion != PhpVersionOff { + expanded.PhpVersion = pointer.To(winAppStack.PhpVersion) + } else { + expanded.PhpVersion = pointer.To("") } - if winAppStack.NetCoreVersion != "" { - expanded.NetFrameworkVersion = pointer.To(winAppStack.NetCoreVersion) + } + if winAppStack.PythonVersion != "" || winAppStack.Python { + expanded.PythonVersion = pointer.To(winAppStack.PythonVersion) + } + if winAppStack.JavaVersion != "" { + expanded.JavaVersion = pointer.To(winAppStack.JavaVersion) + switch { + case winAppStack.JavaEmbeddedServer: + expanded.JavaContainer = pointer.To(JavaContainerEmbeddedServer) + expanded.JavaContainerVersion = pointer.To(JavaContainerEmbeddedServerVersion) + case winAppStack.TomcatVersion != "": + expanded.JavaContainer = pointer.To(JavaContainerTomcat) + expanded.JavaContainerVersion = pointer.To(winAppStack.TomcatVersion) + case winAppStack.JavaContainer != "": + expanded.JavaContainer = pointer.To(winAppStack.JavaContainer) + expanded.JavaContainerVersion = pointer.To(winAppStack.JavaContainerVersion) } - if winAppStack.PhpVersion != "" { - if winAppStack.PhpVersion != PhpVersionOff { - expanded.PhpVersion = pointer.To(winAppStack.PhpVersion) + } + if !features.FourPointOhBeta() { + if winAppStack.DockerContainerName != "" || winAppStack.DockerContainerRegistry != "" || winAppStack.DockerContainerTag != "" { + if winAppStack.DockerContainerRegistry != "" { + expanded.WindowsFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s/%s:%s", winAppStack.DockerContainerRegistry, winAppStack.DockerContainerName, winAppStack.DockerContainerTag)) } else { - expanded.PhpVersion = pointer.To("") - } - } - if winAppStack.PythonVersion != "" || winAppStack.Python { - expanded.PythonVersion = pointer.To(winAppStack.PythonVersion) - } - if winAppStack.JavaVersion != "" { - expanded.JavaVersion = pointer.To(winAppStack.JavaVersion) - switch { - case winAppStack.JavaEmbeddedServer: - expanded.JavaContainer = pointer.To(JavaContainerEmbeddedServer) - expanded.JavaContainerVersion = pointer.To(JavaContainerEmbeddedServerVersion) - case winAppStack.TomcatVersion != "": - expanded.JavaContainer = pointer.To(JavaContainerTomcat) - expanded.JavaContainerVersion = pointer.To(winAppStack.TomcatVersion) - case winAppStack.JavaContainer != "": - expanded.JavaContainer = pointer.To(winAppStack.JavaContainer) - expanded.JavaContainerVersion = pointer.To(winAppStack.JavaContainerVersion) - } - } - if !features.FourPointOhBeta() { - if winAppStack.DockerContainerName != "" || winAppStack.DockerContainerRegistry != "" || winAppStack.DockerContainerTag != "" { - if winAppStack.DockerContainerRegistry != "" { - expanded.WindowsFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s/%s:%s", winAppStack.DockerContainerRegistry, winAppStack.DockerContainerName, winAppStack.DockerContainerTag)) - } else { - expanded.WindowsFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s:%s", winAppStack.DockerContainerName, winAppStack.DockerContainerTag)) - } + expanded.WindowsFxVersion = pointer.To(fmt.Sprintf("DOCKER|%s:%s", winAppStack.DockerContainerName, winAppStack.DockerContainerTag)) } } + } - if winAppStack.DockerImageName != "" { - expanded.WindowsFxVersion = pointer.To(EncodeDockerFxStringWindows(winAppStack.DockerImageName, winAppStack.DockerRegistryUrl)) - - if appSettings == nil { - appSettings = make(map[string]string) - } + if winAppStack.DockerImageName != "" { + expanded.WindowsFxVersion = pointer.To(EncodeDockerFxStringWindows(winAppStack.DockerImageName, winAppStack.DockerRegistryUrl)) - appSettings["DOCKER_REGISTRY_SERVER_URL"] = winAppStack.DockerRegistryUrl - appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = winAppStack.DockerRegistryUsername - appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = winAppStack.DockerRegistryPassword + if appSettings == nil { + appSettings = make(map[string]string) } - } else { - expanded.WindowsFxVersion = pointer.To("") + appSettings["DOCKER_REGISTRY_SERVER_URL"] = winAppStack.DockerRegistryUrl + appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = winAppStack.DockerRegistryUsername + appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = winAppStack.DockerRegistryPassword } + + } else { + expanded.WindowsFxVersion = pointer.To("") } expanded.AppSettings = ExpandAppSettingsForCreate(appSettings)