Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.65k stars 2.84k forks source link

New Attach/Detach data disks APIs support for VMs and VMSS #38030

Open alexn-orca opened 1 month ago

alexn-orca commented 1 month ago

On the 18th of October Azure introduced the new APIs for attaching and detaching data disks for VMs and VMSS.

I would like to have wrappers on those APIs available in Azure python SDK, to me able to attach/detach data volumes without calling update VM operation.

Currently I do this:

    data_disk_update = (virtual_machine.storage_profile.data_disks or []) + [  # type: ignore
        {
            "lun": len(virtual_machine.storage_profile.data_disks),  # type: ignore  # can be 0-15
            # 'name': volume['name'],
            "create_option": DiskCreateOption.attach,
            "managed_disk": {"id": volume_id},
        }
    ]
    virtual_machine_update = {"storage_profile": {"data_disks": data_disk_update}}
  async_disk_attach = await compute_client.virtual_machines.begin_update(rg_name, vm_name, )
  await async_disk_attach.result()

What I want to be able to do: async_disk_attach = await compute_client.virtual_machines.attach_volume(rg_name, vm_name, volumes)

github-actions[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3 @TravisCragg-MSFT.

xiangyan99 commented 1 month ago

Thanks for the feedback, we’ll investigate asap.

msyyc commented 1 month ago

@ChenxiJiang333 Please help on this issue.

ChenxiJiang333 commented 1 month ago

got it

ChenxiJiang333 commented 1 month ago

Hi @alexn-orca, you can now call the new api in Python SDK through this sample: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/compute/azure-mgmt-compute/generated_samples/virtual_machine_examples/virtual_machine_attach_detach_data_disks_maximum_set_gen.py.