2017-08-16 92 views
1

當我嘗試從VS代碼終端登錄到Azure RM時,它只是掛起。沒有提示登錄/密碼顯示。從VS代碼終端登錄AzureRmAccount

有什麼方法可以從該終端登錄嗎?否則,運行/調試Azure PS腳本變得比應該更復雜:)

回答

5

登錄窗口在後臺彈出...如果您最小化所有窗口,您最終將找到它。

1

您需要等待片刻,然後才能看到登錄頁面。

根據你的描述,我建議你可以選擇非交互式登錄。您可以創建一個可以訪問資源的服務主體。請參閱此鏈接:Use portal to create an Azure Active Directory application and service principal that can access resources。你會得到clientid和客戶端的祕密。您可以使用以下代碼登錄您的Azure帳戶。

$subscriptionId="" 
$tenantid="" 
$clientid="" 
$password="" 
$userPassword = ConvertTo-SecureString -String $password -AsPlainText -Force 
$userCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $clientid, $userPassword 
Login-AzureRmAccount -TenantId $tenantid -ServicePrincipal -SubscriptionId $subscriptionId -Credential $userCredential 

enter image description here

+0

謝謝您的回答,它絕對值得使用的腳本環境服務主體。但是我會接受@ bmoore-msft的答案,因爲它更適合我的場景:) –