2017-08-16 100 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的答案,因为它更适合我的场景:) –