Skip to content

Azure Site Recovery new cmdlet to support Azure to Azure (A2A) replication #5533

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 13 commits into from
Mar 21, 2018

Conversation

viverm
Copy link
Contributor

@viverm viverm commented Feb 14, 2018

Description

https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/2


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

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

@maddieclayton maddieclayton changed the title Azure to Azure Powershell Azure Site Recovery new cmdlet to support Azure to Azure (A2A) replication Feb 14, 2018
@@ -97,13 +97,26 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.```yaml
Copy link
Contributor

@MiYanni MiYanni Feb 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm There is a platyPS bug that adds these ```yaml endings. You'll need to move each down to a new line for the build to succeed.

@viverm
Copy link
Contributor Author

viverm commented Feb 15, 2018

Changes done . @MiYanni Please check.

@MiYanni
Copy link
Contributor

MiYanni commented Feb 15, 2018

@azuresdkci Retest this please

@viverm
Copy link
Contributor Author

viverm commented Feb 20, 2018

waiting for PR review

'New-AzureRmRecoveryServicesAsrProtectionContainerMapping',
'New-AzureRmRecoveryServicesAsrRecoveryPlan',
'New-AzureRmRecoveryServicesAsrReplicationProtectedItem',
'New-AzureRmRecoveryServicesAsrStorageClassificationMapping',
'New-AzureRmRecoveryServicesAsrvCenter',
'New-AzureToAzureDiskReplicationConfiguration',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs at least an "AzureRm" prefix

@@ -0,0 +1,14 @@
<ASRVaultCreds xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Azure.Portal.RecoveryServices.Models.Common" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a security risk to have this in our public repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. ManagementCert is needed to access vault which is already removed from the file .

########################## Site Recovery Tests #############################

##Default Value ##
$vaultName = "A2APowershellTest"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use getAssetName for generating resource names and Get-Location for getting valid locations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fixed.

$primaryFabricName = "a2aPrimaryFabric3"
$recoveryFabricName = "a2aRecoveryFabric3"

$PrimaryAzureNetworkId = "/subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/powershellTest/providers/Microsoft.Network/virtualNetworks/powershellTest-vnet"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone should be able to rerecord this test, which will not be possible if you are using hard coded subscription ids. You should build up and break down the test infrastructure each time the test is recorded rather than using existing infrastructure that people might not have access to.

Copy link
Contributor Author

@viverm viverm Feb 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Site Recovery works on existing resources .And it needs N number of preexisting resources setup for recovery . For other ASR scenerio rerecording thing will not be easy as Enterprise infra will be non-existing at time of reRecording. ASR cmdlet runs in context of vault and subscription which already is imported from vaultCredentials file. If someone is rerecording he should have prior knowledge of creating infra to rerun and he can pass infra details at starting of the Test PS file.
If we put the logic of infra creation in test it will be pretty complex.

Can discuss if there is easy to make this independent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of our tests need to be rerecordable by people outside of your team, so having hardcoded resource ids with a subscription that most people cannot access will not work. Is there a reason you can't create the resources and infrastructure at test time? We can have a meeting about this if necessary.

