3

I have my virtual machine running Linux. I've created it via new "Resource manager". Then I added data disk to it.

Then I created new Virtual Machine. And I want it to use the same data disk attached to the first one (at least in read-only mode).

When I try to "attach existing disk" to this new machine I get this error: Failed to attach existing disk 'DISK-NAME.vhd' to the virtual machine 'MACHINE-NAME'. Error: Failed to acquire lease while creating disk 'DISK-NAME.vhd' using blob with URI https://BLOB-URI-disk1.vhd. Blob is already in use.

How do I attach existing data disk which is in use by another machine to my current machine?

David Makogon
  • 69,407
  • 21
  • 141
  • 189
Dmitriy Lezhnev
  • 801
  • 2
  • 10
  • 18

3 Answers3

3

Simply, you can't.

A disk in Azure can only be attached to a single VM at a time. in order to attach it to another VM you need to disconnect it from the first.

If you need to have data shared amongst many machines, you could use Azure File shares which provides SMB 2.1 and SMB 3.0. Most modern Linux versions can connect to this quite seamlessly.

If you need block storage, i.e. sharing an actual disk, you would need to spin up a separate VM and use a protocol like iscsi (or NFS) to share that disk amongst multiple machines.

Michael B
  • 11,887
  • 6
  • 38
  • 74
  • So the point of sharing the disk is to increase availability. In case one machine goes down - other machine will still be online. If we use central VM for sharing - the initial problem remains. And yes, we need block storage, the blob with filesystem in it. – Dmitriy Lezhnev Mar 10 '16 at 09:03
  • That isn't the method that is typically used for availability in cloud environments. You create solutions where individual machines can fail but the data is stored across multiple machines and ideally multiple regions. – Michael B Mar 10 '16 at 09:07
  • Ok, we can simply replicate the data on each VM. I thought that since BLOB is already replicated 3 times (according to documentation) then I may use it among many VMs. Do you have a hint on how to share a block storage (which is BLOB in azure) across multiple VMs? – Dmitriy Lezhnev Mar 10 '16 at 09:18
  • 1
    Obviously it very much depends on your use case, but typically look at where the data is coming in and create a mechanism to share that data between machines as it does so, and keep asking yourself 'what happens if this machine fails at this point in the process' - it is a very different way of thinking about things compared to data centers, but it is much more powerful when you get into the mindset. – Michael B Mar 10 '16 at 09:28
0

Maybe the "StorSimple" Solution from Microsoft Azure could be a way to go? I would describe it as SAN on Azure.

I have not tested it today, but it should be possible to connect several virtual machines to it, and share the files.

You can find more information in the documentation: Azure StorSimple

opHASnoNAME
  • 20,224
  • 26
  • 98
  • 143
  • As I see this solution is only available on old Azure Portal. And also it is not available out of the box - https://ftp.azureedge.net/files/2016-03-10_pgyri.jpg I think this solution is an edge-case. There should be more general approaches for sharing the block storages across VMs. – Dmitriy Lezhnev Mar 10 '16 at 10:29
0

Extending Michael's answer a bit, based on your comments under his answer:

If the goal is to provide data access when a VM goes down for some reason, and the data is on an attached disk, then you can detach the disk from the downed VM and reattach it to another VM (the detach breaks the lease, and the reattach creates a new lease). But be aware: This is a time-consuming process - it might take a minute or two for each operation. But you can certainly do it, and you can do it programmatically.

Regarding disk replication: Yes, Azure disks are triple-replicated (or replicated 6 times, if you enable georeplication). But logically, it's a single disk; it's replicated for durability, not for you to attach to different replicas.

Michael mentioned Azure File Service. Maybe it wasn't clear what that was but... there's no Virtual Machine involved with File Service - it's a durable-storage SMB service, with its own SLA unrelated to your VMs. You may attach to it from multiple VMs and read/write files as you would a locally-attached disk (which seems to be the problem you're trying to tackle).

Regarding replication of data across VM's: If you choose to go this route, and make physical copies yourself, it's strictly up to you how you do it - there is no "best way." But this is the type of thing database engines are built for (and you can imagine how complex they are, dealing with replication, journaling, errors, etc.).

David Makogon
  • 69,407
  • 21
  • 141
  • 189