Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_linux_web_app, azurerm_linux_web_app_slot - fix docker setting not being saved to application setting issue #24086

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions internal/services/appservice/linux_web_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Comment on lines +405 to +420
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this only address part of a larger problem here? Other evaluated settings may also be dropped from the map? I suspect what we should do here is extend the func ExpandAppSettingsForUpdate to take both maps and combine them to ensure everything is caught?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any KVP that are updated via the siteConfig api needs to be updated using the APPSETTING dedicated POST API(https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/list-application-settings?view=rest-appservice-2022-03-01). I only updated the docker one to follow one issue in one PR.

You are correct about extending the ExpandAppSettingsForUpdate to merge the KVPs

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))
Expand Down
15 changes: 15 additions & 0 deletions internal/services/appservice/linux_web_app_slot_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading