POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/attachDetachDataDisks/?api-version=2023-09-01

Attach and detach data disks to/from the virtual machine.

Servers

Path parameters

Name Type Required Description
vmName String Yes

The name of the virtual machine.

subscriptionId String Yes

Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.

resourceGroupName String Yes

The name of the resource group.

Request headers

Name Type Required Description
Content-Type String Yes The media type of the request body.

Default value: "application/json"

Request body fields

Name Type Required Description
dataDisksToAttach[] Array No

The list of managed data disks to be attached.

dataDisksToAttach[].lun Integer No

The logical unit number of the data disk. This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM. If not specified, lun would be auto assigned.

dataDisksToAttach[].diskId String Yes

ID of the managed data disk.

dataDisksToDetach[] Array No

The list of managed data disks to be detached.

dataDisksToDetach[].detachOption String No

Specifies the detach behavior to be used while detaching a disk or which is already in the process of detachment from the virtual machine. Supported values are: ForceDetach. detachOption: ForceDetach is applicable only for managed data disks. If a previous detachment attempt of the data disk did not complete due to an unexpected failure from the virtual machine and the disk is still not released then use force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'.

Possible values:

  • "ForceDetach"
dataDisksToDetach[].diskId String Yes

ID of the managed data disk.

How to start integrating

  1. Add HTTP Task to your workflow definition.
  2. Search for the API you want to integrate with and click on the name.
    • This loads the API reference documentation and prepares the Http request settings.
  3. Click Test request to test run your request to the API and see the API's response.