Wednesday 25 January 2017

MS Azure : Log in and Log out to Azure from the Azure CLI

Log in to Azure


Scenario 1: Azure login with interactive Login
Interactive login is easy: type azure login -- without any options -- as shown in the following example:
azure login
The output appears something like the following:

info:    Executing command login
info:    To sign in, use a web browser to open the page http://aka.ms/devicelogin.
Enter the code XXXXX to authenticate.



Copy the code offered to you in the command output, and open a browser to http://aka.ms/devicelogin, or other page if specified. (You can open a browser on the same computer, or on a different computer or device.) Enter the code, and then you are prompted to enter the username and password for the identity you want to use.


When that process completes, the command shell completes the login. It might look something like:

info:    Added subscription Visual Studio Ultimate with MSDN
info:    Added subscription Azure Free Trial
info:    Setting subscription "Visual Studio Ultimate with MSDN" as default
+
info:    login command OK



Note: With interactive login, authentication and authorization are performed using Azure Active Directory. If you use a Microsoft account identity, the login process accesses your Azure Active Directory default domain. (If you signed up for a free Azure account, Azure Active Directory automatically created a default domain for your account.)

Scenario 2: azure login with a username and password
Use the azure login command with the username (-u) parameter to authenticate when you want to use a work or school account that doesn't require multifactor authentication. You are prompted at the command line for the password (or you can optionally pass the password as an additional parameter of the azure login command). The following example passes the username of an organizational account:
azure login -u Username@mysite.microsoft.com

You are then prompted to enter your password:
info:    Executing command login
Password: *********

The login process then completes.
info:    Added subscription Visual Studio Ultimate with MSDN
+
info:    login command OK

If this is your first time logging in with these credentials, you are asked to verify that you wish to cache an authentication token. This prompt also occurs if you previously used the azure logout command (described later in the article). To bypass this prompt for automation scenarios, run azure login with the -q parameter.

Once you are connected, enter azure it will take you to azure welcome screen as below:

Log out from Azure


To log out, use the following command:
azure logout -u 

5 comments:

  1. Thanks for posting the useful information to my vision. This is excellent information.
    MS Azure Online Training

    ReplyDelete
  2. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing

    Power BI Training In Hyderabad
    Power BI Online Training
    Power BI Training In Ameerpet

    ReplyDelete
  3. Nice Article!

    Thanks for sharing with us 🙂

    React Training in Hyderabad

    ReplyDelete