One of the great features of Windows Azure is VHD mobility. Simply put it means you can upload and download VHDs to and from the cloud.


Note: If you are used to using CSUpload.exe for uploading VHDs you should switch to PowerShell. CSUpload.exe has been marked as deprecated and will likely not ship in future SDKs.

Technical Notes

A few things to point out while I’m here. Currently, Windows Azure only supports the VHD file format in a fixed disk format.
That being said the Add-AzureVHD cmdlet supports converting a dynamic VHD on upload to a fixed VHD so you do not have to worry about converting them up front.

Also, both the Add-AzureVHD and Save-AzureVHD cmdlets have intrinsic knowledge of the VHD file format and during upload or download only copy the written bytes and skip the empty. This is a huge optimization!

So let’s jump right in using PowerShell. This page assumes your PowerShell client is already setup to access your Windows Azure subscription. If this is not the case read through the Getting Started with Windows Azure PowerShell Cmdlets first.

Uploading a VHD

  1. import-module azure
  2. select-azuresubscription "mysubscriptionname"
  3.  
  4. $sourceVHD = "D:\StorageDemos\myvhd.vhd"
  5. $destinationVHD = "https://mwwestus1.blob.core.windows.net/uploads/myvhd.vhd"
  6.  
  7. Add-AzureVhd -LocalFilePath $sourceVHD -Destination $destinationVHD `
  8. -NumberOfUploaderThreads 5

As you can see the code to upload a VHD to your Windows Azure Storage Account is pretty simple.

To make the VHD usable you need to register it with Windows Azure.

Register VHD as a Data Disk

  1. # Register as a plan old data disk
  2. Add-AzureDisk -DiskName 'mydatadisk' -MediaLocation $destinationVHD `
  3. -Label 'mydatadisk'

When the code above is run the uploaded VHD will be registered in Windows Azure as a data disk named ‘mydatadisk’. Refresh the portal and you will see it in the Disks list and it will also be available for attaching to a virtual machine.

If you are uploading a VHD with an operating system on it you need to tell that to Windows Azure.

Register VHD as an OS Disk

This code registers the disk as bootable. Meaning you can now create a virtual machine and specify this disk as the boot disk.

  1. # Register as a plan old data disk
  2. Add-AzureDisk -DiskName 'myosdisk' -MediaLocation $destinationVHD `
  3. -Label 'myosdisk' -OS Windows # or Linux

Creating a VM from uploaded VHDs

As I mentioned above you can specify a disk to boot from instead of provisioning from an image. The PowerShell code to do so is simple. You can of course add disks and endpoints in between New-AzureVMConfig and New-AzureVM as well.

  1. New-AzureVMConfig -DiskName 'myosdisk' -Name 'myvm1' -InstanceSize Small |
  2. Add-AzureDataDisk -Import -DiskName 'mydatadisk' -LUN 0 |
  3. New-AzureVM -ServiceName 'mycloudsvc' -Location 'West US'

Now that you have seen how to upload VHD’s to the cloud let’s walk through the equally simple download process.

Downloading a VHD from Windows Azure

The same pattern as Add-AzureVHD just reversed!

  1. select-azuresubscription "mysubscriptionname"
  2.  
  3. $sourceVHD = "https://mwwestus1.blob.core.windows.net/uploads/mydatadisk.vhd"
  4. $destinationVHD = "D:\StorageDemos\mydatadisk-downloaded.vhd"
  5.  
  6. Save-AzureVhd -Source $sourceVHD -LocalFilePath $destinationVHD `
  7. -NumberOfThreads 5

That’s it! Uploading and downloading VHDs to Windows Azure is fast and simple.

