Skip to content

Commit f6f53c9

Browse files
authored
Merge pull request Azure#9198 from panchagnula/sisirap-Tags-Fix
webapp: Set-AzWebapp removing tags when used with -WebApp property
2 parents 4ee16ff + e317430 commit f6f53c9

File tree

5 files changed

+1245
-505
lines changed

5 files changed

+1245
-505
lines changed

src/Websites/Websites.Test/ScenarioTests/WebAppTests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,4 +1357,8 @@ function Test-TagsNotRemovedBySetWebApp
13571357

13581358
Assert-notNull $webApp.Tags
13591359
Assert-notNull $slot.Tags
1360+
1361+
# Test - tags not removed after using Set-AzWebApp with WebApp parameter
1362+
$webapp = Set-AzWebApp -WebApp $getApp
1363+
Assert-notNull $webApp.Tags
13601364
}

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests/TestTagsNotRemovedBySetWebApp.json

Lines changed: 1234 additions & 502 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+
* fixes the issue where using Set-AzWebApp and Set-AzWebAppSlot with -WebApp property was removing the tags
2122

2223
## Version 1.2.1
2324
* "Kind" property will now be set for PSSite objects returned by Get-AzWebApp

src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public override void ExecuteCmdlet()
169169
siteConfig = WebApp.SiteConfig;
170170
}
171171

172-
//According to current implementation if AppSettings paramter is provided we are overriding existing AppSettings
172+
//According to current implementation if AppSettings parameter is provided we are overriding existing AppSettings
173173
if (WebApp.SiteConfig.AppSettings != null && AppSettings == null)
174174
{
175175
foreach (var setting in WebApp.SiteConfig.AppSettings)
@@ -278,7 +278,8 @@ public override void ExecuteCmdlet()
278278
StringComparer.OrdinalIgnoreCase));
279279

280280
CmdletHelpers.TryParseAppServicePlanMetadataFromResourceId(WebApp.ServerFarmId, out rg, out servicePlanName);
281-
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, servicePlanName);
281+
WebApp.AzureStoragePath = null; // the API to update site Object doesn't have the AzureStorage Path property
282+
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, servicePlanName, WebApp);
282283
break;
283284
}
284285

src/Websites/Websites/Cmdlets/WebApps/SetAzureWebApp.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ public override void ExecuteCmdlet()
288288
StringComparer.OrdinalIgnoreCase));
289289

290290
CmdletHelpers.TryParseAppServicePlanMetadataFromResourceId(WebApp.ServerFarmId, out rg, out servicePlanName);
291-
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, null, servicePlanName);
291+
// AzureStorage path is not a part of the back end siteObject, but if the PSSite Object is given as an input, we will some value for this
292+
WebApp.AzureStoragePath = null;
293+
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, null, servicePlanName, WebApp);
292294
WebsitesClient.AddCustomHostNames(ResourceGroupName, location, Name, WebApp.HostNames.ToArray());
293295
break;
294296
}

0 commit comments

Comments
 (0)