Add Data Disk

 

The Add Data Disk operation adds a data disk to a Virtual Machine.

Request

The Add Data Disk request may be specified as follows. Replace <subscription-id> with the subscription ID, <service-name> with the name of the cloud service, <deployment-name> with the name of the deployment, and <role-name> with the name of the role to which the data disk is to be added.

Method

Request URI

POST

https://management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/<deployment-name>/roles/<role-name>/DataDisks

URI Parameters

None.

Request Headers

The following table describes the request headers.

Request Header

Description

x-ms-version

Required. Specifies the version of the operation to use for this request. This header should be set to 2012-03-01 or higher.

Request Body

The format of the request body is as follows:

<DataVirtualHardDisk xmlns="https://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <HostCaching>caching-mode</HostCaching>
  <DiskLabel>identifier-of-disk</DiskLabel>
  <DiskName>name-of-disk</DiskName> 
  <Lun>lun-number</Lun>
  <LogicalDiskSizeInGB>size-in-gb-of-the-disk</LogicalDiskSizeInGB>
  <MediaLink>uri-vhd-file</MediaLink>
  <SourceMediaLink>uri-of-disk</SourceMediaLink>
</DataVirtualHardDisk>

The following table describes the elements of the request body

Element name

Description

HostCaching

Optional. Specifies the caching behavior of data disk.

Possible values are:

  • None

  • ReadOnly

  • ReadWrite

The default vault is None.

DiskLabel

Optional. Specifies the identifier of the data disk. This value is only available programmatically and is not shown in the Management Portal.

DiskName

Optional. Specifies the name of the disk. If this value matches an existing registered disk, the existing disk is attached to the Virtual Machine. If this element is not specified, a name is automatically generated.

Lun

Optional when adding the first data disk to a Virtual Machine. Specifies the Logical Unit Number (LUN) for the disk. The LUN specifies the slot in which the data drive appears when mounted for usage by the Virtual Machine. Valid LUN values are 0 through 31.

LogicalDiskSizeInGB

Optional. Specifies the size, in GB, of an empty disk to be attached to the Virtual Machine. If SourceMediaLink is specified or DiskName refers to an existing disk in the subscription, then this element is ignored.

MediaLink

Required. Specifies the location of the blob in storage where the vhd file for the disk is located. The storage account where the vhd is located must be associated with the specified subscription. If SourceMediaLink is not specified, an empty disk is created at the location specified by this element.

Example:

http://example.blob.core.windows.net/disks/mydisk.vhd

If DiskName refers to an existing registered disk, this element is ignored.

SourceMediaLink

Optional. Specifies the location of a blob in storage which where a vhd file is located that is imported and registered as a disk. If this element is specified, MediaLink is not used.

Response

The response includes an HTTP status code and a set of response headers.

Status Code

A successful operation returns status code 202 (Accepted).

Response Headers

The response for this operation includes the following headers. The response may also include additional standard HTTP headers.

Response Header

Description

x-ms-request-id

A value that uniquely identifies a request made against the management service.

Response Body

None.