从VS Code终端登录AzureRm账户

10

当我尝试从VS Code终端登录Azure RM时,它就会卡住。没有显示登录/密码提示。

有没有办法从该终端登录?否则,运行/调试Azure PS脚本将比应该更复杂 :)

2个回答

27

登录窗口会在后台弹出...如果你最小化所有窗口,最终你会找到它。


2

请稍等片刻,然后您将能够看到登录页面。

根据您的描述,我建议您选择非交互式登录。您可以创建一个能够访问资源的服务主体。请参考此链接:使用门户创建可访问资源的 Azure Active Directory 应用程序和服务主体。您将获得客户端 ID 和客户端密钥。您可以使用以下代码登录 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


谢谢你的回答,使用服务主体在脚本环境中确实很值得。但我会接受 @bmoore-msft 的答案,因为它更适合我的场景 :) - the_joric

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接