Connect-AzureRmAccount - 无法连接到 Azure

Connect-AzureRmAccount - Cannot connect to Azure

尝试从 Powershell 连接 Azure 时出现以下错误:

PS H:\> Connect-AzureRmAccount
Connect-AzureRmAccount : An error occurred while sending the request.
At line:1 char:1
+ Connect-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzureRmAccount], HttpRequestException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

有几件事要尝试:

有时,powershell cmdlet 不会给出正确的错误消息,因为它会抑制它,要获取实际错误,您可以尝试使用 -debug 属性执行,或者您可以尝试使用如下所示的 DebugPreference

$DebugPreference = "Continue"
Write-Debug -Message "Hello, World"

或者,Connect-AzureRMAccount cmdlet 默认使用 TLS 1.0 连接到 Azure,有时它会被组织安全策略阻止,

你能设置类似下面的东西吗:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

附加参考:

希望对您有所帮助。