Esempio n. 1
0
        /// <summary>
        /// Azure to Azure network mapping.
        /// </summary>
        private void AzureToAzureNetworkMapping()
        {
            CreateNetworkMappingInput input = new CreateNetworkMappingInput
            {
                Properties = new CreateNetworkMappingInputProperties
                {
                    RecoveryFabricName    = this.RecoveryFabric.Name,
                    RecoveryNetworkId     = this.RecoveryAzureNetworkId,
                    FabricSpecificDetails = new AzureToAzureCreateNetworkMappingInput()
                    {
                        PrimaryNetworkId = this.PrimaryAzureNetworkId
                    }
                }
            };

            var response =
                RecoveryServicesClient
                .NewAzureSiteRecoveryNetworkMapping(
                    this.PrimaryFabric.Name,
                    ARMResourceTypeConstants.AzureNetwork,
                    this.Name,
                    input);

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

            WriteObject(new ASRJob(jobResponse));
        }
Esempio n. 2
0
        /// <summary>
        ///     Enterprise to Azure network mapping.
        /// </summary>
        private void EnterpriseToAzureNetworkMapping()
        {
            // Add following checks if needed:
            // Verify whether the subscription is associated with the account or not.
            // Check if the Azure VM Network is associated with the Subscription or not.

            var mappingName = this.Name;

            var input = new CreateNetworkMappingInput
            {
                Properties = new CreateNetworkMappingInputProperties
                {
                    RecoveryFabricName    = "Microsoft Azure",
                    RecoveryNetworkId     = this.RecoveryAzureNetworkId,
                    FabricSpecificDetails = new VmmToAzureCreateNetworkMappingInput()
                }
            };

            var response = this.RecoveryServicesClient.NewAzureSiteRecoveryNetworkMapping(
                Utilities.GetValueFromArmId(
                    this.PrimaryNetwork.ID,
                    ARMResourceTypeConstants.ReplicationFabrics),
                Utilities.GetValueFromArmId(
                    this.PrimaryNetwork.ID,
                    ARMResourceTypeConstants.ReplicationNetworks),
                mappingName,
                input);

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

            this.WriteObject(new ASRJob(jobResponse));
        }
