From 3042f43730bc3069520a0b4d5eebfedb044c293a Mon Sep 17 00:00:00 2001 From: Willem-J-an <51120533+Willem-J-an@users.noreply.github.com> Date: Thu, 7 Jan 2021 06:15:09 +0100 Subject: [PATCH] Fix bug causing Docker Password to be removed from appsettings in Set-AzWebApp(Slot) (#13866) * Fix removal of docker password setting #13865 * minor adjustment to changelog to make sure the versioning script will handle it correctly Co-authored-by: Noort Co-authored-by: Yeming Liu --- src/Websites/Websites/ChangeLog.md | 3 ++- .../Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs | 8 +++++--- .../Websites/Cmdlets/WebApps/SetAzureWebApp.cs | 10 ++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Websites/Websites/ChangeLog.md b/src/Websites/Websites/ChangeLog.md index 6d69398afd1f..96a5e1665714 100644 --- a/src/Websites/Websites/ChangeLog.md +++ b/src/Websites/Websites/ChangeLog.md @@ -22,7 +22,8 @@ - New Cmdlets - New-AzWebAppCertificate - Remove-AzWebAppCertificate - +* Fix bug that causes Docker Password to be removed from appsettings in `Set-AzWebApp` and `Set-AzWebAppSlot` + ## Version 2.1.1 * Prevent duplicate access restriction rules diff --git a/src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs b/src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs index 9d715c2fba41..86214ba6f841 100644 --- a/src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs +++ b/src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs @@ -234,11 +234,13 @@ public override void ExecuteCmdlet() } } - appSettings.Remove(CmdletHelpers.DockerRegistryServerPassword); - if (ContainerRegistryPassword != null) { - appSettings[CmdletHelpers.DockerRegistryServerPassword] = ContainerRegistryPassword.ConvertToString(); + appSettings.Remove(CmdletHelpers.DockerRegistryServerPassword); + if (ContainerRegistryPassword.ConvertToString() != string.Empty) + { + appSettings[CmdletHelpers.DockerRegistryServerPassword] = ContainerRegistryPassword.ConvertToString(); + } } if (parameters.Contains("EnableContainerContinuousDeployment")) diff --git a/src/Websites/Websites/Cmdlets/WebApps/SetAzureWebApp.cs b/src/Websites/Websites/Cmdlets/WebApps/SetAzureWebApp.cs index 426f0b183320..7c7c6fcbf83f 100644 --- a/src/Websites/Websites/Cmdlets/WebApps/SetAzureWebApp.cs +++ b/src/Websites/Websites/Cmdlets/WebApps/SetAzureWebApp.cs @@ -236,14 +236,16 @@ public override void ExecuteCmdlet() if (ContainerRegistryUser != string.Empty) { appSettings[CmdletHelpers.DockerRegistryServerUserName] = ContainerRegistryUser; - } + } } - appSettings.Remove(CmdletHelpers.DockerRegistryServerPassword); - if (ContainerRegistryPassword != null) { - appSettings[CmdletHelpers.DockerRegistryServerPassword] = ContainerRegistryPassword.ConvertToString(); + appSettings.Remove(CmdletHelpers.DockerRegistryServerPassword); + if (ContainerRegistryPassword.ConvertToString() != string.Empty) + { + appSettings[CmdletHelpers.DockerRegistryServerPassword] = ContainerRegistryPassword.ConvertToString(); + } } if (parameters.Contains("EnableContainerContinuousDeployment"))