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
1,013 views

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
• 56,160 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 in Azure by Prerna
• 1,940 points
110 views
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
302 views
+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
616 views
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
• 56,160 points
1,114 views
0 votes
1 answer

How can I replicate an Azure Virtual Machine?

To create a managed image of a ...READ MORE

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

How can I enable Ping(ICMP) on Azure?

I had a similar problem. Needed to ...READ MORE

answered Aug 17, 2018 in Azure by Priyaj
• 56,160 points
1,977 views
0 votes
2 answers

How can I add database connection string to Azure Functions?

The best way to do this is ...READ MORE

answered Aug 17, 2018 in Azure by Priyaj
• 56,160 points
2,399 views
+1 vote
10 answers

How can the NuGet packages be used in Azure Functions?

Yes! Although the Azure Functions portal does ...READ MORE

answered Jun 8, 2018 in Azure by club_seesharp
• 3,450 points
3,781 views
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
362 views
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
• 56,160 points
191 views