From 47587b572691d9e98496bf1b0a3c376b15496854 Mon Sep 17 00:00:00 2001 From: Kota Sudhakar Reddy <60102891+Kotasudhakarreddy@users.noreply.github.com> Date: Mon, 17 May 2021 12:27:13 +0530 Subject: [PATCH 1/4] 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 --- src/Websites/Websites/ChangeLog.md | 3 +++ .../AppServicePlans/SetAzureAppServicePlan.cs | 6 ++++- .../DeploymentSlots/SetAzureWebAppSlot.cs | 3 ++- .../Websites/Utilities/WebsitesClient.cs | 22 +++++++++---------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Websites/Websites/ChangeLog.md b/src/Websites/Websites/ChangeLog.md index 3c2829ba7bc0..92230f29f93a 100644 --- a/src/Websites/Websites/ChangeLog.md +++ b/src/Websites/Websites/ChangeLog.md @@ -18,6 +18,9 @@ - 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 ## 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..1669f99e3cc4 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 { @@ -65,7 +66,10 @@ public override void ExecuteCmdlet() 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); + if (Tag != null) + { + CmdletHelpers.ConvertToStringDictionary(Tag).ForEach(item => AppServicePlan.Tags.Add(item)); + } 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( From 55ac4a980024fdcc4bcc8b54aff70794dcf88b78 Mon Sep 17 00:00:00 2001 From: Kota Sudhakar Reddy <60102891+Kotasudhakarreddy@users.noreply.github.com> Date: Mon, 17 May 2021 23:12:37 +0530 Subject: [PATCH 2/4] Build issue fixed --- .../Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs b/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs index 1669f99e3cc4..bf85f4c2dd3f 100644 --- a/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs +++ b/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs @@ -66,10 +66,11 @@ public override void ExecuteCmdlet() 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; - if (Tag != null) - { - CmdletHelpers.ConvertToStringDictionary(Tag).ForEach(item => AppServicePlan.Tags.Add(item)); - } + AppServicePlan.Tags = (IDictionary)CmdletHelpers.ConvertToStringDictionary(Tag); + //if (Tag != null) + //{ + // CmdletHelpers.ConvertToStringDictionary(Tag).ForEach(item => AppServicePlan.Tags.Add(item)); + //} break; } From 6ba5cd0997ad268bc78bcc9a365528d0e2912d49 Mon Sep 17 00:00:00 2001 From: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com> Date: Tue, 18 May 2021 13:59:21 +0800 Subject: [PATCH 3/4] Update ChangeLog.md --- src/Websites/Websites/ChangeLog.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Websites/Websites/ChangeLog.md b/src/Websites/Websites/ChangeLog.md index 92230f29f93a..990919f7e3f0 100644 --- a/src/Websites/Websites/ChangeLog.md +++ b/src/Websites/Websites/ChangeLog.md @@ -18,9 +18,9 @@ - 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 +* updated `Set-AzAppServicePlan` to keep existing Tags when adding new Tags +* Fixed `Set-AzWebApp` to set the AppSettings +* updated `Set-AzWebAppSlot` to set FtpsState ## Version 2.5.0 * Updated `Add-AzWebAppAccessRestrictionRule` to allow all supported Service Tags and validate against Service Tag API. From 1c4e5dd96efc2c1c09e218509bbafcd38c79f76e Mon Sep 17 00:00:00 2001 From: Kota Sudhakar Reddy <60102891+Kotasudhakarreddy@users.noreply.github.com> Date: Tue, 18 May 2021 15:17:20 +0530 Subject: [PATCH 4/4] Build fix --- .../Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs b/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs index bf85f4c2dd3f..a1d2da8cdb7b 100644 --- a/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs +++ b/src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs @@ -65,12 +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); - //if (Tag != null) - //{ - // CmdletHelpers.ConvertToStringDictionary(Tag).ForEach(item => AppServicePlan.Tags.Add(item)); - //} + 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; }