PowerShell可以实现所有的Azure管理功能,Portal上能做的Powershell也能做,PowerShell还能做Portal无法做的事情,比如创建DS系列虚拟机。

本文先介绍Windows Azure PowerShell的环境准备工作。

1. 从官网下载页面,下载并安装Windows Azure PowerShell: http://www.windowsazure.cn/zh-cn/downloads/#cmd-line-tools

2. 安装完毕后以管理员身份运行,右键点击PowerShell图标然后选择以管理员身份运行;

3. 设置执行策略。作为一个安全性的测试,PowerShell的执行策略定义了在脚本和文件满足何种条件的前提下才能执行。例如,您可以指定只允许经过签名的脚本,以免错误运行攻击性的脚本。Windows Azure Powershell命令集需要执行策略为RemoteSigned、Unrestricted或者Bypass。要设置执行策略,应以管理员身份运行Windows AzurePowershell,然后通过Set-ExecutionPolicy命令来设置,见下图。

Windows Azure PowerShell之环境准备_blank

4. 执行命令Get-AzurePublishSettingsFile -Environment "AzureChinaCloud",执行完该命令后会打开azure页面,输入用户名密码后登陆azure下载您的Windows Azure Subscription的发布配置文件;

Windows Azure PowerShell之环境准备_下载页面_02

下载发布配置文件

Windows Azure PowerShell之环境准备_target_03

5. 在PowerShell中执行Import-AzurePublishSettingsFile “发布配置文件本地存放路径”;

Windows Azure PowerShell之环境准备_Windows_04

至此环境准备完成。