Exemple #1
0
        /// <summary>
        /// Helper method to fill in input details.
        /// </summary>
        private void AzureToAzureReplication(AddDisksInput input)
        {
            var providerSettings = new A2AAddDisksInput()
            {
                VmDisks        = new List <A2AVmDiskInputDetails>(),
                VmManagedDisks = new List <A2AVmManagedDiskInputDetails>()
            };

            foreach (ASRAzuretoAzureDiskReplicationConfig disk in this.AzureToAzureDiskReplicationConfiguration)
            {
                if (disk.IsManagedDisk)
                {
                    providerSettings.VmManagedDisks.Add(new A2AVmManagedDiskInputDetails
                    {
                        DiskId = disk.DiskId,
                        RecoveryResourceGroupId             = disk.RecoveryResourceGroupId,
                        PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId,
                        RecoveryReplicaDiskAccountType      = disk.RecoveryReplicaDiskAccountType,
                        RecoveryTargetDiskAccountType       = disk.RecoveryTargetDiskAccountType,
                        RecoveryDiskEncryptionSetId         = disk.RecoveryDiskEncryptionSetId
                    });
                }
                else
                {
                    providerSettings.VmDisks.Add(new A2AVmDiskInputDetails
                    {
                        DiskUri = disk.VhdUri,
                        RecoveryAzureStorageAccountId       = disk.RecoveryAzureStorageAccountId,
                        PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId
                    });
                }
            }

            input.Properties.ProviderSpecificDetails = providerSettings;
        }
Exemple #2
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteSiteRecoveryCmdlet()
        {
            base.ExecuteSiteRecoveryCmdlet();
            if (ShouldProcess(this.InputObject.FriendlyName, VerbsCommon.Add))
            {
                // check for A2A protected item - if providerSpecificDetails is A2AReplicationDetails.

                var addDisksProviderSpecificInput = new AddDisksProviderSpecificInput();
                var inputProperties = new AddDisksInputProperties
                {
                    ProviderSpecificDetails = addDisksProviderSpecificInput
                };
                var input = new AddDisksInput {
                    Properties = inputProperties
                };
                AzureToAzureReplication(input);

                this.response = this.RecoveryServicesClient.AddDisks(
                    Utilities.GetValueFromArmId(
                        this.InputObject.ID,
                        ARMResourceTypeConstants.ReplicationFabrics),
                    Utilities.GetValueFromArmId(
                        this.InputObject.ID,
                        ARMResourceTypeConstants.ReplicationProtectionContainers),
                    this.InputObject.Name,
                    input);

                this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails(
                    PSRecoveryServicesClient.GetJobIdFromReponseLocation(this.response.Location));

                this.WriteObject(new ASRJob(this.jobResponse));

                if (this.WaitForCompletion.IsPresent)
                {
                    this.WaitForJobCompletion(this.jobResponse.Name);

                    this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails(
                        PSRecoveryServicesClient
                        .GetJobIdFromReponseLocation(this.response.Location));

                    this.WriteObject(new ASRJob(this.jobResponse));
                }
            }
        }
        /// <summary>
        /// Add disks to replicated protected item.
        /// </summary>
        /// <param name="fabricName">Fabric Name</param>
        /// <param name="protectionContainerName">Protection Container ID</param>
        /// <param name="replicationProtectedItemName">Virtual Machine ID or Replication group Id</param>
        /// <param name="input">Add disks input.</param>
        /// <returns>Job response</returns>
        public PSSiteRecoveryLongRunningOperation AddDisks(
            string fabricName,
            string protectionContainerName,
            string replicationProtectedItemName,
            AddDisksInput input)
        {
            var op = this.GetSiteRecoveryClient()
                     .ReplicationProtectedItems.BeginAddDisksWithHttpMessagesAsync(
                fabricName,
                protectionContainerName,
                replicationProtectedItemName,
                input,
                this.GetRequestHeaders(true))
                     .GetAwaiter()
                     .GetResult();

            var result = SiteRecoveryAutoMapperProfile.Mapper.Map <PSSiteRecoveryLongRunningOperation>(op);

            return(result);
        }