Azure / Azure/azure-cli

Issues with az login when your email address has both an Entra ID and a MS account tied to it

Open
#31,156 4 comments 0 reactions 1 assignee Claimed by @jiasli View on GitHub
Account act-identity-squad Auto-Assign Auto-Resolve Azure CLI Team customer-reported Possible-Solution question Similar-Issue
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

I originally hosted my domains email (pre-Exchange Online) using MS Small business server. At that time we were able to use those email addresses to create MS accounts (for services like OneDrive\Messenger\..other MS services).
Then I migrated my systems to Azure. Probably a couple years after that, no new mailbox tied to our domain can be used to make a new MS account.

If I try to use any new email address from our domain this is the error:
**Create account**
You can't sign up here with a work or school email address. Use a personal email, such as Gmail or Yahoo!, or get a new Outlook email.

So now, here is my issue....
When I am using **az login** the UI to select which account I want to use comes up properly.
The auth works properly as well.

However, the problem then is PowerShell errors with:
**Found multiple accounts with the same username**

I can see the 2 accounts tied to the same email address. however, the end of each account shows the difference.
one ends with:

1. 'realm': '77b1a388-5gws-492g-ga42-64wfa087g04a'},
2. 'realm': 'organizations'}]

In the #1 bullet above I changed the characters for privacy.

I got the URL within PowerShell to report this here:
**Please report to us via Github: https://github.com/Azure/azure-cli/issues/20168**

### Related command

az login

### Errors

You can't sign up here with a work or school email address. Use a personal email, such as Gmail or Yahoo!, or get a new Outlook email.

### Issue script & Debug output

cli.azure.cli.core.azclierror: Found multiple accounts with the same username 'john.doe@microsoft.com': [{'home_account_id': '2892c001-fae1-44d7-988e-4407b35d70b9.4c6414b7-e019-4b42-b37f-795af00707d5', 'environment': 'login.microsoftonline.com', 'username': 'john.doe@microsoft.com', 'account_source': 'broker', 'authority_type': 'MSSTS', 'local_account_id': '71d92c9d-9ec1-4ffc-9f68-912fe441ac18', 'realm': '77a1b388-5acf-492b-bf42-64cbb087d04c'}, {'home_account_id': '00000000-0000-0000-6cae-0abe7c6aaad1.9188040d-6c67-4c5b-b112-36a304b66dad', 'environment': 'login.microsoftonline.com', 'username': 'john.doe@microsoft.com', 'account_source': 'broker', 'authority_type': 'MSSTS', 'local_account_id': '00000000-0000-0000-6cae-0abe7c6aaad1.9188040d-6c67-4c5b-b112-36a304b66dad.f8cdef31-a31e-4b4a-93e4-5f571e91255a', 'realm': 'organizations'}]
Please report to us via Github: https://github.com/Azure/azure-cli/issues/20168
az_command_data_logger: Found multiple accounts with the same username 'john.doe@microsoft.com': [{'home_account_id': '2892c001-fae1-44d7-988e-4407b35d70b9.4c6414b7-e019-4b42-b37f-795af00707d5', 'environment': 'login.microsoftonline.com', 'username': 'john.doe@microsoft.com', 'account_source': 'broker', 'authority_type': 'MSSTS', 'local_account_id': '71d92c9d-9ec1-4ffc-9f68-912fe441ac18', 'realm': '77a1b388-5acf-492b-bf42-64cbb087d04c'}, {'home_account_id': '00000000-0000-0000-6cae-0abe7c6aaad1.9188040d-6c67-4c5b-b112-36a304b66dad', 'environment': 'login.microsoftonline.com', 'username': 'john.doe@microsoft.com', 'account_source': 'broker', 'authority_type': 'MSSTS', 'local_account_id': '00000000-0000-0000-6cae-0abe7c6aaad1.9188040d-6c67-4c5b-b112-36a304b66dad.f8cdef31-a31e-4b4a-93e4-5f571e91255a', 'realm': 'organizations'}]
Please report to us via Github: https://github.com/Azure/azure-cli/issues/20168

### Expected behavior

the account selected through the UI actually gets used/referenced within PowerShell

### Environment Summary

PS C:\Users\tima> az version
{
"azure-cli": "2.63.0",
"azure-cli-core": "2.63.0",
"azure-cli-telemetry": "1.1.0",
"extensions": {
"ssh": "2.0.6",
"stack-hci-vm": "1.4.3"
}
}

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.