Skip to content

webapp: Set-AzWebapp removing tags when used with -WebApp property #9198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Websites/Websites.Test/ScenarioTests/WebAppTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1357,4 +1357,8 @@ function Test-TagsNotRemovedBySetWebApp

Assert-notNull $webApp.Tags
Assert-notNull $slot.Tags

# Test - tags not removed after using Set-AzWebApp with WebApp parameter
$webapp = Set-AzWebApp -WebApp $getApp
Assert-notNull $webApp.Tags
}

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Websites/Websites/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* fixes the issue where using Set-AzWebApp and Set-AzWebAppSlot with -WebApp property was removing the tags

## Version 1.2.1
* "Kind" property will now be set for PSSite objects returned by Get-AzWebApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public override void ExecuteCmdlet()
siteConfig = WebApp.SiteConfig;
}

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

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

Expand Down
4 changes: 3 additions & 1 deletion src/Websites/Websites/Cmdlets/WebApps/SetAzureWebApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ public override void ExecuteCmdlet()
StringComparer.OrdinalIgnoreCase));

CmdletHelpers.TryParseAppServicePlanMetadataFromResourceId(WebApp.ServerFarmId, out rg, out servicePlanName);
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, null, servicePlanName);
// 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
WebApp.AzureStoragePath = null;
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, null, servicePlanName, WebApp);
WebsitesClient.AddCustomHostNames(ResourceGroupName, location, Name, WebApp.HostNames.ToArray());
break;
}
Expand Down