Blog Post

Azure Compute Blog
2 MIN READ

Announcing Public Preview of new attach/detach disks API for VMs/VMSS

viveksingla's avatar
viveksingla
Icon for Microsoft rankMicrosoft
Oct 18, 2024

We are excited to announce the public preview of a new API that will make attaching and detaching disks to a VM faster and easier. The new API is designed to reduce the number of API calls and the latency involved in disk operations. It simplifies the inputs required to attach disks and allows multiple disks to be attached/detached in one request. The new API is compatible with single instance VMs, VMSS  Uniform and VMSS Flex.

 

The new API offers several advantages over the existing disk management API. Here are some of the benefits you can expect from using the new API:

  • Faster and more efficient: The new API reduces the number of API calls and the latency involved in attaching and detaching disks. For example, you can mention only the disk that needs to be attached/detached and don’t need to mention the LUN number. It helps you avoid the GET API call required for getting the list of all disks & LUN numbers being used.
  • Easier and more intuitive: The new API simplifies the disk management workflow by allowing you to attach and detach multiple disks in one request, and by reducing the input parameters.
  • Separate Throttling limits – Currently, customers need to make Update VM API requests to attach/detach a disk and there is a limit of max 12 requests per VM per min. With this new API, customers will get additional quota of X requests per VM per min, in addition to the 12 requests already available for Update VM API.

One of the most common tasks for cloud users is to manage their disk resources. Whether you need to add more storage, backup your data, or migrate to a different instance, you need to attach and detach disks from your virtual machines. This new API is designed to reduce the number of API calls and the latency involved in disk operations.

 

The new API is available as a RESTful endpoint that you can access from any programming language or tool. Since API is in Public Preview, there are no SLA guarantees on the API.

 

How to use the API?

 

POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/rgcompute/providers/Microsoft.Compute/virtualMachines/aaaaaaaaaaaaaaaaaaaa/attachDetachDataDisks?api-version=2024-03-01

{
  "dataDisksToAttach": [
    {
      
      "diskId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/Disk1"
    },
    {
      "lun": 2,
      "diskId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/Disk2",
      "diskEncryptionSet": {
        "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
      },
      "caching": "ReadWrite",
      "deleteOption": "Detach",
      "writeAcceleratorEnabled": false
    }
  ],
  "dataDisksToDetach": [
    {
      "diskId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_1_disk1_1a4e784bdafa49baa780eb2d128ff65x",
      "detachOption": "ForceDetach"
    },
    {
      "diskId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_4_disk4_4d4e784bdafa49baa780eb2d256ff41z"
    }
  ]
}

 

 

For more information, please refer to API documentation.

 

Updated Sep 24, 2024
Version 1.0
No CommentsBe the first to comment