Can I Login without prompt in Azure?

0 votes

Actually, I tried the below commands inorder to get a no-prompt login scenario, but every time, i am getting login popup. 
I also tried to use a certificate, but didn't work too. Even when tried to use tenat ID. 
 Can someone suggest me how to get a faster no-login prompt experience?

Login-AzureRmAccount -SubscriptionId XXXX -TenantId XXXX

Add-AzureRmAccount -Tenant "XXXX" -SubscriptionId "XXXX"

Login-AzureRmAccount -TenantId XXX

May 9, 2018 in Azure by null_void
• 3,220 points

2 answers to this question.

0 votes

There is a simple way of acheiving this. You can try the below steps:

> Login to your azure account with command: Login-AzureRmAccount
> Save the context in a Json file using command: Save-AzureRmContext -Path "E:\AzureProfile.json"
> Now, you can login without prompt using command: Import-AzureRmContext -Path "E:\AzureProfile.json"

answered May 9, 2018 by club_seesharp
• 3,450 points
0 votes

You can use -Credential parameter, and DPAPI to login.

First, run the following PowerShell once to store a secured password for your account.

Read-Host "Enter Password" -AsSecureString | ConvertTo-SecureString `
-AsPlainText -Force | ConvertFrom-SecureString | Out-File "C:\Password.txt"

And then, you can use the following script to login.

# The azure account here must not be a Live ID.
$username = "<your Azure account>"
$SecurePassword = Get-Content "C:\Password.txt" | ConvertTo-SecureString
$cred = new-object -typename System.Management.Automation.PSCredential `
     -argumentlist $username, $SecurePassword

Login-AzureRmAccount -Credential $cred

An other way would be using Service Principal. First, you should follow the article to create a Service Principal

And then, use the following script to login.

$clientID = "<the client id of your AD Application>"
$key = "<the key of your AD Application>"
$SecurePassword = $key | ConvertTo-SecureString -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential `
     -argumentlist $clientID, $SecurePassword
$tenantID = "<the tenant id of your subscription>"

Add-AzureRmAccount -Credential $cred -TenantId $tenantID -ServicePrincipal
answered Aug 17, 2018 by Priyaj
• 57,530 points

Related Questions In Azure

0 votes
1 answer

Can I use an appsettings.json file in Azure Functions?

Only environment variables are supported for app ...READ MORE

answered Apr 24, 2019 in Azure by p
• 1,940 points
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
4 answers

How can I rename a SQL Azure database?

This command serves the purpose ALTER DATABASE [oldname] ...READ MORE

answered Nov 30, 2018 in Azure by Abhinav
+1 vote
1 answer

Can I rename a Azure Storage Blob?

Though the approach I'm about to share ...READ MORE

answered May 10, 2018 in Azure by club_seesharp
• 3,450 points
0 votes
2 answers

How can I download a .vhd image to my local machine from azure and upload the same to a different azure account?

From the Windows Azure Portal you can ...READ MORE

answered Aug 20, 2018 in Azure by Priyaj
• 57,530 points
0 votes
1 answer

How can I remove/hide/disable excessive HTTP response headers in Azure/IIS7 without having to use UrlScan?

MSDN published an article on how to ...READ MORE

answered May 21, 2018 in Azure by club_seesharp
• 3,450 points
0 votes
2 answers

How can I view the deployed files in Azure?

In Visual Studio, in the window "Server ...READ MORE

answered Aug 21, 2018 in Azure by Priyaj
• 57,530 points