[Microsoft.Azure.Test.TestUtilities]::Wait($JobQueryWaitTimeInSeconds * 1000)
}else
{
if( !(($job.State -eq "Succeeded") -or ($job.State -eq "CompletedWithInformation")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it not be !($job.State -eq "CompletedWithInformation")?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two successful condition Succeeded and CompletedWithInformation . If the value is something else it should throw the error.

@@ -19,6 +19,13 @@ New-AzureRmRecoveryServicesAsrNetworkMapping -Name <String> -PrimaryNetwork <ASR
[<CommonParameters>]
```

### AzureToAzure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an example for this new parameter set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -37,6 +37,13 @@ New-AzureRmRecoveryServicesAsrPolicy [-AzureToVMware] -Name <String> -RecoveryPo
[<CommonParameters>]
```

### AzureToAzure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an example for this new parameter set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

@@ -47,6 +47,15 @@ New-AzureRmRecoveryServicesAsrReplicationProtectedItem [-HyperVToAzure] -Protect
[-Confirm] [<CommonParameters>]
```

### AzureToAzure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an example for this new parameter set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

@@ -30,6 +30,14 @@ Update-AzureRmRecoveryServicesAsrPolicy [-VMwareToAzure] -InputObject <ASRPolicy
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### AzureToAzure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an example for this new parameter set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

@@ -51,6 +51,25 @@ Update-AzureRmRecoveryServicesAsrProtectionDirection [-VmmToVmm]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### AzureToAzure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an example for these new parameter sets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

@maddieclayton
Copy link
Contributor

@viverm Sorry for the late review. Some comments for you to look at, I'll look again in more depth when the big issues are fixed. Please reassign to me when you have finished looking at these comments.

@viverm
Copy link
Contributor Author

viverm commented Feb 24, 2018

@maddieclayton Still fix for GetAssetName and hardcoding in test needs to be disscussed.

@viverm viverm removed their assignment Mar 16, 2018
@viverm
Copy link
Contributor Author

viverm commented Mar 16, 2018

@viverm
Copy link
Contributor Author

viverm commented Mar 19, 2018

@cormacpayne Few formatting changes in help files when generated with platyps 2.9.
Check the PR .

### Example 3
```
PS C:\>$job = New-AzureRmRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -AzureToAzureDiskReplicationConfig disk1,disk2 -AzureVmId $vmId `
-Name <String> -RecoveryVmName "vmName" -ProtectionContainerMapping $pcmMapping `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm nit: change <String>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS C:>$job = New-AzureRmRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -AzureToAzureDiskReplicationConfig disk1,disk2 -AzureVmId $vmId -Name "a2aprotectedItem" -RecoveryVmName "vmName" -ProtectionContainerMapping $pcmMapping
-RecoveryResourceGroupId $recoveryResourceGroup
corrected

```
PS C:\> $disk1 = new-AzureToAzureDiskReplicationConfiguration -vhdUri $diskUri1 -RecoveryAzureStorageAccountId $recoveryAzureStorageAccountId -LogStorageAccountId $logStorageAccountId
PS C:\> $disk2 = new-AzureToAzureDiskReplicationConfiguration -vhdUri $diskUri2 -RecoveryAzureStorageAccountId $recoveryAzureStorageAccountId -LogStorageAccountId $logStorageAccountId
PS C:\> $enableDRjob = New-AzureRmRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -AzureVmId $vmId -Name $rpiName -RecoveryCloudServiceId $recoveryCloudServiceId -ProtectionContainerMapping $pcm -RecoveryResourceGroupId $RecoveryResourceGroupId -AzureToAzureDiskReplicationConfiguration $disk1,$disk2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm same comment here about trailing backtick

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cormacpayne these individual commands are in one line that why there is no backtick.

For the readability purpose breaking the in multiple line with backtick.

@viverm
Copy link
Contributor Author

viverm commented Mar 20, 2018

@cormacpayne I am not able to find generated msi file to run and verify the things manually.

https://azuresdkci.westus2.cloudapp.azure.com/job/powershell-demand/638/

How can I generate/find it?

@viverm
Copy link
Contributor Author

viverm commented Mar 20, 2018

@cormacpayne Build is failing after merge . Can you check.

@cormacpayne
Copy link
Member

You can find the generated msi in the following sign job: https://azuresdkci.westus2.cloudapp.azure.com/job/ps-sign/267/

/// </summary>
[Cmdlet(VerbsCommon.New, "AzureRmRecoveryServicesVault", SupportsShouldProcess = true),
OutputType(typeof(ARSVault))]
public class NewAzureRmRecoveryServicesVault : RecoveryServicesCmdletBase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm ping on this comment. This file should be removed.

@@ -76,16 +72,24 @@ public override void ExecuteSiteRecoveryCmdlet()
{
using (var powerShell = System.Management.Automation.PowerShell.Create())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm this powershell object isn't used anymore, so we should get rid of the using that instantiates it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File name changed from NewAzureRMRecoveryServicesVault.cs to NewAzureRmRecoveryServicesVault.cs reindex ed it.

@cormacpayne cormacpayne changed the base branch from preview to release-2018-03-23 March 21, 2018 15:44
@cormacpayne
Copy link
Member

@cormacpayne cormacpayne dismissed markcowl’s stale review March 21, 2018 20:29

Approved offline

@cormacpayne cormacpayne merged commit d841703 into Azure:release-2018-03-23 Mar 21, 2018
@viverm viverm deleted the a2apowershell_preview branch April 17, 2018 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants