3

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.

3

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}" 

Example

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:

$appID="bca24913-026d-4020-b9f1-add600bf9045"
$password="******"
$tenant="*******"
az login --service-principal -u $appID --password $password --tenant $tenant

More information about this please refer to this link.

1

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

https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli

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.