Login-AzureRmAccount from VS Code terminal

2019-04-21 20:11发布

When I try to login to Azure RM from VS Code terminal it just hangs. No prompt with login / password is shown.

Is there any way to get logged in from that terminal? Otherwise running / debugging Azure PS scripts becomes more complicated than it should be :)

2条回答
地球回转人心会变
2楼-- · 2019-04-21 21:12

The login window pops-up in the background... if you minimize all your windows you'll eventually find it.

查看更多
成全新的幸福
3楼-- · 2019-04-21 21:13

You need to wait for a moment, then you could see the login page.

According to your description, I suggest you could select Non-interactive login. You could create a service principal that can access resource. Please refer to this link:Use portal to create an Azure Active Directory application and service principal that can access resources. You will get clientid and client secret. You could use the following code to login your Azure account.

$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

查看更多
登录 后发表回答