Skip to content

Commit b743105

Browse files
raohri3VeryEarly
andauthored
add try catch and logs for clone across resource group (#12176)
* adding SourceWebApp.Location details * Update ChangeLog.md * Add Details in documentation * Correcting powershell * Remove app created to restore in case of Failure * Update ChangeLog.md * Add try catch and logs * Update ChangeLog.md Co-authored-by: Yabo Hu <[email protected]>
1 parent 442f790 commit b743105

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Websites/Websites/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* Fixed bug that prevented changing Container settings in `Set-AzWebApp` and `Set-AzWebAppSlot`
2424
* Fixed bug to get SiteConfig when -Name is not given for Get-AzWebApp
2525
* Added a support to create ASP for Linux Apps
26+
* Added exceptions for clone across resource groups
2627

2728
## Version 1.9.0
2829
* Fixed typo on help of `Update-AzWebAppAccessRestrictionConfig`.

src/Websites/Websites/Cmdlets/WebApps/NewAzureWebApp.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,20 @@ public void CreateWithClonedWebApp()
231231
WriteVerboseWithTimestamp("Cloning source web app '{0}' to destination web app {1}", srcwebAppName, Name);
232232
}
233233

234-
WriteObject(new PSSite(WebsitesClient.CreateWebApp(ResourceGroupName, Name, null, Location, AppServicePlan, cloningInfo, AseName, AseResourceGroupName)));
234+
try
235+
{
236+
WriteObject(new PSSite(WebsitesClient.CreateWebApp(ResourceGroupName, Name, null, Location, AppServicePlan, cloningInfo, AseName, AseResourceGroupName)));
237+
}
238+
catch (Exception e)
239+
{
240+
if(e.Message.Contains("Operation returned an invalid status code \'BadRequest\'"))
241+
{
242+
var message = e.Message + "\nIf AppServicePlan is present in other resourceGroup, please provide AppServicePlan in following format : \" /subscriptions/{subscriptionId}/resourcegroups/{resourcegroupName}/providers/Microsoft.Web/serverfarms/{serverFarmName}\"";
243+
WriteObject(message);
244+
throw new Exception(message, e);
245+
}
246+
throw e;
247+
}
235248

236249
if (cloneWebAppSlots)
237250
{

0 commit comments

Comments
 (0)