標籤:windows 虛擬機器 blank target 定向
我們可以用Windows Azure PowerShell來管理Windows Azure虛擬機器。接下來我們來看下如何使用Windows Azure PowerShell建立和刪除虛擬機器。
1.擷取虛擬機器鏡像。Get-AzureVMImage 這個命令可以返回虛擬機器鏡像列表,由於現在Azure當中的鏡像非常多,運行該命令時最好將通過管道重新導向到txt檔案中,以便查看。另外因我們後面用New-AzureQuickVM命令建立虛擬機器時只需要知道鏡像的名稱,因此在執行Get-AzureVMImage 加上 管道篩選出ImageName即可。如
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/8C/34/wKiom1hk7LaDuQuaAAA8lawFuOc295.png" "644" height="65" />
2.擷取Azure地區。Get-AzureLocation,同樣我們只需要知道displayname,通過管道篩選displayname即可。
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/8C/34/wKiom1hk7LfgTnGIAACJcPlAi8A341.png" "644" height="197" />
3.New-AzureQuickVM建立虛擬機器。
在PowerShell中依次執行以下命令
PS C:\Users\huangcj> $image = "55bc2b193643443bb879a78bda516fc8__Windows-Server-2012-Datacenter-20161214-zh.cn-127GB.vhd
"
PS C:\Users\huangcj> $location = Get-AzureLocation
PS C:\Users\huangcj> $svcname = "hcjtest"
PS C:\Users\huangcj> $admpass = "abc;123456"
PS C:\Users\huangcj> New-AzureQuickVM -Windows -InstanceSize "Large" -ServiceName $svcname -Name "hcjt5" -ImageName $ima
ge -Password $admpass -AdminUsername "huangcj" -Location $location[0].name
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/8C/31/wKioL1hk7LjD2lseAAGZTPpcbSY641.png" "644" height="166" />
$location[0].name 為China East 即上海資料中心,$location[1].name為China North 即北京資料中心。
執行完後,我們到Azure Portal中可以看到建立好的虛擬機器.
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/8C/35/wKiom1hk7LnTT0waAABA2gibDac412.png" "644" height="111" />
4.刪除虛擬機器 Remove-AzureVM
刪除命名比較簡單,見
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/8C/31/wKioL1hk7LnTwznWAAA2xE3msVs017.png" "644" height="133" />
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/8C/31/wKioL1hk7LqD6hyZAACIEL84Rn8856.png" "644" height="138" />
以上的命令並沒有刪除硬碟vhd檔案,如果要刪除則在後面加上參數 –DeleteVHD
Windows Azure PowerShell之管理虛擬機器