使用powershell链接到Azure

一:针对传统的的Azure 的登陆界面: (ASM)

1. 正常来说是 现在本地创建证书文件,然后上传文件,以便本地计算机和Azure建立可靠的安全连接

Get-AzurePublishSettingsFile -Environment AzureChinaCloud  <国内世纪互联版本>

Get-AzurePublishSettingsFile -Environment "AzureCloud"    <国际版本>

Import-AzurePublishSettingsFile <PathToFile>


2.也可以:
Add-AzureAccount -Environment AzureChinaCloud  -<国内世纪互联>

Add-AzureAccount  <国际版本>

在弹出的窗口输入账号和密码直接创建本地到Azure 的一个安全连接

二: 针对目前的新的portal界面,(ARM)

请使用 Azure PowerShell 指南中的说明安装 Azure PowerShell,然后运行 Login-AzureRmAccount -EnvironmentName AzureChinaCloud 创建与 Azure 的连接。 此外,用户配置文件的 .ssh 目录中需具备名为 id_rsa.pub 的 SSH 公钥。 

Add-AzureRmAccount -EnvironmentName AzureChinaCloud

#This is For Azure China All Powershell command

$userName = "[YourUserName]"
$securePassword = ConvertTo-SecureString -String "[YourPassword]" -AsPlainText -Force

$cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword)
Add-AzureAccount -Credential $cred -Environment AzureChinaCloud
Get-AzureSubscription

原文地址:https://www.cnblogs.com/junjiany/p/6062715.html