/// <summary>
        /// Create protection container.
        /// </summary>
        /// <param name="fabricName">Fabric Name.</param>
        /// <param name="protectionContainerName">Protection Container name.</param>
        /// <param name="input">Creation input.</param>
        /// <returns>A long running operation response.</returns>
        public PSSiteRecoveryLongRunningOperation CreateProtectionContainer(
            string fabricName,
            string protectionContainerName,
            CreateProtectionContainerInput input)
        {
            var op = this.GetSiteRecoveryClient().ReplicationProtectionContainers.BeginCreateWithHttpMessagesAsync(
                fabricName,
                protectionContainerName,
                input,
                this.GetRequestHeaders(true))
                     .GetAwaiter()
                     .GetResult();
            var result = SiteRecoveryAutoMapperProfile.Mapper.Map <PSSiteRecoveryLongRunningOperation>(op);

            return(result);
        }
Ejemplo n.º 2
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));
            }
        }
 /// <summary>
 /// Create a protection container.
 /// </summary>
 /// <remarks>
 /// Operation to create a protection container.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fabricName'>
 /// Unique fabric ARM name.
 /// </param>
 /// <param name='protectionContainerName'>
 /// Unique protection container ARM name.
 /// </param>
 /// <param name='creationInput'>
 /// Creation input.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ProtectionContainer> BeginCreateAsync(this IReplicationProtectionContainersOperations operations, string fabricName, string protectionContainerName, CreateProtectionContainerInput creationInput, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateWithHttpMessagesAsync(fabricName, protectionContainerName, creationInput, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create a protection container.
 /// </summary>
 /// <remarks>
 /// Operation to create a protection container.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fabricName'>
 /// Unique fabric ARM name.
 /// </param>
 /// <param name='protectionContainerName'>
 /// Unique protection container ARM name.
 /// </param>
 /// <param name='creationInput'>
 /// Creation input.
 /// </param>
 public static ProtectionContainer BeginCreate(this IReplicationProtectionContainersOperations operations, string fabricName, string protectionContainerName, CreateProtectionContainerInput creationInput)
 {
     return(operations.BeginCreateAsync(fabricName, protectionContainerName, creationInput).GetAwaiter().GetResult());
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a protection container
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IProtectionContainerOperations.
 /// </param>
 /// <param name='fabricName'>
 /// Required. Fabric name.
 /// </param>
 /// <param name='protectionContainerName'>
 /// Required. Protection container name.
 /// </param>
 /// <param name='input'>
 /// Required. Create protection container input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static Task <LongRunningOperationResponse> BeginCreatingAsync(this IProtectionContainerOperations operations, string fabricName, string protectionContainerName, CreateProtectionContainerInput input, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.BeginCreatingAsync(fabricName, protectionContainerName, input, customRequestHeaders, CancellationToken.None));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a protection container
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IProtectionContainerOperations.
 /// </param>
 /// <param name='fabricName'>
 /// Required. Fabric name.
 /// </param>
 /// <param name='protectionContainerName'>
 /// Required. Protection container name.
 /// </param>
 /// <param name='input'>
 /// Required. Create protection container input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static LongRunningOperationResponse BeginCreating(this IProtectionContainerOperations operations, string fabricName, string protectionContainerName, CreateProtectionContainerInput input, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IProtectionContainerOperations)s).BeginCreatingAsync(fabricName, protectionContainerName, input, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }