/// <summary> /// Create network mapping. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.SiteRecovery.INetworkMappingOperations. /// </param> /// <param name='parameters'> /// Required. Create network 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 INetworkMappingOperations operations, NetworkMappingInput parameters, CustomRequestHeaders customRequestHeaders) { return Task.Factory.StartNew((object s) => { return ((INetworkMappingOperations)s).CreateAsync(parameters, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
public void CreateAzureNetworkMappingTest() { using (UndoContext context = UndoContext.Current) { context.Start(); var client = GetSiteRecoveryClient(CustomHttpHandler); // Get Servers var servers = client.Servers.List(RequestHeaders); // 57f95c35-6c83-42ce-bb21-2c4f10f92d8e var networks = client.Networks.List(servers.Servers[0].ID, RequestHeaders); CreateAzureNetworkMappingInput createAzureNetworkMappingInput = new CreateAzureNetworkMappingInput(); createAzureNetworkMappingInput.PrimaryServerId = servers.Servers[0].ID; createAzureNetworkMappingInput.PrimaryNetworkId = networks.Networks[0].ID; createAzureNetworkMappingInput.RecoveryNetworkName = "Azure VM Network name"; createAzureNetworkMappingInput.RecoveryNetworkId = "Azure VM Network ID"; NetworkMappingInput networkMappingInput = new NetworkMappingInput(); networkMappingInput.NetworkTargetType = NetworkTargetType.Azure.ToString(); networkMappingInput.CreateNetworkMappingInput = DataContractUtils.Serialize<CreateAzureNetworkMappingInput>(createAzureNetworkMappingInput); var response = client.NetworkMappings.Create(networkMappingInput, RequestHeaders); Assert.NotNull(response.Job); Assert.NotNull(response.Job.ID); Assert.True(response.Job.Errors.Count < 1, "Errors found while creating network mapping"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } }
/// <summary> /// Create Azure Site Recovery Azure Network Mapping. /// </summary> /// <param name="primaryServerId">Primary server Id</param> /// <param name="primaryNetworkId">Primary network Id</param> /// <param name="recoveryNetworkName">Recovery server Id</param> /// <param name="recoveryNetworkId">Recovery network Id</param> /// <returns>Job response</returns> public JobResponse NewAzureSiteRecoveryAzureNetworkMapping( string primaryServerId, string primaryNetworkId, string recoveryNetworkName, string recoveryNetworkId) { CreateAzureNetworkMappingInput createAzureNetworkMappingInput = new CreateAzureNetworkMappingInput(); createAzureNetworkMappingInput.PrimaryServerId = primaryServerId; createAzureNetworkMappingInput.PrimaryNetworkId = primaryNetworkId; createAzureNetworkMappingInput.RecoveryNetworkName = recoveryNetworkName; createAzureNetworkMappingInput.RecoveryNetworkId = recoveryNetworkId; NetworkMappingInput networkMappingInput = new NetworkMappingInput(); networkMappingInput.NetworkTargetType = NetworkTargetType.Azure.ToString(); networkMappingInput.CreateNetworkMappingInput = DataContractUtils.Serialize<CreateAzureNetworkMappingInput>(createAzureNetworkMappingInput); return this.GetSiteRecoveryClient() .NetworkMappings .Create(networkMappingInput, this.GetRequestHeaders()); }
/// <summary> /// Create network mapping. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.SiteRecovery.INetworkMappingOperations. /// </param> /// <param name='parameters'> /// Required. Create network 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 INetworkMappingOperations operations, NetworkMappingInput parameters, CustomRequestHeaders customRequestHeaders) { return operations.CreateAsync(parameters, customRequestHeaders, CancellationToken.None); }