예제 #1
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            // Check for at least one option
            if (string.IsNullOrEmpty(this.Name) &&
                string.IsNullOrEmpty(this.Size) &&
                string.IsNullOrEmpty(this.PrimaryNic) &&
                string.IsNullOrEmpty(this.RecoveryNetworkId))
            {
                this.WriteWarning(Properties.Resources.ArgumentsMissingForUpdateVmProperties.ToString());
                return;
            }

            // Both primary & recovery inputs should be present
            if (string.IsNullOrEmpty(this.PrimaryNic) ^
                string.IsNullOrEmpty(this.RecoveryNetworkId))
            {
                this.WriteWarning(Properties.Resources.NetworkArgumentsMissingForUpdateVmProperties.ToString());
                return;
            }

            UpdateVmPropertiesInput updateVmPropertiesInput = new UpdateVmPropertiesInput();

            updateVmPropertiesInput.RecoveryAzureVmGivenName = this.Name;
            updateVmPropertiesInput.RecoveryAzureVmSize      = this.Size;
            updateVmPropertiesInput.SelectedPrimaryNicId     = this.PrimaryNic;
            updateVmPropertiesInput.RecoveryAzureNetworkId   = this.RecoveryNetworkId;

            this.jobResponse = RecoveryServicesClient.UpdateVmProperties(
                this.VirtualMachine.ProtectionContainerId,
                this.VirtualMachine.ID,
                updateVmPropertiesInput);

            this.WriteJob(this.jobResponse.Job);
        }
 /// <summary>
 /// Updates Virtual Machine properties.
 /// </summary>
 /// <param name="protectionContainerId">Protection Container ID</param>
 /// <param name="virtualMachineId">Virtual Machine ID</param>
 /// <param name="updateVmPropertiesInput">Update VM properties input</param>
 /// <returns>Job response</returns>
 public JobResponse UpdateVmProperties(
     string protectionContainerId,
     string virtualMachineId,
     UpdateVmPropertiesInput updateVmPropertiesInput)
 {
     return this.GetSiteRecoveryClient().Vm.UpdateVmProperties(
         protectionContainerId,
         virtualMachineId,
         updateVmPropertiesInput,
         this.GetRequestHeaders());
 }
 /// <summary>
 /// Updates Virtual Machine properties.
 /// </summary>
 /// <param name="protectionContainerId">Protection Container ID</param>
 /// <param name="virtualMachineId">Virtual Machine ID</param>
 /// <param name="updateVmPropertiesInput">Update VM properties input</param>
 /// <returns>Job response</returns>
 public JobResponse UpdateVmProperties(
     string protectionContainerId,
     string virtualMachineId,
     UpdateVmPropertiesInput updateVmPropertiesInput)
 {
     return(this.GetSiteRecoveryClient().Vm.UpdateVmProperties(
                protectionContainerId,
                virtualMachineId,
                updateVmPropertiesInput,
                this.GetRequestHeaders()));
 }
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            // Check for at least one option
            if (string.IsNullOrEmpty(this.Name) && 
                string.IsNullOrEmpty(this.Size) && 
                string.IsNullOrEmpty(this.PrimaryNic) && 
                string.IsNullOrEmpty(this.RecoveryNetworkId))
            {
                this.WriteWarning(Properties.Resources.ArgumentsMissingForUpdateVmProperties.ToString());
                return;
            }

            // Both primary & recovery inputs should be present
            if (string.IsNullOrEmpty(this.PrimaryNic) ^
                string.IsNullOrEmpty(this.RecoveryNetworkId))
            {
                this.WriteWarning(Properties.Resources.NetworkArgumentsMissingForUpdateVmProperties.ToString());
                return;
            }

            UpdateVmPropertiesInput updateVmPropertiesInput = new UpdateVmPropertiesInput();
            updateVmPropertiesInput.RecoveryAzureVmGivenName = this.Name;
            updateVmPropertiesInput.RecoveryAzureVmSize = this.Size;
            updateVmPropertiesInput.SelectedPrimaryNicId = this.PrimaryNic;
            updateVmPropertiesInput.RecoveryAzureNetworkId = this.RecoveryNetworkId;

            this.jobResponse = RecoveryServicesClient.UpdateVmProperties(
                this.VirtualMachine.ProtectionContainerId,
                this.VirtualMachine.ID,
                updateVmPropertiesInput);

            this.WriteJob(this.jobResponse.Job);
        }
 /// <summary>
 /// Updates VM properties.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.SiteRecovery.IVirtualMachineOperations.
 /// </param>
 /// <param name='protectionContainerId'>
 /// Required. Parent Protection Container ID.
 /// </param>
 /// <param name='virtualMachineId'>
 /// Required. VM ID.
 /// </param>
 /// <param name='parameters'>
 /// Required. Update VM properties input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The response model for the Job details object.
 /// </returns>
 public static Task <JobResponse> UpdateVmPropertiesAsync(this IVirtualMachineOperations operations, string protectionContainerId, string virtualMachineId, UpdateVmPropertiesInput parameters, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.UpdateVmPropertiesAsync(protectionContainerId, virtualMachineId, parameters, customRequestHeaders, CancellationToken.None));
 }
 /// <summary>
 /// Updates VM properties.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.SiteRecovery.IVirtualMachineOperations.
 /// </param>
 /// <param name='protectionContainerId'>
 /// Required. Parent Protection Container ID.
 /// </param>
 /// <param name='virtualMachineId'>
 /// Required. VM ID.
 /// </param>
 /// <param name='parameters'>
 /// Required. Update VM properties input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The response model for the Job details object.
 /// </returns>
 public static JobResponse UpdateVmProperties(this IVirtualMachineOperations operations, string protectionContainerId, string virtualMachineId, UpdateVmPropertiesInput parameters, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IVirtualMachineOperations)s).UpdateVmPropertiesAsync(protectionContainerId, virtualMachineId, parameters, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }