Preserving or detaching managed data disks on VMSS instances

Mark Whitney 81 Reputation points
2021-01-20T22:24:16.237+00:00

We are creating a VMSS with 1 or more managed data disks. We would like to keep all the managed data disks (from all the VMSS instances) when we delete the VMSS.

Is there a way to configure the VMSS on start to not delete the data disks when the VMSS is deleted?

Or if not, is there a way to delete a VMSS and designate that we preserve the data disks upon deletion?

Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
590 questions
Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
362 questions
{count} votes

Accepted answer
  1. vipullag-MSFT 25,616 Reputation points
    2021-01-27T06:04:28.547+00:00

    @Mark Whitney Apologies in delayed response.

    If you specify data disks in the VMSS model, the scale set will track and delete those scale set data disks with the instance. We don't have a way of overriding that from the control plane.

    Below are work arounds for retaining the disks related to VMSS:

    • You can "manually" create standalone disks in your subscription outside the vmss lifecycle, and then attach them to instances. Then you have full control over those disks. See for example az vmss disk
    • You can create a snapshot of a VMSS disk (OS or data disk). You could use a terminate notification to trigger snapshotting the disk right before you delete. There would be some automation on your part to reattach those to a new scale set.

    Hope this helps.
    Please 'Accept as answer' if the provided information is helpful, so that it can help others in the community looking for help on similar topics.

    0 comments No comments

0 additional answers

Sort by: Most helpful