Azure Same Storage on VM

2019-03-06 12:38发布

问题:

I want to make 20 Virtual Computers and I want to download same files on them, however it will take too long time to get on each one of them and download the same files. Is there anyway I can have the files already downloaded on the other Virtual machines that I will create so I don't have to re-download on each single one?

回答1:

I'm not sure that I understand what you're trying to do.

If you want to create a base image of software that all your VMs will share, you should be able to set up a single virtual machine, then sysprep the image, capture it, and use that to spin up new virtual machines with the same configuration.

If you want a shared data store, thats what Table, Blob, and SQL storage accounts are for. :)

I don't think you can make multiple VMs that read/write the same disk simultaneously, however. That doesn't make sense. VMs are machines, imagine what would happen if you were simultaneously running 10 machines off the same hard drive and the same os install- there's no practical way for the machines to synchronize their use of the resource to avoid stomping all over each other.


EDIT:

If all you're trying to do is share some data and you're not working with an app (where using Azure Storage like tables or blobs would be the way to go), but just with downloads for some infrastructure or whatnot, I have a couple ideas. What makes sense depends on your specific scenario.

The Network Share

  1. Create an empty data disk on one of your VMs. Don't forget to initialize the disk first, just as you would with a real blank HDD.
  2. Download your content to that data disk. (I assigned drive letter S: for Shared)
  3. While downloading, enable sharing on the folder that they're being downloaded to. Assuming windows 2012:
    1. I created the folder "S:\Downloads\".
    2. I R-clicked on S:\Downloads in Windows Explorer, went to the "Share With >" menu, and selected "Specific people...".
    3. I put "Everyone" in the dialog and shared with Read Only access. << This is not particularly secure. I leave a more well-ACL'd sharing experience as an exercise for the OP.
    4. I clicked "Share" and confirmed the UAC prompt.
  4. Azure is secure by default, so the share won't work yet b/c ports haven't been opened. Poke a hole in your firewall for sharing. From an administrator console prompt: netsh firewall set service type=fileandprint mode=enable profile=current.
  5. Azure also secures your VM in the network environment. You'll have to create endpoints to enable network access, you can do this from the portal on the VM that is opening up the share. Create the following two endpoints:
    1. NetBIOSSession, tcp, port 139 (internal and external)
    2. SMB, tcp, port 445 (internal and external)

At this point, all your other VMs ought to be able to access the share in question via either the sharing VMs DNS name or VIP address (available on your VM's dashboard in the portal). The access ought to be very fast because you're sharing your large data set within the datacenter(s).

The Data Disk

I haven't actually done this myself, so some independent work will be required. Nutshell:

You can upload an arbitrary .vhd to the cloud and create a data disk out of it, so on a local VM add a new static disk (Azure doesn't import dynamic vhds last I checked) and download everything you want to that VHD. Then upload that VHD to your storage and print out a data disk for every VM from the disk image that you uploaded. Done!

The Sysprep'd Image

If we're talking about a dozen different applications that want to be installed on every VM (as opposed to some form of specialized data), I still think the sysprep'd image is the way to go. It looks like there's a bug right now, so the howto of record has been temporarily taken down in favor of a forum post describing the workaround. It looks like the key takeaway is to shutdown your VM from the portal after it's been sysprep'd, not from within the vm.

Hope this helps, good luck!