How to add a empty disk to a virtual machine under new storage location?

10,264

Solution 1

I haven't tried this yet, but I believe you can add a new empty data disk via PowerShell, and specify the location in blob storage. Check out the Add-AzureDataDisk cmdlet and the -MediaLocation parameter.

Solution 2

I hit this issue and was able to finally resolve it. I just wanted to share what I've done so far in case it is helpful.

To start with I had to create the .vhd on my computer. If you open "Disk Management" (Start -> Run -> mmc then choose File -> Add Snap In). In Disk Management from the "More Options" menu you can create a new .vhd. Make sure to use a fixed size disk. Azure won't let you use the expanding disk size (I'm pretty sure you only get charged for what you use, not the full size of the fixed disk). Use Disk Management to Initialize and make it a Simple volume (which formats the disk).

Next I had to upload it to my storage account. To start with, make sure your storage account has at least 1 container. You can set this up in the Azure console (manage.windowsazure.com). The file must be uploaded as a Page Blob.

Next I used a free tool AzCopy (http://blogs.msdn.com/b/windowsazurestorage/archive/2013/04/01/azcopy-using-cross-account-copy-blob.aspx). You'll need the URL and key for your storage container. You can get to both in the Azure console by going to the Storage menu item then selecting your storage, then clicking Manage Keys.

The tool is a command line tool and my command line looked like this:

c:\Users\jim\Desktop\AzCopy>AzCopy.exe c:\users\jim\desktop\main https://[storage url]/[container name] /destkey:[secret key] /blobtype:page /V /S

In that example my .vhd file was the only file in the desktop\main folder.

I'm not sure if that is all you needed, but I'll give the remainder of the steps I followed to make it visible in my virtual machine.

Next I went back into the Azure management console. I clicked on the Virtual Machines menu item, then chose Disks along the top menu. I then clicked Create and was able to add a disk by browsing to it in the container in my Storage. Then you should be able to go to the Dashboard of your Virtual Machine to attach it.

Share:
10,264
NullReference
Author by

NullReference

Yep, I'm that interesting.

Updated on June 04, 2022

Comments

  • NullReference
    NullReference almost 2 years

    I'd like to add an empty data disk to a virtual drive under a new storage location. When I have the virtual machine select and click Add -> Empty Data Disk I'm not able to change the storage location. Does anyone know how to change the default storage location when adding an empty disk? Thanks

    UPDATE

    I believe this is the command that needs to be run. But running it on the vm doesn't do anything.

    Get-AzureVM "service" -Name "vmname" `| Add-AzureDataDisk -CreateNew -DiskSizeInGB 1000 -DiskLabel "sqlsa1" -MediaLocation "http://mystoragelocation.blob.core.windows.net/" -LUN 4 '| Update-AzureVM
    
    • David Makogon
      David Makogon over 10 years
      Your call to Add-AzureDataDisk is incorrect, as it doesn't point to a blob, only a storage account. Run Get-Help Add-AzureDataDisk -Detailed or Get-Help Add-AzureDataDisk -Examples to see how to use it properly.
    • NullReference
      NullReference over 10 years
      @DavidMakogon I appreciate the help. I understand the concept of vhds and how it needs to be pointed to one. But how does one simply create an empty vhd in a storage location?
    • David Makogon
      David Makogon over 10 years
      As I commented on Michael's answer: you must use the -CreateNew flag.
    • NullReference
      NullReference over 10 years
      @DavidMakogon Forgive my ignorance, but doesn't the url provided in update 1 point to blob storage container.blob.core.windows.net. It has blob in the url so I assumed it did.
    • David Makogon
      David Makogon over 10 years
      No. Full URI would be http(s)://yourstorage.blob.core.windows.net/yourcontainer/yo‌​urblob.vhd.
  • David Makogon
    David Makogon over 10 years
    Right: -MediaLocation allows you to specify a blob URI to store the disk in, which can be in a different storage account than your virtual machine. Combine that with -CreateNew to build a new data disk, vs. specifying an existing disk.
  • NullReference
    NullReference over 10 years
    @DavidMakogon I've never used powershell with an azure vm. Does that mean I need to have Windows Azure Management Cmdlets installed on the vm to run the command on it, or am I running the cmdlets locally?
  • mcollier
    mcollier over 10 years
    You'd run the cmdlet locally. This essentially makes a call to the Windows Azure service management API, instructing Windows Azure to attach the desired data disk to the specified VM.
  • NullReference
    NullReference over 10 years
    Do you happen to know how to create an empty blob vhd? The azure admin website doesn't give that option.
  • mcollier
    mcollier over 10 years
    I believe you could create a VHD using Disk Management on your local PC. Create the VHD file and then upload to Windows Azure blob storage. Then you should be able to use the -MediaLocation property to reference that VHD file.