Esempio n. 3
0
        /// <summary>
        ///     Enterprise to enterprise network mapping.
        /// </summary>
        private void EnterpriseToEnterpriseNetworkMapping()
        {
            var mappingName = this.Name;

            var input = new CreateNetworkMappingInput
            {
                Properties = new CreateNetworkMappingInputProperties
                {
                    RecoveryFabricName = Utilities.GetValueFromArmId(
                        this.RecoveryNetwork.ID,
                        ARMResourceTypeConstants.ReplicationFabrics),
                    RecoveryNetworkId     = this.RecoveryNetwork.ID,
                    FabricSpecificDetails = new VmmToVmmCreateNetworkMappingInput()
                }
            };

            var response = this.RecoveryServicesClient.NewAzureSiteRecoveryNetworkMapping(
                Utilities.GetValueFromArmId(
                    this.PrimaryNetwork.ID,
                    ARMResourceTypeConstants.ReplicationFabrics),
                Utilities.GetValueFromArmId(
                    this.PrimaryNetwork.ID,
                    ARMResourceTypeConstants.ReplicationNetworks),
                mappingName,
                input);

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

            this.WriteObject(new ASRJob(jobResponse));
        }
        /// <summary>
        ///     Creates a new Azure Site Recovery Network mapping.
        /// </summary>
        /// <param name="primaryFabricName">Primary fabric name</param>
        /// <param name="primaryNetworkName">Primary network name</param>
        /// <param name="mappingName">Mapping name</param>
        /// <param name="recoveryFabricName">Recovery fabric name</param>
        /// <param name="recoveryNetworkId">Recovery network id</param>
        /// <returns>Long running operation response</returns>
        public PSSiteRecoveryLongRunningOperation NewAzureSiteRecoveryNetworkMapping(
            string primaryFabricName,
            string primaryNetworkName,
            string mappingName,
            CreateNetworkMappingInput input)
        {
            var op = this.GetSiteRecoveryClient()
                     .ReplicationNetworkMappings.BeginCreateWithHttpMessagesAsync(
                primaryFabricName,
                primaryNetworkName,
                mappingName,
                input,
                this.GetRequestHeaders(true))
                     .GetAwaiter()
                     .GetResult();
            var result = Mapper.Map <PSSiteRecoveryLongRunningOperation>(op);

            return(result);
        }
        /// <summary>
        /// Creates a new Azure Site Recovery Network mapping.
        /// </summary>
        /// <param name="primaryFabricName">Primary fabric name</param>
        /// <param name="primaryNetworkName">Primary network name</param>
        /// <param name="mappingName">Mapping name</param>
        /// <param name="recoveryFabricName">Recovery fabric name</param>
        /// <param name="recoveryNetworkId">Recovery network id</param>
        /// <returns>Long running operation response</returns>
        public LongRunningOperationResponse NewAzureSiteRecoveryNetworkMapping(
            string primaryFabricName,
            string primaryNetworkName,
            string mappingName,
            string recoveryFabricName,
            string recoveryNetworkId)
        {
            CreateNetworkMappingInput input = new CreateNetworkMappingInput();

            input.RecoveryFabricName = recoveryFabricName;
            input.RecoveryNetworkId  = recoveryNetworkId;

            return(this.GetSiteRecoveryClient()
                   .NetworkMapping
                   .BeginCreating(
                       primaryFabricName,
                       primaryNetworkName,
                       mappingName,
                       input,
                       this.GetRequestHeaders()));
        }
 /// <summary>
 /// Creates network mapping.
 /// </summary>
 /// <remarks>
 /// The operation to create an ASR network mapping.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fabricName'>
 /// Primary fabric name.
 /// </param>
 /// <param name='networkName'>
 /// Primary network name.
 /// </param>
 /// <param name='networkMappingName'>
 /// Network mapping name.
 /// </param>
 /// <param name='input'>
 /// Create network mapping input.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <NetworkMapping> BeginCreateAsync(this IReplicationNetworkMappingsOperations operations, string fabricName, string networkName, string networkMappingName, CreateNetworkMappingInput input, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateWithHttpMessagesAsync(fabricName, networkName, networkMappingName, input, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Creates network mapping.
 /// </summary>
 /// <remarks>
 /// The operation to create an ASR network mapping.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fabricName'>
 /// Primary fabric name.
 /// </param>
 /// <param name='networkName'>
 /// Primary network name.
 /// </param>
 /// <param name='networkMappingName'>
 /// Network mapping name.
 /// </param>
 /// <param name='input'>
 /// Create network mapping input.
 /// </param>
 public static NetworkMapping BeginCreate(this IReplicationNetworkMappingsOperations operations, string fabricName, string networkName, string networkMappingName, CreateNetworkMappingInput input)
 {
     return(operations.BeginCreateAsync(fabricName, networkName, networkMappingName, input).GetAwaiter().GetResult());
 }
        public void PairNetworks()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                const string fabricName = "Vmm;f0632449-effd-4858-a210-4ea15756e4b7";
                const string primaryNetworkName = "718b68df-ac22-412e-9312-91135cc4451f";
                const string networkMappingName = "Test";
                CreateNetworkMappingInput input = new CreateNetworkMappingInput()
                {
                    //RecoveryFabricName = "Vmm;f0632449-effd-4858-a210-4ea15756e4b7",
                    //RecoveryNetworkId = "/Subscriptions/fa7fd0da-bfa7-41b1-9877-8664fc43d59f/resourceGroups/Default-Storage-WestUS/providers/Microsoft.SiteRecovery/SiteRecoveryVault/testVault/replicationFabrics/Vmm;f0632449-effd-4858-a210-4ea15756e4b7/replicationNetworks/15e1a665-e184-4da0-8e9d-0de72a7d8fa9"
                    RecoveryFabricName = "Microsoft Azure",
                    RecoveryNetworkId = "/subscriptions/19b823e2-d1f3-4805-93d7-401c5d8230d5/resourceGroups/Default-Networking/providers/Microsoft.ClassicNetwork/virtualNetworks/BvtMapped1Network1"
                };

                var response = client.NetworkMapping.Create(
                    fabricName,
                    primaryNetworkName,
                    networkMappingName,
                    input,
                    RequestHeaders);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Creates Network Mapping.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.INetworkMappingOperations.
 /// </param>
 /// <param name='fabricName'>
 /// Required. Fabric Name.
 /// </param>
 /// <param name='primaryNetworkName'>
 /// Required. Primary Network Name.
 /// </param>
 /// <param name='networkMappingName'>
 /// Required. Network Mapping Name.
 /// </param>
 /// <param name='input'>
 /// Required. Network Mapping 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 INetworkMappingOperations operations, string fabricName, string primaryNetworkName, string networkMappingName, CreateNetworkMappingInput input, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.BeginCreatingAsync(fabricName, primaryNetworkName, networkMappingName, input, customRequestHeaders, CancellationToken.None));
 }
Esempio n. 10
0
 /// <summary>
 /// Creates Network Mapping.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.INetworkMappingOperations.
 /// </param>
 /// <param name='fabricName'>
 /// Required. Fabric Name.
 /// </param>
 /// <param name='primaryNetworkName'>
 /// Required. Primary Network Name.
 /// </param>
 /// <param name='networkMappingName'>
 /// Required. Network Mapping Name.
 /// </param>
 /// <param name='input'>
 /// Required. Network Mapping 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 INetworkMappingOperations operations, string fabricName, string primaryNetworkName, string networkMappingName, CreateNetworkMappingInput input, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((INetworkMappingOperations)s).BeginCreatingAsync(fabricName, primaryNetworkName, networkMappingName, input, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }