Windows Azure Powershell Copying file to VM

前端 未结 6 1876
隐瞒了意图╮
隐瞒了意图╮ 2021-01-02 08:25

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

6条回答
  •  孤街浪徒
    2021-01-02 09:19

    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
    

提交回复
热议问题