From e72676a8591c670b1857971bc61b89c026b97cef Mon Sep 17 00:00:00 2001 From: Kota Sudhakar Reddy <60102891+Kotasudhakarreddy@users.noreply.github.com> Date: Tue, 18 May 2021 17:08:23 +0530 Subject: [PATCH] =?UTF-8?q?Fixes:=20#14884:=20`Set-AzWebAppSlot`=20to=20se?= =?UTF-8?q?t=20FtpsState,=20#14998:`Set-AzWeb=E2=80=A6=20(#15011)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes: #14884: `Set-AzWebAppSlot` to set FtpsState, #14998:`Set-AzWebApp` to set the AppSettings, #15005: `Set-AzAppServicePlan` to keep existing Tags when adding new Tags * Build issue fixed * Update ChangeLog.md * Build fix Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com> --- src/Websites/Websites/ChangeLog.md | 4 ++++ .../AppServicePlans/SetAzureAppServicePlan.cs | 8 +++++-- .../DeploymentSlots/SetAzureWebAppSlot.cs | 3 ++- .../Websites/Utilities/WebsitesClient.cs | 22 +++++++++---------- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/Websites/Websites/ChangeLog.md b/src/Websites/Websites/ChangeLog.md index 574126718791..70cd5e2707a0 100644 --- a/src/Websites/Websites/ChangeLog.md +++ b/src/Websites/Websites/ChangeLog.md @@ -18,7 +18,11 @@ - Additional information about change #1 --> ## Upcoming Release +* updated `Set-AzAppServicePlan` to keep existing Tags when adding new Tags +* Fixed `Set-AzWebApp` to set the AppSettings +* updated `Set-AzWebAppSlot` to set FtpsState * Added support for StaticSites. + ## Version 2.5.0 * Updated `Add-AzWebAppAccessRestrictionRule` to allow all supported Service Tags and validate against Service Tag API. diff --git a/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs b/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs index c96248046af9..a1d2da8cdb7b 100644 --- a/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs +++ b/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs @@ -20,6 +20,7 @@ using Microsoft.Azure.Commands.WebApps.Models.WebApp; using System.Collections; using System.Collections.Generic; +using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.Azure.Commands.WebApps.Cmdlets.AppServicePlans { @@ -64,8 +65,11 @@ public override void ExecuteCmdlet() int workerSizeAsNumber = 0; int.TryParse(Regex.Match(AppServicePlan.Sku.Name, @"\d+").Value, out workerSizeAsNumber); AppServicePlan.Sku.Name = string.IsNullOrWhiteSpace(WorkerSize) ? CmdletHelpers.GetSkuName(AppServicePlan.Sku.Tier, workerSizeAsNumber) : CmdletHelpers.GetSkuName(AppServicePlan.Sku.Tier, WorkerSize); - AppServicePlan.PerSiteScaling = PerSiteScaling; - AppServicePlan.Tags = (IDictionary)CmdletHelpers.ConvertToStringDictionary(Tag); + AppServicePlan.PerSiteScaling = PerSiteScaling; + if (Tag != null && AppServicePlan.Tags!=null) + CmdletHelpers.ConvertToStringDictionary(Tag).ForEach(item => AppServicePlan.Tags?.Add(item)); + else + AppServicePlan.Tags = (IDictionary)CmdletHelpers.ConvertToStringDictionary(Tag); break; } diff --git a/src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs b/src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs index 86214ba6f841..5b2b7b2fccb7 100644 --- a/src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs +++ b/src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs @@ -181,7 +181,8 @@ public override void ExecuteCmdlet() parameters.Contains("Use32BitWorkerProcess") ? (bool?)Use32BitWorkerProcess : null, AutoSwapSlotName = parameters.Contains("AutoSwapSlotName") ? AutoSwapSlotName : null, NumberOfWorkers = parameters.Contains("NumberOfWorkers") ? NumberOfWorkers : WebApp.SiteConfig.NumberOfWorkers, - AlwaysOn = parameters.Contains("AlwaysOn") ? (bool)AlwaysOn : false + AlwaysOn = parameters.Contains("AlwaysOn") ? (bool)AlwaysOn : false, + FtpsState = parameters.Contains("FtpsState") ? FtpsState : WebApp.SiteConfig.FtpsState }; } diff --git a/src/Websites/Websites/Utilities/WebsitesClient.cs b/src/Websites/Websites/Utilities/WebsitesClient.cs index ff9034f250c3..5abed9d36f13 100644 --- a/src/Websites/Websites/Utilities/WebsitesClient.cs +++ b/src/Websites/Websites/Utilities/WebsitesClient.cs @@ -513,21 +513,21 @@ public void UpdateWebAppConfiguration(string resourceGroupName, string location, if (useSlot) { - if (appSettings != null) + if (siteConfig != null) { - WrappedWebsitesClient.WebApps().UpdateApplicationSettingsSlot( + WrappedWebsitesClient.WebApps().UpdateConfigurationSlot( resourceGroupName, webSiteName, - new StringDictionary { Properties = appSettings }, + siteConfig.ConvertToSiteConfigResource(), slotName); } - if (siteConfig != null) + if (appSettings != null) { - WrappedWebsitesClient.WebApps().UpdateConfigurationSlot( + WrappedWebsitesClient.WebApps().UpdateApplicationSettingsSlot( resourceGroupName, webSiteName, - siteConfig.ConvertToSiteConfigResource(), + new StringDictionary { Properties = appSettings }, slotName); } @@ -552,6 +552,11 @@ public void UpdateWebAppConfiguration(string resourceGroupName, string location, else { + if (siteConfig != null) + { + WrappedWebsitesClient.WebApps().UpdateConfiguration(resourceGroupName, webSiteName, siteConfig.ConvertToSiteConfigResource()); + } + if (appSettings != null) { WrappedWebsitesClient.WebApps().UpdateApplicationSettings( @@ -560,11 +565,6 @@ public void UpdateWebAppConfiguration(string resourceGroupName, string location, new StringDictionary { Properties = appSettings }); } - if (siteConfig != null) - { - WrappedWebsitesClient.WebApps().UpdateConfiguration(resourceGroupName, webSiteName, siteConfig.ConvertToSiteConfigResource()); - } - if (connectionStrings != null) { WrappedWebsitesClient.WebApps().UpdateConnectionStrings(