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

import-module azure
select-azuresubscription "mysubscriptionname"
 
$sourceVHD = "D:\StorageDemos\myvhd.vhd"
$destinationVHD = "https://mwwestus1.blob.core.windows.net/uploads/myvhd.vhd"
 
Add-AzureVhd -LocalFilePath $sourceVHD -Destination $destinationVHD `
-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

# Register as a plan old data disk
Add-AzureDisk -DiskName 'mydatadisk' -MediaLocation $destinationVHD `
-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.

# Register as a plan old data disk
Add-AzureDisk -DiskName 'myosdisk' -MediaLocation $destinationVHD `
-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.

New-AzureVMConfig -DiskName 'myosdisk' -Name 'myvm1' -InstanceSize Small |
Add-AzureDataDisk -Import -DiskName 'mydatadisk' -LUN 0 |
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!

select-azuresubscription "mysubscriptionname"
 
$sourceVHD = "https://mwwestus1.blob.core.windows.net/uploads/mydatadisk.vhd"
$destinationVHD = "D:\StorageDemos\mydatadisk-downloaded.vhd"
 
Save-AzureVhd -Source $sourceVHD -LocalFilePath $destinationVHD `
-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. SupportV7包中 SwipeRefreshLayout 修改下拉控件的距离

    //修改下拉距离 ViewTreeObserver vto = mCategoryResults.mSwipeRefreshLayout.getViewTreeObserver(); vto.addO ...

  2. jQuery---EasyUI小案列

    jQuery EasyUI为提供了大多数UI控件的使用,如:accordion,combobox,menu,dialog,tabs,validatebox,datagrid,window,tree等等 ...

  3. H5+CSS3实现手指滑动切换图片

    包含3个文件:html.slider-H5.js.jquery.js(自行下载).在html中可配置滑动参数.具体代码如下: HTML代码: <!DOCTYPE HTML> <htm ...

  4. winform 指定浏览器打开链接

      Process myProcess = new Process();   myProcess.StartInfo.FileName = "firefox.exe";//&quo ...

  5. Python 闭包

    什么是闭包? 闭包(closure)是词法闭包(lexical closure)的简称.闭包不是新奇的概念,而是早在高级程序语言开始发展的年代就已产生. 对闭包的理解大致分为两类,将闭包视为函数或者是 ...

  6. 自定义一个叫 ReadOnlyXmlMembershipProvider 的 MembershipProvider,用 XML 作为用户储藏室

    1. 配置 web.config <membership defaultProvider="AspNetReadOnlyXmlMembershipProvider"> ...

  7. AutoMapper用法一瞥

    前段时候做个小项目用到了autoMapper(参考了NOP里的用法),感觉还行,用起来挺方便的.首先复杂的东西我就不说了,至于详细的教程我也就不写了,比较园子里有很多这样的文章,我就分享下,在项目中实 ...

  8. android 代码控制控件的长宽,小技巧

    要在代码里改变ImageView 的长宽,如图 通过拿到contentImage这对象的控件参数,再去改变,再设置 , 上图的contentImage为ImageView对象: 而这里 要提醒的是,L ...

  9. Lo-Dash – 替代 Underscore 的优秀 JS 工具库

    前端开发人员大都喜欢 Underscore,它的工具函数很实用,用法简单.这里给大家推荐另外一个功能更全面的 JavaScript 工具——Lo-Dash,帮助你更好的开发网站和 Web 应用程序. ...

  10. Android 学习笔记之如何使用SQLite数据库来保存数据...

    PS:最近一阵子都在为考试复习...坑爹的计算机网络,复习了3天,最后该不会的还是不会...明天还考英语...真蛋疼... 学习内容: 1.使用SQLite数据库来保存数据... SQLite:   ...