Skip to content

Commit 39560c3

Browse files
Fixes: #15005: Set-AzAppServicePlan to keep existing Tags when adding new Tags (#17650)
* Fix #17184 : `Get-AzWebApp` to return SiteConfig details in the response when requested the WebApps under subscreption * Revert "Fix #17184 : `Get-AzWebApp` to return SiteConfig details in the response when requested the WebApps under subscreption" This reverts commit 96a4d28. * Fix #17184 : `Get-AzWebApp` to return SiteConfig details in the response when requested the WebApps under subscreption * Revert "Fix #17184 : `Get-AzWebApp` to return SiteConfig details in the response when requested the WebApps under subscreption" This reverts commit 96a4d28. * Fixed Set-AzAppServicePlan to keep existing Tags when adding new Tags
1 parent 5725504 commit 39560c3

File tree

4 files changed

+486
-475
lines changed

4 files changed

+486
-475
lines changed

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.AppServicePlanTests/TestCreateNewAppServicePlan.json

Lines changed: 319 additions & 91 deletions
Large diffs are not rendered by default.

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.AppServicePlanTests/TestSetAppServicePlan.json

Lines changed: 152 additions & 380 deletions
Large diffs are not rendered by default.

src/Websites/Websites/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fixed `Set-AzAppServicePlan` to keep existing Tags when adding new Tags
2122
* Fixed `Set-AzWebApp`,`Set-AzWebAppSlot`, `Get-AzWebApp` and `Get-AzWebAppSlot` to expose `VnetRouteAllEnabled` property in `SiteConfig` [#15663]
2223
* Fixed `Set-AzWebApp`, `Set-AzWebAppSlot`, `Get-AzWebApp` and `Get-AzWebAppSlot` to expose `HealthCheckPath` property in `SiteConfig` [#16325]
2324
* Fixed DateTime conversion issue caused by culture [#17253]

src/Websites/Websites/Cmdlets/AppServicePlans/SetAzureAppServicePlan.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,20 @@ public override void ExecuteCmdlet()
6565
int workerSizeAsNumber = 0;
6666
int.TryParse(Regex.Match(AppServicePlan.Sku.Name, @"\d+").Value, out workerSizeAsNumber);
6767
AppServicePlan.Sku.Name = string.IsNullOrWhiteSpace(WorkerSize) ? CmdletHelpers.GetSkuName(AppServicePlan.Sku.Tier, workerSizeAsNumber) : CmdletHelpers.GetSkuName(AppServicePlan.Sku.Tier, WorkerSize);
68-
AppServicePlan.PerSiteScaling = PerSiteScaling;
69-
if (Tag != null && AppServicePlan.Tags!=null)
70-
CmdletHelpers.ConvertToStringDictionary(Tag).ForEach(item => AppServicePlan.Tags?.Add(item));
71-
else
68+
AppServicePlan.PerSiteScaling = PerSiteScaling;
69+
if (Tag != null && AppServicePlan.Tags != null)
70+
CmdletHelpers.ConvertToStringDictionary(Tag).ForEach(item =>
71+
{
72+
if (!AppServicePlan.Tags.ContainsKey(item.Key))
73+
{
74+
AppServicePlan.Tags.Add(item);
75+
}
76+
else
77+
{
78+
AppServicePlan.Tags[item.Key] = item.Value;
79+
}
80+
});
81+
else if (Tag != null)
7282
AppServicePlan.Tags = (IDictionary<string, string>)CmdletHelpers.ConvertToStringDictionary(Tag);
7383
break;
7484
}

0 commit comments

Comments
 (0)