When I try to login using azure cli by providing username and password. I get error

az login -u myemail@email.com -p plaintextpassword

The user name might be invalid. For cross-check, try 'az login' to authenticate through browser.

When I use browser authentication method with the same username and password I am able to login. Using this process I get the option of "Work or school account" or "personal account". I select "work or school account" and enter my credentials. Is there a way to select this using command line option.

2 Answers 2


When your account is Microsoft account(such as *@outlook.com, *@hotmail.com), you will get the error log. The root reason is Microsoft account does not support non-interactive login. It is also unsafe for you to login Azure with your account directly.

If you plan to manage your app or service with Azure CLI 2.0, you should run it under an Azure Active Directory (AAD) service principal rather than your own credentials. Please refer to the following steps to create service principal.

1.Login to Azure.

2.Use az ad sp create-for-rbac to create the service principal.

az ad sp create-for-rbac --name {appId} --password "{strong password}" 


az ad sp create-for-rbac --name shuiexample --password "Password012!!" 

You could get result like below:

  "appId": "bca24913-026d-4020-b9f1-add600bf9045",
  "displayName": "shuiexample1234",
  "name": "http://shuiexample1234",
  "password": "*******",
  "tenant": "*******"

3.Sign in using the service principal using the following:

az login --service-principal -u $appID --password $password --tenant $tenant

More information about this please refer to this link.

  • 2
    I get this error : az: error: unrecognized arguments: --password ***** Jul 5, 2019 at 16:20
  • As of Azure CLI 2.0.68, the --password parameter to create a service principal with a user-defined password is no longer supported to prevent the accidental use of weak passwords.
    – user59050
    May 5, 2020 at 12:15

Is the account you are using a Microsoft account or require multifactor authentication? either of these will require interactive log-in


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.