Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 2.99k forks source link

Found multiple accounts with same username #20168

Open dylankdreyer78 opened 3 years ago

dylankdreyer78 commented 3 years ago

When trying to log in using the CLI I get this error:

image

I have obviously made a mess of things here but I don't know how to sort this out now :/

Any ideas?

HenriKoelewijn commented 1 year ago

I had this issue too. Used az config set core.token_encryption=false az login

and followed the directions that were printed in the browser. That worked.

sarveswarreddy commented 1 year ago

You can cleanup one of the entries of the same account in the json file under your home directory ".azure/azureProfile.json" It solved the issue for me..

aaltotsky commented 1 year ago

I experienced the same issue. I do have 2 accounts with the same email name. One "Personal" and another "Work". The personal account has access to the correct subscription. It worked fine before until today. Here is the information about the az version:

C:\Users\master>az --version
azure-cli                         2.49.0

core                              2.49.0
telemetry                          1.0.8

Extensions:
containerapp                      0.3.33

Dependencies:
msal                              1.20.0
azure-mgmt-resource               22.0.0

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\master\.azure\cliextensions'

Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb  7 2023, 17:05:00) [MSC v.1929 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

I tried all the above suggestions - nothing is working for me. I tried to signup directly with az login -u johndoe@contoso.com -p VerySecret - same result.

I would appreciate any help.

aaltotsky commented 1 year ago

I found a solution.

Use Connect-AzAccount -TenantId <TenantID>

Ryangr0 commented 1 year ago

I found a solution.

Use Connect-AzAccount -TenantId <TenantID>

I think we're experiencing the same exact issue. I don't think that using powershell instead of the cli is a proper solution to this problem. I wonder if there's a way to merge these accounts? This isn't the only area in which I'm experiencing strange behavior within the azure ecosystem, and I'm getting more and more convinced me having both a personal and a work account on the same email is the problem.

aaltotsky commented 1 year ago

@Ryangr0 Initially, I want to merge them (accounts), but at this point, both accounts manage different subscriptions. They have different admin rights. So, I'm not sure if it is worth merging them just to use the az command. I also think that the problem could be in the MFA as well. Many services (GitHub, Azure DevOps) can create an access token, that should be used instead of the password. Maybe that is the solution.

aaltotsky commented 1 year ago

Here is another workaround:

  1. Sign in to the Azure Portal (https://portal.azure.com/)
  2. Click on the Cloud Shell (Next to the search box).
  3. Use az login there.
dodalovicgran commented 1 year ago
❯ az login
A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
Opening in existing browser session.
Found multiple accounts with the same username 'dusan.odalovic@gransoftware.de': [{'home_account_id': '8a5134bc-65f5-4de8-9611-9ed50f821da8.3e9ceed8-1dd5-422c-8d37-b26422dce745', 'environment': 'login.microsoftonline.com', 'username': 'dusan.odalovic@gransoftware.de', 'authority_type': 'MSSTS', 'local_account_id': '8a5134bc-65f5-4de8-9611-9ed50f821da8', 'realm': '3e9ceed8-1dd5-422c-8d37-b26422dce745'}, {'home_account_id': '00000000-0000-0000-cdb6-0b41b24413e2.9188040d-6c67-4c5b-b112-36a304b66dad', 'environment': 'login.microsoftonline.com', 'username': 'dusan.odalovic@gransoftware.de', 'authority_type': 'MSSTS', 'local_account_id': '331c08ab-44b9-449c-b2d9-4e0e18d347ef', 'realm': '3e9ceed8-1dd5-422c-8d37-b26422dce745'}]
craigmj commented 1 year ago

I still have this problem:

Please report to us via Github: https://github.com/Azure/azure-cli/issues/20168

I'm struggling to understand how you can be running a cloud service where users get logged out of their accounts. We are starting to migrate all our infrastructure off your cloud, to a more 'accessile' one...

craigmj commented 1 year ago

Here's the error - github removed it for some reason:

Found multiple accounts with the same username 'craig@lateral.co.za': [{'home_account_id': '00000000-0000-0000-226c-4e0a43c67914.9188040d-6c67-4c5b-b112-36a304b66dad', 'environment': 'login.microsoftonline.com', 'username': 'craig@lateral.co.za', 'authority_type': 'MSSTS', 'local_account_id': 'kISun9DEDcR3pNu7H8kd4CS8PbJ0XXkmW2yMvziPqiQ', 'realm': 'organizations'}, {'home_account_id': '3eec8dab-c90d-4871-a539-bf53a88f25ad.589bcab5-cea5-4eaa-ba34-9e58b9d21b40', 'environment': 'login.microsoftonline.com', 'username': 'craig@lateral.co.za', 'authority_type': 'MSSTS', 'local_account_id': '3eec8dab-c90d-4871-a539-bf53a88f25ad', 'realm': 'organizations'}]

MuhammadSalmanGalileo commented 1 year ago

I have same problem here is the error Found multiple accounts with the same username 'm.salman@efishery.com': [{'home_account_id': 'a1e2efba-95f3-4703-befb-0ebe01d062d2.aefbf958-7519-4710-990a-d2312cfe4fc2', 'environment': 'login.microsoftonline.com', 'username': 'm.salman@efishery.com', 'authority_type': 'MSSTS', 'local_account_id': 'a1e2efba-95f3-4703-befb-0ebe01d062d2', 'realm': 'organizations'}, {'home_account_id': '00000000-0000-0000-63eb-d2114b254395.9188040d-6c67-4c5b-b112-36a304b66dad', 'environment': 'login.microsoftonline.com', 'username': 'm.salman@efishery.com', 'authority_type': 'MSSTS', 'local_account_id': 'OORfRCtkTyOBLt4FdLmekmPhVtg7s79fhOvReBnP0Dk', 'realm': 'organizations'}]

BrunoJuchli commented 1 year ago

ERROR: Found multiple accounts with the same username 'bruno.juchli@smart-me.com': [{'home_account_id': 'd32db2dd-4414-4cdd-917e-c2f1cb3b8e85.5c9a4ff6-00e2-4775-9e18-cc5e6745a1f9', 'environment': 'login.microsoftonline.com', 'username': 'bruno.juchli@smart-me.com', 'authority_type': 'MSSTS', 'local_account_id': 'd32db2dd-4414-4cdd-917e-c2f1cb3b8e85', 'realm': 'organizations'}, {'home_account_id': '01948d69-2651-41cd-9815-d75892fb52a0.67d2b627-4607-4f1d-b430-2760715a2ae2', 'environment': 'login.microsoftonline.com', 'username': 'bruno.juchli@smart-me.com', 'authority_type': 'MSSTS', 'local_account_id': '01948d69-2651-41cd-9815-d75892fb52a0', 'realm': 'organizations'}] Please report to us via Github: https://github.com/Azure/azure-cli/issues/20168

Reported workaround of using Connect-AzAccount -TenantId <TenantID> doesn't work for me.

This, however, worked:

az account clear
az login
SusserBank commented 11 months ago

Same error: ╷ │ Error: obtaining Authorization Token from the Azure CLI: parsing json result from the Azure CLI: waiting for the Azure CLI: exit status 1: ERROR: Found multiple accounts with the same username 'domadminswinters@susser.bank': [{'home_account_id': '012156d7-6e1b-4ef1-b9d2-41a9ec136447.518917f1-fecb-440c-b871-99406caf2528', 'environment': 'login.microsoftonline.com', 'username': 'domadminswinters@susser.bank', 'authority_type': 'MSSTS', 'local_account_id': '012156d7-6e1b-4ef1-b9d2-41a9ec136447', 'realm': 'organizations'}, {'home_account_id': 'ef6e89f8-6656-442e-8dd7-676a2651b8d5.518917f1-fecb-440c-b871-99406caf2528', 'environment': 'login.microsoftonline.com', 'username': 'domadminswinters@susser.bank', 'authority_type': 'MSSTS', 'local_account_id': 'ef6e89f8-6656-442e-8dd7-676a2651b8d5', 'realm': 'organizations'}] │ Please report to us via Github: https://github.com/Azure/azure-cli/issues/20168

az account clear az login resolved the issue

bburdette commented 11 months ago

Just got directed here by az login, "Please report to us via Github: https://github.com/Azure/azure-cli/issues/20168".

The error was "Found multiple accounts with the same username", followed by specific account information I won't post here.

My situation is I was sent an azure login link by an admin and I've been using that to manage things in azure. That azure account hasn't been associated with a microsoft account, though it does have an email associated with it, "emailA". I created a microsoft account at some point with a different email address ("emailB"), but somehow it got associated with the emailA even though that was not listed on my user information profile. Not really sure of the sequence of events there, its been over a year I think.

Anyway, recently I was trying to az login and it wanted a microsoft account. I tried creating one with emailA, but it said that was already associated with a microsoft account, even though I couldn't log in with emailA. I went through the process of creating a new account with emailA, but it would get to a "Create Account" dialog and hang.

So I tried deleting the emailB microsoft account, but still could not create a microsoft account under emailA. I did not wait the required 60 days for full deletion.

So I logged in with emailB (reviving that microsoft account) and changed the email on that account to emailA, then removed emailB from it.

lopes221 commented 11 months ago

On Ubuntu 22.04 rm ~/.azure/*.json will solve the issue.

SusserBank commented 11 months ago

Thanks. It’s a Windows server, so this worked for me:

az account clear az login

Stormy Winters System Administrator

Susser Bank 3030 Matlock Road | Arlington, Texas 76015 Direct: 817.987.2178

@.***

From: Anderson Lopes @.> Sent: Friday, December 8, 2023 6:01 AM To: Azure/azure-cli @.> Cc: Susser Bank GitHub @.>; Comment @.> Subject: Re: [Azure/azure-cli] Found multiple accounts with same username (Issue #20168)

Caution: This email was received from an external source.

On Ubuntu 22.04 rm ~/.azure/*.json will solve the issue.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/Azure/azure-cli/issues/20168*issuecomment-1847056737__;Iw!!PQJeJ_XT8Nha!ai93fj9pl_18Ki8zD2GjTdjPIoLKGW7SY81hQ9PCTFzXNDX6J8h_1FJCccLPw59zlurHhdHXVvfyTxt869acIjpnAPE$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/BEAOTBOQJLEDYET2S4IOIFDYIL6P7AVCNFSM5HILCEQKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBUG4YDKNRXGM3Q__;!!PQJeJ_XT8Nha!ai93fj9pl_18Ki8zD2GjTdjPIoLKGW7SY81hQ9PCTFzXNDX6J8h_1FJCccLPw59zlurHhdHXVvfyTxt869ac1XhuYcI$. You are receiving this because you commented.Message ID: @.**@.>>

**NOTE: THIS MESSAGE IS INTENDED FOR THE USE OF THE INDIVIDUAL OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN INFORMATION THAT IS PRIVILEGED, CONFIDENTIAL, AND EXEMPT FROM DISCLOSURE UNDER APPLICABLE LAW. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication (except to the intended recipient or to us) is strictly prohibited. If you are aware of the intended recipient, you are responsible for delivering the message to the intended recipient. If you have received this communication in error, please notify us immediately by telephone and return the original message to us at the above address.

bburdette commented 11 months ago

On Ubuntu 22.04 rm ~/.azure/*.json will solve the issue.

This fixed my az login issue. Along the way I also changed the email on my non-work microsoft account so it wouldn't conflict with the work azure account with the same email. But I was still getting the error until doing this.

michaelfeil commented 10 months ago

On Ubuntu 22.04 rm ~/.azure/*.json will solve the issue.

This helped also to resolve this:

(evalenv) michi@michi:~/grdt$ az login
A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
Found multiple accounts with the same username 'michael@me.ai': [{'home_account_id': '00000000-0000-0000-db93-547fxxxxxxxxxxxxxxx-6c67-4c5b-b112-xxxxx', 'environment': 'login.microsoftonline.com', 'username': 'michael@me.ai', 'authority_type': 'MSSTS', 'local_account_id': 'ySpxxxxxxx-GlNvYmKGTvbiwQ', 'realm': 'organizations'}, {'home_account_id': '0f5e035b-fe69-4fbd-aced-be134d871024.a4d0a6ec-5402-xxxxxxxx-xxxxxx', 'environment': 'login.microsoftonline.com', 'username': 'michael@me.ai', 'authority_type': 'MSSTS', 'local_account_id': 'xxxxxxxx-fe69-4fbd-aced-xxxxxxx', 'realm': 'organizations'}]
Please report to us via Github: https://github.com/Azure/azure-cli/issues/20168
jziggas commented 7 months ago

I'm not entirely sure but I believe I resolved this issue with the following steps (because any of the individual suggestions above did not work):

jonas-lomholdt commented 6 months ago

Thanks! I did a rm ~/.azure/msal_token_cache.json and that solved it for me.

DeepaAvaradi commented 3 months ago

Hi, I am getting Below error whenver i am trying to get the access token, please help me on that image

rayluo commented 3 months ago

Food for thought, @jiasli.

We have been collecting the user reports for this issue for a while now. The "multiple accounts with same username" symptoms covered a wide spectrum.

The problem is that we still don't really know why we ended up with such a state in the first place, despite sporadic repro report(s). We just knew that username is not unique, and Entra ID somehow has no problem allowing different accounts with same username to sign in and knows who-is-who.

I suppose on the client side, and Azure CLI in particular, we could either:

  1. Add an experimental check after each successful az login ... to proactively check get_accounts(username=current_username_obtained_via_ID_token) and fail early with same error message. That way, when everything else being equal, at least we will have better idea of how the 2nd account would have been established via an "az login".
  2. Alternatively, MSAL could add a last_modification_time field into the accounts so that Azure CLI may use it to automatically choose the newer account to proceed, optionally automatically removing the old account. This essentially automates the "az account clear; az login ..." workaround.
asouzajunior commented 1 month ago

Same problem here . Tried to use az login, but get this message. My e-mail was omitted below.

% az login
A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with az login --use-device-code.

Retrieving tenants and subscriptions for the selection... Found multiple accounts with the same username 'axxxxxza@xxxxx.com.br': [{'home_account_id': '16223eeb-871b-47ed-a948-cd5ba9241cc4.995266c5-aa22-415a-afc2-2cc026ce99f9', 'environment': 'login.microsoftonline.com', 'username': 'axxxxxza@xxxxx.com.br', 'account_source': 'authorization_code', 'authority_type': 'MSSTS', 'local_account_id': '16223eeb-871b-47ed-a948-cd5ba9241cc4', 'realm': 'organizations'}, {'home_account_id': '00000000-0000-0000-0c83-47e3c67e0948.9188040d-6c67-4c5b-b112-36a304b66dad', 'environment': 'login.microsoftonline.com', 'username': 'axxxxxza@xxxxx.com.br', 'account_source': 'authorization_code', 'authority_type': 'MSSTS', 'local_account_id': 'HbyDaX5XjgMbvbQ0VVnF_58o-Ch_9DaeSQBatAgrRZE', 'realm': 'organizations'}] Please report to us via Github: https://github.com/Azure/azure-cli/issues/20168

zyptai commented 3 weeks ago

Same issue. My issue is my user thinks i have a personal and a microsoft account in the same user ID.

ERROR: Found multiple accounts with the same username 'tixxxxx@i.com': [{'home_account_id': '747e0494-612a-49d2-a9f0-ac512e4340ae.f20f5397-6421-44f6-80aa-1dbcc827e24d', 'environment': 'login.microsoftonline.com', 'username': 'tixxxxx@i.com':, 'account_source': 'broker', 'authority_type': 'MSSTS', 'local_account_id': '747e0494-612a-49d2-a9f0-ac512e4340ae', 'realm': 'f20f5397-6421-44f6-80aa-1dbcc827e24d'}, {'home_account_id': '00000000-0000-0000-edbe-a05df11c0122.9188040d-6c67-4c5b-b112-36a304b66dad', 'environment': 'login.microsoftonline.com', 'username': ''tixxxxx@i.com':, 'account_source': 'broker', 'authority_type': 'MSSTS', 'local_account_id': '00000000-0000-0000-edbe-a05df11c0122.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

dmwozniak-grg commented 1 week ago

Same issue.

azure.core.exceptions.ClientAuthenticationError: ERROR: Found multiple accounts with the same username 'contact@dmwozniak.com': [{'home_account_id': '6793ad6a-e2b9-4b04-9ae4-001e9a505e49.56d2060f-2bdb-4206-80a1-4a09f5f7e9ed', 'environment': 'login.microsoftonline.com', 'username': 'contact@dmwozniak.com', 'account_source': 'broker', 'authority_type': 'MSSTS', 'local_account_id': '6793ad6a-e2b9-4b04-9ae4-001e9a505e49', 'realm': '56d2060f-2bdb-4206-80a1-4a09f5f7e9ed'}, {'home_account_id': '00000000-0000-0000-4d7d-e1fd64222eed.9188040d-6c67-4c5b-b112-36a304b66dad', 'environment': 'login.microsoftonline.com', 'username': 'contact@dmwozniak.com', 'account_source': 'broker', 'authority_type': 'MSSTS', 'local_account_id': '00000000-0000-0000-4d7d-e1fd64222eed.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