-
Notifications
You must be signed in to change notification settings - Fork 4k
Webapps undelete commands #7165
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
Webapps undelete commands #7165
Conversation
Marking as do not merge until this gets in: #7127 |
@Nking92 Hey Nick, for some reason, GitHub isn't letting me pull in the latest changes from |
0908a7b
to
4d3ed08
Compare
I had an SDK update commit on my own preview branch and then branched the webapps-undelete branch off of that. I have rebased everything to be on upstream/preview, so the SDK update is now included as part of this PR, which will hopefully fix the build. Please note that both Sisira and I have updated the SDK separately. We want to take Sisira's update as the "official" one, and I will rebase my branch on top of that once you merge her PR. So basically, the only commit that needs review is 4d3ed08, and the SDK update commit was only there to get my build working. |
$deletedApp = Get-AzureRmDeletedWebApp -ResourceGroupName $undeleteRgName -Name $undeleteAppName -Slot "Production" | ||
$deletedSlot = Get-AzureRmDeletedWebApp -ResourceGroupName $undeleteRgName -Name $undeleteAppName -Slot $undeleteSlot | ||
Restore-AzureRmDeletedWebApp $deletedApp -TargetResourceGroupName $rgname -TargetName $wname -Force | ||
Restore-AzureRmDeletedWebApp $deletedSlot -TargetResourceGroupName $rgname -TargetName $wname -TargetSlot $slotName -Force |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some asserts here?
New-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location -Tier $tier | ||
$deletedApp = Get-AzureRmDeletedWebApp -ResourceGroupName $undeleteRgName -Name $undeleteAppName -Slot "Production" | ||
$job = $deletedApp | Restore-AzureRmDeletedWebApp -TargetResourceGroupName $rgname -TargetAppServicePlanName $whpName -Force -AsJob | ||
$job | Wait-Job |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, please add some asserts here
@@ -95,7 +95,8 @@ CmdletsToExport = 'Get-AzAppServicePlan', 'Set-AzAppServicePlan', | |||
'New-AzWebApp', 'Remove-AzWebAppBackup', | |||
'Reset-AzWebAppPublishingProfile', 'Restart-AzWebApp', | |||
'Set-AzWebApp', 'Start-AzWebApp', 'Stop-AzWebApp', | |||
'Get-AzWebAppSnapshot', 'Restore-AzWebAppSnapshot' | |||
'Get-AzWebAppSnapshot', 'Restore-AzWebAppSnapshot', | |||
'Get-AzDeletedWebApp' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing one of the cmdlets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow these instructions to create the right aliases for the Az -> AzureRm netcore cmdlets. https://github.com/Azure/azure-powershell/blob/preview/documentation/development-docs/create-alias-mappings.md
|
||
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps | ||
{ | ||
public class AzureDeletedWebApp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a "PS" prefix to indicate that this is a PowerShell model
/// <summary> | ||
/// Restores a deleted Azure Web App's contents and settings to an existing web app | ||
/// </summary> | ||
[Cmdlet("Restore", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "DeletedWebApp"), OutputType(typeof(void))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to do a get here and return the restored web app? I feel like that would be the expected behavior.
{ | ||
// Note, there can be multiple deleted web apps with the same name and resource group. Internally each deleted app has a unique ID. | ||
[Parameter(Position = 0, Mandatory = true, HelpMessage = "The deleted Azure Web App.", ValueFromPipeline = true)] | ||
public AzureDeletedWebApp InputObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you only did the inputobject parameter set - you need the interactive one as well (as discussed in the design review)
Restore-AzureRmDeletedWebApp -ResourceGroupName <string> -Name <string> [-TargetResourceGroupName <string>] -TargetName <string>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I overlooked that. The problem is that there could be a web app with the same name and resource group that was deleted and re-created multiple times. This is actually a relatively common case. In the backend we've given each deleted app a unique ID to avoid ambiguity.
We could default to restoring the most recent deleted app with the provided name and resource group. Do you think that would be good, or could it be too confusing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I do see your point. I think it would be good to be restore the most recently deleted app, but add a warning message if there were multiple stating that we chose to restore the most recent app. Could you also add a parameter set to accept that unique id? Or do you think that the users would not ever want to use that functionality? Apologies if we've previously discussed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on adding the option to undelete by deleted site name with your suggestions.
I don't think many people would use a deleted site ID parameter. The ID is a generated integer that's only discoverable by using the Get-AzureRmDeletedWebApp cmdlet. It's easiest to just use the deleted site object directly instead of pulling the ID out of it. The ID is also something we'd prefer to keep somewhat hidden from customers because it's not much use to them.
public AzureDeletedWebApp InputObject; | ||
|
||
[Parameter(Position = 1, Mandatory = true, HelpMessage = "The resource group containing the new Azure Web App.", ValueFromPipelineByPropertyName = true)] | ||
public string TargetResourceGroupName { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the design review this was not mandatory - why has this changed? Also, none of these parameters should have ValueFromPipelineByPropertyName = true, please remove from all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this to be optional
@Nking92 Is this feature supposed to go in stable or a preview module? |
@Nking92 Please fix merge conflicts. |
@Nking92 In order to get into the Ignite release you will need to update this PR by the end of the day. We are required to hand off to cloudshell by 10am Monday morning. |
…uild errors from breaking changes. Re-record backup tests.
…sserts to tests. Fix az mapping.
…K. Fix build errors from breaking changes. Re-record backup tests." This reverts commit 6964d17.
3072907
to
12788c0
Compare
/// <summary> | ||
/// Restores a deleted Azure Web App's contents and settings to an existing web app | ||
/// </summary> | ||
[Cmdlet("Restore", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "DeletedWebApp"), OutputType(typeof(PSSite))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a DefaultParameterSetName attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add help files for your change: https://github.com/Azure/azure-powershell/blob/preview/documentation/development-docs/help-generation.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please update the changelog at src/Websites/Commands.Websites/Changelog.md
Description
Implements the cmdlets Get-AzureRmDeletedWebApp and Restore-AzureRmDeletedWebApp, which allow users to restore a deleted app.
Sisira is working on updating the Websites project to use the new Websites SDK and fix all breaking changes. I will rebase onto her changes once her PR is accepted. I am opening this PR for early feedback since the deadline is coming up very soon.
Cmdlet review:
https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/128
Checklist
CONTRIBUTING.md
platyPS
module