Windows Azure Powershell Copying file to VM

Syed Farabi picture Syed Farabi · Aug 5, 2013 · Viewed 14.4k times · Source

I am trying to use Windows Azure PowerShell to copy a zip file into VM. I have managed to connect to VM following the documentation.

But, I cannot find any tutorial to upload / copy / transfer a zip file to VM Disk, say into the C drive.

Can any one please help me giving any link for the tutorial or any idea how can I copy this?

Answer

Matt Wrock picture Matt Wrock · Sep 12, 2013

Here is ano ther approach that I documented here. It involves

  1. Creating and mounting an empty local VHD.
  2. Copying your files to the new VHD and dismount it.
  3. Copy the VHD to azure blob storage
  4. Attach that VHD to your VM.

Here is an example:

#Create and mount a new local VHD
$volume = new-vhd -Path test.vhd -SizeBytes 50MB | `
  Mount-VHD -PassThru | `
  Initialize-Disk -PartitionStyle mbr -Confirm:$false -PassThru | `
  New-Partition -UseMaximumSize -AssignDriveLetter -MbrType IFS | `
  Format-Volume -NewFileSystemLabel "VHD" -Confirm:$false

#Copy my files  
Copy-Item C:\dev\boxstarter "$($volume.DriveLetter):\" -Recurse
Dismount-VHD test.vhd

#upload the Vhd to azure
Add-AzureVhd -Destination http://mystorageacct.blob.core.windows.net/vhdstore/test.vhd `
  -LocalFilePath test.vhd

#mount the VHD to my VM
Get-AzureVM MyCloudService MyVMName | `
  Add-AzureDataDisk -ImportFrom `
  -MediaLocation "http://mystorageacct.blob.core.windows.net/vhdstore/test.vhd" `
  -DiskLabel "boxstarter" -LUN 0 | `
  Update-AzureVM