Skip to content

Add Documentation for restore from Deleted app #12057

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 7 commits into from
Jun 8, 2020
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
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
* Added safeguard to delete created webapp if restore failed in `Restore-AzDeletedWebApp`
* Added "SourceWebApp.Location" for `New-AzWebApp` and `New-AzWebAppSlot`

## Version 1.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,26 @@ public override void ExecuteCmdlet()
{
throw new Exception("Target App Service Plan " + TargetAppServicePlanName + " not found in target Resource Group " + TargetResourceGroupName);
}
Action createRestoreAction = () =>
try
{
WebsitesClient.CreateWebApp(TargetResourceGroupName, TargetName, TargetSlot, plan.Location, TargetAppServicePlanName,
null, string.Empty, string.Empty);
restoreAction();
};
string confirmMsg = string.Format("This web app will be created. App Name: {0}, Resource Group: {1}", TargetName, TargetResourceGroupName);
if (!string.IsNullOrEmpty(TargetSlot))
Action createRestoreAction = () =>
{
WebsitesClient.CreateWebApp(TargetResourceGroupName, TargetName, TargetSlot, plan.Location, TargetAppServicePlanName,
null, string.Empty, string.Empty);
restoreAction();
};
string confirmMsg = string.Format("This web app will be created. App Name: {0}, Resource Group: {1}", TargetName, TargetResourceGroupName);
if (!string.IsNullOrEmpty(TargetSlot))
{
confirmMsg += ", Slot: " + TargetSlot;
}
ConfirmAction(this.Force.IsPresent, confirmMsg, "The deleted app has been restored.", TargetName, createRestoreAction);
}
catch (Exception e)
{
confirmMsg += ", Slot: " + TargetSlot;
WebsitesClient.RemoveWebApp(TargetResourceGroupName, TargetName, TargetSlot, true, true, false);
throw e;
}
ConfirmAction(this.Force.IsPresent, confirmMsg, "The deleted app has been restored.", TargetName, createRestoreAction);
}

PSSite restoredApp = new PSSite(WebsitesClient.GetWebApp(TargetResourceGroupName, TargetName, TargetSlot));
Expand Down
8 changes: 8 additions & 0 deletions src/Websites/Websites/help/Restore-AzDeletedWebApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ PS C:\> Restore-AzDeletedWebApp -ResourceGroupName Default-Web-WestUS -Name Cont

Restores the Staging slot of a deleted app named ContosoApp belonging to the resource group Default-Web-WestUS. The web app named ContosoRestore belonging to the resource group Default-Web-EastUS will be overwritten. The deleted web app settings will not be restored.

###Example 3
```powershell
PS C:\> $deletedSite = Get-AzDeletedWebApp -ResourceGroupName Default-Web-WestUS -Name ContosoApp
PS C:\> Restore-AzDeletedWebApp -TargetResourceGroupName Default-Web-EastUS -TargetName ContosoRestore -TargetAppServicePlanName ContosoPlan -InputObject $deletedSite[0]
```

In case there are 2 deleted apps with same name(ContosoApp), then we get details of both the sites and restore the app named ContosoRestore with the app of our choice by calling restore with InputObject(Deletedsite) details

## PARAMETERS

### -AsJob
Expand Down