我有一个英雄 PowerShell 脚本,它尝试连接到 Azure:
$username = "asdfasdf"
$password = "asdfasdf"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
Add-AzureAccount -Credential $cred
Select-AzureSubscription -SubscriptionId asdfasdf
但我收到此错误:
Add-AzureAccount : user_realm_discovery_failed: User realm discovery failed: Unable to connect to the remote
server
At line:6 char:1
+ Add-AzureAccount -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount
我的用户绝对是 Azure 目录的共同管理员。我是否必须使用代理才能与 Azure 通信?
最佳答案
嗯,由于多种原因,这似乎是一个常见错误。尝试连接到服务结构时,我的用户名格式错误并收到错误:
user_realm_discovery_failed: User realm discovery failed
即somedomain\fred
应该是<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ff9edfafbdfecf0f2fafbf0f2fef6f1b1fcf0f2" rel="noreferrer noopener nofollow">[email protected]</a>
.
一旦我纠正它,它就工作得很好。因此,鉴于上述答案,此错误似乎是由于连接或身份验证问题而出现的。
关于powershell - 添加-AzureAccount : user_realm_discovery_failed: User realm discovery failed: Unable to connect to the remote,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41572583/