/// <summary> /// The Create Data Disk operation adds a data disk to a virtual /// machine. There are three ways to create the data disk using the /// Add Data Disk operation. Option 1 - Attach an empty data disk to /// the role by specifying the disk label and location of the disk /// image. Do not include the DiskName and SourceMediaLink elements in /// the request body. Include the MediaLink element and reference a /// blob that is in the same geographical region as the role. You can /// also omit the MediaLink element. In this usage, Azure will create /// the data disk in the storage account configured as default for the /// role. Option 2 - Attach an existing data disk that is in the image /// repository. Do not include the DiskName and SourceMediaLink /// elements in the request body. Specify the data disk to use by /// including the DiskName element. Note: If included the in the /// response body, the MediaLink and LogicalDiskSizeInGB elements are /// ignored. Option 3 - Specify the location of a blob in your storage /// account that contain a disk image to use. Include the /// SourceMediaLink element. Note: If the MediaLink element /// isincluded, it is ignored. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157199.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineDiskOperations. /// </param> /// <param name='serviceName'> /// Required. The name of your service. /// </param> /// <param name='deploymentName'> /// Required. The name of the deployment. /// </param> /// <param name='roleName'> /// Required. The name of the role to add the data disk to. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Create Virtual Machine Data /// Disk operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static AzureOperationResponse BeginCreatingDataDisk(this IVirtualMachineDiskOperations operations, string serviceName, string deploymentName, string roleName, VirtualMachineDataDiskCreateParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IVirtualMachineDiskOperations)s).BeginCreatingDataDiskAsync(serviceName, deploymentName, roleName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// The Create Data Disk operation adds a data disk to a virtual /// machine. There are three ways to create the data disk using the /// Add Data Disk operation. Option 1 - Attach an empty data disk to /// the role by specifying the disk label and location of the disk /// image. Do not include the DiskName and SourceMediaLink elements in /// the request body. Include the MediaLink element and reference a /// blob that is in the same geographical region as the role. You can /// also omit the MediaLink element. In this usage, Azure will create /// the data disk in the storage account configured as default for the /// role. Option 2 - Attach an existing data disk that is in the image /// repository. Do not include the DiskName and SourceMediaLink /// elements in the request body. Specify the data disk to use by /// including the DiskName element. Note: If included the in the /// response body, the MediaLink and LogicalDiskSizeInGB elements are /// ignored. Option 3 - Specify the location of a blob in your storage /// account that contain a disk image to use. Include the /// SourceMediaLink element. Note: If the MediaLink element /// isincluded, it is ignored. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157199.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineDiskOperations. /// </param> /// <param name='serviceName'> /// Required. The name of your service. /// </param> /// <param name='deploymentName'> /// Required. The name of the deployment. /// </param> /// <param name='roleName'> /// Required. The name of the role to add the data disk to. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Create Virtual Machine Data /// Disk operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<OperationResponse> CreateDataDiskAsync(this IVirtualMachineDiskOperations operations, string serviceName, string deploymentName, string roleName, VirtualMachineDataDiskCreateParameters parameters) { return operations.CreateDataDiskAsync(serviceName, deploymentName, roleName, parameters, CancellationToken.None); }
protected PSArgument[] CreateVirtualMachineDiskCreateDataDiskParameters() { string serviceName = string.Empty; string deploymentName = string.Empty; string roleName = string.Empty; VirtualMachineDataDiskCreateParameters parameters = new VirtualMachineDataDiskCreateParameters(); return ConvertFromObjectsToArguments(new string[] { "ServiceName", "DeploymentName", "RoleName", "Parameters" }, new object[] { serviceName, deploymentName, roleName, parameters }); }
/// <summary> /// The Add Data Disk operation adds a data disk to a virtual machine. /// There are three ways to create the data disk using the Add Data /// Disk operation. Option 1 – Attach an empty data disk to the role /// by specifying the disk label and location of the disk image. Do /// not include the DiskName and SourceMediaLink elements in the /// request body. Include the MediaLink element and reference a blob /// that is in the same geographical region as the role. You can also /// omit the MediaLink element. In this usage, Windows Azure will /// create the data disk in the storage account configured as default /// for the role. Option 2 – Attach an existing data disk that is in /// the image repository. Do not include the DiskName and /// SourceMediaLink elements in the request body. Specify the data /// disk to use by including the DiskName element. Note: If included /// the in the response body, the MediaLink and LogicalDiskSizeInGB /// elements are ignored. Option 3 - Specify the location of a blob /// in your storage account that contain a disk image to use. Include /// the SourceMediaLink element. Note: If the MediaLink element /// isincluded, it is ignored. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157199.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineDiskOperations. /// </param> /// <param name='serviceName'> /// The name of your service. /// </param> /// <param name='deploymentName'> /// The name of the deployment. /// </param> /// <param name='roleName'> /// The name of the role to add the data disk to. /// </param> /// <param name='parameters'> /// Parameters supplied to the Create Virtual Machine Data Disk /// operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static OperationResponse CreateDataDisk(this IVirtualMachineDiskOperations operations, string serviceName, string deploymentName, string roleName, VirtualMachineDataDiskCreateParameters parameters) { try { return operations.CreateDataDiskAsync(serviceName, deploymentName, roleName, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }