-
Notifications
You must be signed in to change notification settings - Fork 4k
Added cmdlets instant file recovery and enhanced tests #4834
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
Conversation
This PR already includes changes proposed in #4821. Once this PR gets merged, will pull from upstream and update the current PR. |
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.
@dragonfly91 a few initial comments
Also, would you mind updating the RecoveryServices.Backup change log to reflect the changes you are making in this PR?
@@ -42,6 +44,19 @@ The last command triggers the backup job for the Backup item in $Item. | |||
|
|||
## PARAMETERS | |||
|
|||
### -DefaultProfile | |||
The credentials, account, tenant, and subscription used for communication with azure.```yaml |
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.
@dragonfly91 for all of the files where you find this applies, please make sure the ```yaml
string at the end of this parameter description is moved to a line by itself. See other parameters in this file for how this should look.
### Example 1: Select the recovery point and get the script | ||
``` | ||
PS C:\> $namedContainer = Get-AzureRmRecoveryServicesBackupContainer -ContainerType "AzureVM" �Status "Registered" -FriendlyName "V2VM" | ||
PS C:\> $backupitem = Get-AzureRmRecoveryServicesBackupItem �Container $namedContainer �WorkloadType "AzureVM" |
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.
@dragonfly91 it looks like there might have been some bad encoding on the first two lines of this example
### Example 1: Select the recovery point and get the script | ||
``` | ||
PS C:\> $namedContainer = Get-AzureRmRecoveryServicesBackupContainer -ContainerType "AzureVM" �Status "Registered" -FriendlyName "V2VM" | ||
PS C:\> $backupitem = Get-AzureRmRecoveryServicesBackupItem �Container $namedContainer �WorkloadType "AzureVM" |
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.
@dragonfly91 same comment about bad encoding in the example
/// </summary> | ||
[Parameter( | ||
Mandatory = false, | ||
ValueFromPipeline = false, |
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.
@dragonfly91 this parameter should not have the ValueFromPipeline
attribute
var response = psBackupProvider.ProvisionItemLevelRecoveryAccess(); | ||
|
||
WriteDebug(string.Format("Mount Script download completed")); | ||
WriteInformation(string.Format(Resources.MountRecoveryPointInfoMessage, response.Password), |
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.
@dragonfly91 I would recommend writing this as a part of the debug or verbose stream
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 text needs to be displayed as it contains a password. When the script is run, it asks for this password to be able to mount the files of the recovery point. Do you have any other option to display the text?
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.
@dragonfly91 WriteInformation is only available in PowerShell 5. Please use one of the other streams. If this needs to be displayed, then it should be part of the output object for the cmdlet
WriteInformation(string.Format(Resources.MountRecoveryPointInfoMessage, response.Password), | ||
null); | ||
WriteObject(response); | ||
}, ShouldProcess(RecoveryPoint.ItemName, VerbsCommon.Get)); |
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.
@dragonfly91 instead of using "Get" as the action, I would say something like "Downloading script..."
Hi Cormac, I've addressed all of your comments. Can you please take a look? |
c88008d
to
ed66bdf
Compare
Hi @markcowl and @cormacpayne I've addressed @markcowl 's comments. Can you please take a look? |
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.
@dragonfly91 a few more comments
@@ -1,8 +1,9 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Hyak.Common" version="1.0.3" targetFramework="net45" /> | |||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net462" /> |
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.
@dragonfly91 what is this package being used for?
string content = string.Empty; | ||
AzureVmRecoveryPoint rp = ProviderData[RestoreBackupItemParams.RecoveryPoint] | ||
as AzureVmRecoveryPoint; | ||
if (rp.EncryptionEnabled == true) |
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.
@dragonfly91 do we need to check if rp
is null before accessing a property of it?
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 case would never happen as we have [ValidateNotNullOrEmpty] declared on top of the RecoveryPoint parameter in the cmdlet definition. So, I don't think a null check is needed.
scriptDownloadLocation = Directory.GetCurrentDirectory(); | ||
} | ||
absoluteFilePath = Path.Combine(scriptDownloadLocation, result.Filename); | ||
File.WriteAllBytes(absoluteFilePath, Convert.FromBase64String(content)); |
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.
@dragonfly91 we should check for the existence of absoluteFilePath
before writing to it
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.
The designed behavior is that the cmdlet overwrites any existing files. However, the file name already contains a randomized string (based on timestamp) and thus every time a new file is generated. So, there's no point in checking for the existence of the file.
scriptDownloadLocation = Directory.GetCurrentDirectory(); | ||
} | ||
absoluteFilePath = Path.Combine(scriptDownloadLocation, result.Filename); | ||
File.WriteAllBytes(absoluteFilePath, Convert.FromBase64String(content)); |
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.
@dragonfly91 also, please use AzureSession.Instance.DataStore
to read from/write to a file.
/// Disable the mount script of recovery point of an item. | ||
/// Files won't be mounted after running this cmdlet. | ||
/// </summary> | ||
[Cmdlet(VerbsLifecycle.Disable, "AzureRmRecoveryServicesBackupRPMountScript", |
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.
@dragonfly91 make sure this cmdlet has an OutputType
, even if it's void
or RecoveryPointBase
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.
Taken this.
``` | ||
|
||
### -Path | ||
Location where the file should be downloaded in the case of file recovery. |
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.
@dragonfly91 it should be made clear in the documentation that if no Path
is provided, then you use the current directory as the save location of the script
Hi @cormacpayne and @markcowl , I've addressed all the given comments. Can you please take a look? |
…very Services Backup. Updating Microsoft.Azure.Management.RecoveryServices.Backup dll version to 2.1.0-preview Updating Microsoft.Azure.Management.RecoveryServices.Backup dll version to 2.1.0-preview in Test projects Updating hint path for Microsoft.Azure.Management.RecoveryServices.Backup dll version to 2.1.0-preview
Renaming model for RecoveryPointAccessInfo Fixing few bugs Fex bug fixes Adding timezone info changes Bug fixes Bug fixes
disabling create vault vm rg backup test test infra betterments, job tests wait job test recording job and get rp tests ilr test get item test recording add protection and backup test recordings get rps test recording Fixes to item tests all tests except restore tests working in both record and playback modes Updated help files Edits to make restore test work upstream pull + full restore test pass ILR test test fixes
Test fixes Renaming instant file restore cmdlets based on design review comments.
Fix 12577430: In Get-Container, should use exact equal check instead of contains check when checking for container name.
…d to the user in Get-AzureRmRSBRPMountScript cmdlet as per PR review comments.
Description
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.
General Guidelines
Testing Guidelines
Cmdlet Signature Guidelines
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThru
parameter.Cmdlet Parameter Guidelines