Esempio n. 1
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteSiteRecoveryCmdlet()
        {
            base.ExecuteSiteRecoveryCmdlet();
            if (this.ShouldProcess(
                    this.Name,
                    VerbsCommon.New))
            {
                if (!this.InputObject.FabricType.Equals(Constants.Azure))
                {
                    throw new Exception(
                              string.Format(
                                  Resources.IncorrectFabricType,
                                  Constants.Azure,
                                  this.InputObject.FabricType));
                }

                var input = new CreateProtectionContainerInput()
                {
                    Properties = new CreateProtectionContainerInputProperties()
                };

                var response =
                    RecoveryServicesClient.CreateProtectionContainer(
                        this.InputObject.Name,
                        this.Name,
                        input);

                string jobId = PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location);

                var jobResponse =
                    RecoveryServicesClient
                    .GetAzureSiteRecoveryJobDetails(jobId);

                WriteObject(new ASRJob(jobResponse));
            }
        }