代码改变世界

使用Windows Azure PowerShell远程管理Windows Azure虚拟机

2014-07-10 11:23  马伟  阅读(822)  评论(0编辑  收藏  举报

对于Windows Azure,如果你还在使用windowsazure.com门户来管理虚拟机,那就显得不怎么高上大了。Windows Azure PowerShell 是一个功能强大的脚本环境,可用于在 Windows Azure 中控制和自动执行工作负荷的部署和管理。

  安  装  

通过Microsoft Web Platform Installer一键搞定安装。

  登录Azure账户  

启动安装好的Windows Azure PowerShell,使用“Add-AzureAccount” 命令来登录你的Windows Azure账户,如下图:

 如果你有多个订阅,可以通过“Select-AzureSubscription”命令进行设置,如下图:

启动、停止以及重新启动Windows Azure虚拟机

Windows Azure PowerShell Cmdlet 支持使用 Restart-AzureVM、Stop-AzureVM 和 Start-AzureVM 命令执行重新启动、停止和启动虚拟机操作,其格式如下:

Restart-AzureVM -ServiceName $cloudSvcName -Name $vmname 

Stop-AzureVM -ServiceName $cloudSvcName -Name $vmname 

Start-AzureVM -ServiceName $cloudSvcName -Name $vmname

其中,“-ServiceName $cloudSvcName”表示云服务的名称,“-Name $vmname” 虚拟机的名称。例如,使用“Stop-AzureVM ”命令来关闭一台虚拟机,如下图:

使用“Start-AzureVM” 命令来启动一台虚拟机,如下图:

其他命令,请查看相关帮助。