From 27f5e7f0cb2c0edc8bc0d0113b45aef52d52eb16 Mon Sep 17 00:00:00 2001 From: Xiaxin Date: Fri, 1 Dec 2023 16:38:25 +0800 Subject: [PATCH] fix docker setting not updated for linux web app[slot] --- .../appservice/linux_web_app_resource.go | 16 ++++++++++++++++ .../appservice/linux_web_app_slot_resource.go | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/internal/services/appservice/linux_web_app_resource.go b/internal/services/appservice/linux_web_app_resource.go index e32a12052faf..a0fcf20a42d0 100644 --- a/internal/services/appservice/linux_web_app_resource.go +++ b/internal/services/appservice/linux_web_app_resource.go @@ -402,6 +402,22 @@ func (r LinuxWebAppResource) Create() sdk.ResourceFunc { metadata.SetID(id) + if siteConfigAppSetting := siteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { + if webApp.AppSettings == nil { + webApp.AppSettings = make(map[string]string) + } + for _, pair := range *siteConfigAppSetting { + if pair.Name == nil || pair.Value == nil { + continue + } + if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || + *pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || + *pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { + webApp.AppSettings[*pair.Name] = *pair.Value + } + } + } + appSettingsUpdate := helpers.ExpandAppSettingsForUpdate(webApp.AppSettings) if metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") { appSettingsUpdate.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(webApp.SiteConfig[0].HealthCheckEvictionTime)) diff --git a/internal/services/appservice/linux_web_app_slot_resource.go b/internal/services/appservice/linux_web_app_slot_resource.go index 65337dbd9581..8a5775608d96 100644 --- a/internal/services/appservice/linux_web_app_slot_resource.go +++ b/internal/services/appservice/linux_web_app_slot_resource.go @@ -383,6 +383,21 @@ func (r LinuxWebAppSlotResource) Create() sdk.ResourceFunc { metadata.SetID(id) + if siteConfigAppSetting := siteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { + if webAppSlot.AppSettings == nil { + webAppSlot.AppSettings = make(map[string]string) + } + for _, pair := range *siteConfigAppSetting { + if pair.Name == nil || pair.Value == nil { + continue + } + if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || + *pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || + *pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { + webAppSlot.AppSettings[*pair.Name] = *pair.Value + } + } + } appSettings := helpers.ExpandAppSettingsForUpdate(webAppSlot.AppSettings) if metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") { appSettings.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(webAppSlot.SiteConfig[0].HealthCheckEvictionTime))