2017-08-09 16 views
2

我使用我的個人電子郵件ID(這是一個Gmail ID)創建了一個「免費試用」帳戶。我發現了錯誤:Add-AzureRmAccount:序列不包含元素(也不適用於Gmail帳戶)

Add-AzureRmAccount : Sequence contains no elements At line:1 char:1 + Add-AzureRmAccount -Credential $cred + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Add-AzureRmAccount], AadAuthenticationFailedException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.AddAzureRMAccountCommand

我跑的代碼是

$username = "[email protected]" 
$password = "something" 

$secpass = $password | ConvertTo-SecureString -AsPlainText -Force 
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secpass 

Add-AzureRmAccount -Credential $cred 

是否有某種類型的其中記錄在這樣應該工作賬戶/訂閱?

回答

1

Windows Live ID憑據不能用於非交互式登錄。此錯誤消息被描述爲this issue的一部分,因爲它需要改進而引起了此問題。

我認爲你要麼需要使用Login-AzureRmAccount交互式登錄或登錄創建一個服務主體,按照該指南:https://docs.microsoft.com/en-us/powershell/azure/authenticate-azureps?view=azurermps-4.2.0

Log in with a service principal

Service principals provide a way for you to create non-interactive accounts that you can use to manipulate resources. Service principals are like user accounts to which you can apply rules using Azure Active Directory. By granting the minimum permissions needed to a service principal, you can ensure your automation scripts are even more secure.

  1. If you don't already have a service principal, create one .

  2. Log in with the service principal:

    Login-AzureRmAccount -ServicePrincipal -ApplicationId "http://my-app" -Credential $pscredential -TenantId $tenantid 
    
+0

感謝您的快速響應馬克! 只是爲了澄清,使用Gmail帳戶計爲使用Windows Live ID憑據? – datathief

+0

是的,您可以使用任何電子郵件地址創建Windows Live ID afaik。 –

+0

如果您還可以瞭解允許非交互式登錄的帳戶類型以及我如何創建帳戶,那將會很棒。 – datathief

相關問題