public void CreateStorageMappingTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                // Get Servers
                var servers = client.Servers.List(RequestHeaders);

                var storagesOnPrimary = client.Storages.List(servers.Servers[0].ID, RequestHeaders);
                var storagesOnRecovery = client.Storages.List(servers.Servers[1].ID, RequestHeaders);

                StorageMappingInput mappingInput = new StorageMappingInput();
                mappingInput.PrimaryServerId = servers.Servers[0].ID;
                mappingInput.PrimaryStorageId = storagesOnPrimary.Storages[0].ID;
                mappingInput.RecoveryServerId = servers.Servers[1].ID;
                mappingInput.RecoveryStorageId = storagesOnRecovery.Storages[0].ID;

                var response = client.StorageMappings.Create(mappingInput, RequestHeaders);

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.True(response.Job.Errors.Count < 1, "Errors found while creating storage mapping");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
 /// <summary>
 /// Create storage mapping.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.SiteRecovery.IStorageMappingOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Storage mapping input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The response model for the Job details object.
 /// </returns>
 public static JobResponse Create(this IStorageMappingOperations operations, StorageMappingInput parameters, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IStorageMappingOperations)s).CreateAsync(parameters, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        /// <summary>
        /// Delete Azure Site Recovery Storage Mapping.
        /// </summary>
        /// <param name="primaryServerId">Primary server Id</param>
        /// <param name="primaryStorageId">Primary storage Id</param>
        /// <param name="recoveryServerId">Recovery server Id</param>
        /// <param name="recoveryStorageId">Recovery storage Id</param>
        /// <returns>Job response</returns>
        public JobResponse RemoveAzureSiteRecoveryStorageMapping(
            string primaryServerId,
            string primaryStorageId,
            string recoveryServerId,
            string recoveryStorageId)
        {
            StorageMappingInput parameters = new StorageMappingInput();
            parameters.PrimaryServerId = primaryServerId;
            parameters.PrimaryStorageId = primaryStorageId;
            parameters.RecoveryServerId = recoveryServerId;
            parameters.RecoveryStorageId = recoveryStorageId;

            return this.GetSiteRecoveryClient()
                .StorageMappings
                .Delete(parameters, this.GetRequestHeaders());
        }
 /// <summary>
 /// Create storage mapping.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.SiteRecovery.IStorageMappingOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Storage mapping input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The response model for the Job details object.
 /// </returns>
 public static Task<JobResponse> CreateAsync(this IStorageMappingOperations operations, StorageMappingInput parameters, CustomRequestHeaders customRequestHeaders)
 {
     return operations.CreateAsync(parameters, customRequestHeaders, CancellationToken.None);
 }