Windows Azure 上传 VM的更多相关文章

  1. Windows Azure 上 Linux VM 中的交换空间 – 第 2 部分

    本文章由 Azure CAT 团队的 Piyush Ranjan (MSFT) 撰写. 在前一篇文章 Windows Azure 上Linux VM 中的交换空间第 1 部分中,我介绍了在默认情况下, ...

  2. 在Windows Azure上配置VM主备切换(1)——Linux篇

    对任何一个上线系统来说,高可用设计是不可或缺的一个环节,这样才可以确保应用可以持续.稳定的运行,而不是频繁的掉线.停机.高可用设计的核心思路很简单,就是消除一切单点故障,将单点链路或者节点升级为多点. ...

  3. 在 Windows Azure 上部署预配置 Oracle VM

    Microsoft 和 Oracle 近期宣布建立战略合作伙伴关系,基于此,我们将通过 Windows Azure 镜像库推出多种常用的 Oracle 软件配置.即日起,客户可以在 Windows S ...

  4. 如何将SQL Server运行到Windows Azure上

    从2012年6月6日开始,Windows Azure上一些强大的新功能现在可用于预览,包括新的Windows Azure虚拟机(VM).其中有关Windows Azure虚拟机最强大的一件事是他们利用 ...

  5. 在 Windows Azure 上部署并定制化 FreeBSD 虚拟机镜像

     发布于 2014-12-11 作者 陈阳 FreeBSD 基础镜像现已登陆中国的 VM Depot! 对于青睐 BSD 而非 Linux 的开源爱好者来说,这无疑是个好消息.同时,随着该基础镜像 ...

  6. 在 Windows Azure 上设计多租户应用程序

    作者:Suren Machiraju 和 Ralph Squillace 审校:Christian Martinez.James Podgorski.Valery Mizonov 和 Michael ...

  7. azure 上传blob到ams(CreateFromBlob)

    遇到的错误:The destination storage credentials must contain the account key credentials,参数名: destinationS ...

  8. Windows Azure 上的 Symfony,适用于 PHP 开发者的强大组合

     发布于 2014-06-13 作者 陈 忠岳 Symfony 是针对 PHP 开发者的流行开源 Web 应用框架.现在,您可以更轻松地在 Windows Azure 上使用它,这都归功于 Ben ...

  9. 快速学习使用 Windows Azure 上的 SharePoint Server 2013

     为了在当今的企业环境中占据一席之地,您需要能够迅速顺应变化和应对挑战.有时,需要及时调整您的SharePoint 基础结构以保持竞争优势. 基础结构即服务可通过随时使用.即付即用的解决方案应对这 ...

随机推荐

  1. HBase Snapshot功能介绍

    HBase在0.94之后提供了Snapshot功能,一个snapshot其实就是一组metadata信息的集合,它可以让管理员将表恢复到以前的一个状态.snapshot并不是一份拷贝,它只是一个文件名 ...

  2. On Caching and Evangelizing SQL

    http://www.oracle.com/technetwork/issue-archive/2011/11-sep/o51asktom-453438.html   Our technologist ...

  3. access里like的通配符不能用%,要用*

    转自http://www.knowsky.com/339881.html access里like的通配符用法是这样:     “?”表示任何单一字符: “*”表示零个或多个字符: “#”表示任何一个数 ...

  4. Eclipse项目名出现红叉

    一.背景与原因 项目第一次加进来的时候,我用的是D:\Java\jdk1.7.0_17,后来由于配置将tomcat切换到jboss,说是JBOSS某个版本只支持jdk6,我就将“环境变量JAVA_HO ...

  5. 一起Polyfill系列:Function.prototype.bind的四个阶段

    昨天边参考es5-shim边自己实现Function.prototype.bind,发现有不少以前忽视了的地方,这里就作为一个小总结吧. 一.Function.prototype.bind的作用 其实 ...

  6. Lambda表达式和匿名内部类(I)

    本文git地址 前言 Java Labmda表达式的一个重要用法是简化某些匿名内部类(Anonymous Classes)的写法.实际上Lambda表达式并不仅仅是匿名内部类的语法糖,JVM内部是通过 ...

  7. Mybatis 示例之 foreach

    foreach一共有三种类型,分别为List,[](array),Map三种. foreach的第一篇用来将List和数组(array). 下面表格是我总结的各个属性的用途和注意点. foreach属 ...

  8. LeetCode - 31. Next Permutation

    31. Next Permutation Problem's Link ---------------------------------------------------------------- ...

  9. CSS浏览器兼容性写法小结

    *        , ie6,ie7可以识别: _和- ,  ie6可以识别: !important  ,表示高优先级,ie7及以上,firefox都支持,ie6认识带!important的样式属性, ...

  10. 批处理安装Windows服务,提示"InstallUtil.exe"不是内部命令也不是外部命令解决方式

    今天在测试一个C#写的windows服务的时候,在用bat进行调用cmd安装的时候, cd C:\Windows\Microsoft.NET\Framework\v2.0.50727 InstallU ...