internal void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();
            var parameters = new VirtualMachineDiskUpdateParameters
            {
                Name = this.DiskName,
                Label = this.Label
            };

            this.ExecuteClientActionNewSM(
                null,
                this.CommandRuntime.ToString(),
                () => this.ComputeClient.VirtualMachineDisks.UpdateDisk(this.DiskName, parameters),
                (s, response) => this.ContextFactory<VirtualMachineDiskUpdateResponse, DiskContext>(response, s));
        }
        internal void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();

            VirtualMachineDiskUpdateParameters parameters;

            if (this.ParameterSetName == NoResizeParameterSetName)
            {
                parameters = new VirtualMachineDiskUpdateParameters
                {
                    Name = this.DiskName,
                    Label = this.Label,
                };

                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineDisks.UpdateDisk(this.DiskName, parameters),
                    (s, response) => this.ContextFactory<VirtualMachineDiskUpdateResponse, DiskContext>(response, s));
            }
            else
            {
                if (this.Label == null)
                {
                    var currentDisk = this.ComputeClient.VirtualMachineDisks.GetDisk(this.DiskName);
                    Label = currentDisk.Label;
                }

                parameters = new VirtualMachineDiskUpdateParameters
                {
                    Name = this.DiskName,
                    Label = this.Label,
                    ResizedSizeInGB = this.ResizedSizeInGB,
                };

                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineDisks.UpdateDiskSize(this.DiskName, parameters));
            }
        }
 /// <summary>
 /// The Add Disk operation adds a disk to the user image repository.
 /// The disk can be an operating system disk or a data disk.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157178.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineDiskOperations.
 /// </param>
 /// <param name='name'>
 /// Required. The name of the disk being updated.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Virtual Machine Disk
 /// operation.
 /// </param>
 /// <returns>
 /// A virtual machine disk associated with your subscription.
 /// </returns>
 public static Task<VirtualMachineDiskUpdateResponse> UpdateDiskAsync(this IVirtualMachineDiskOperations operations, string name, VirtualMachineDiskUpdateParameters parameters)
 {
     return operations.UpdateDiskAsync(name, parameters, CancellationToken.None);
 }
 /// <summary>
 /// The Add Disk operation adds a disk to the user image repository.
 /// The disk can be an operating system disk or a data disk.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157178.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineDiskOperations.
 /// </param>
 /// <param name='name'>
 /// Required. The name of the disk being updated.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Virtual Machine Disk
 /// operation.
 /// </param>
 /// <returns>
 /// A virtual machine disk associated with your subscription.
 /// </returns>
 public static VirtualMachineDiskUpdateResponse UpdateDisk(this IVirtualMachineDiskOperations operations, string name, VirtualMachineDiskUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IVirtualMachineDiskOperations)s).UpdateDiskAsync(name, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// The Add Disk operation adds a disk to the user image repository.
 /// The disk can be an operating system disk or a data disk.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157178.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineDiskOperations.
 /// </param>
 /// <param name='name'>
 /// The name of the disk being updated.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Update Virtual Machine Disk operation.
 /// </param>
 /// <returns>
 /// A virtual machine disk associated with your subscription.
 /// </returns>
 public static VirtualMachineDiskUpdateResponse UpdateDisk(this IVirtualMachineDiskOperations operations, string name, VirtualMachineDiskUpdateParameters parameters)
 {
     try
     {
         return operations.UpdateDiskAsync(name, parameters).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
        protected PSArgument[] CreateVirtualMachineDiskUpdateDiskSizeParameters()
        {
            string name = string.Empty;
            VirtualMachineDiskUpdateParameters parameters = new VirtualMachineDiskUpdateParameters();

            return ConvertFromObjectsToArguments(new string[] { "Name", "Parameters" }, new object[] { name, parameters });
        }