unable to login to azure portal via az login command

SHANTANU TALUKDER 0 Reputation points
2024-06-04T13:26:10.01+00:00

I was trying to login to azure from command prompt as an administrator using "az login". Getting an error message stating that my subscription wasn't found and user authentication failed. I checked my subscription from the azure console which is showing a valid subscription and I am a global admin for my subscription. I tried to do the same from VSCODE terminal and experienced the same issue. Azure cli was installed on my windows laptop.az lAZ Subscription.pngAZ Login.pngogin error.png

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
666 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Babafemi Bulugbe 2,835 Reputation points MVP
    2024-06-04T16:40:56.03+00:00

    Hello SHANTANU TALUKDER,

    Thank you for posting your query in the Microsoft Q&A Community.

    I understand that you are experiencing issue authenticating with your user account via CLI

    Based on your screenshots, one reason why you might be experiencing this is trying to authenticate to a different tenant other that the tenant where the subscription is.

    To resolve this, kindly force the authentication by adding your tenant id

    az login --tenant 00000000-0000-0000-0000-000000000000
    

    If you are in the tenant and you still not able to access, you can set the subscription using this

    az account set --subscription "<subscription ID or name>"
    

    Let me know if further assistance is needed.

    Babafemi

    0 comments No comments

  2. Prrudram-MSFT 22,941 Reputation points
    2024-06-10T10:53:49.61+00:00

    Hello @SHANTANU TALUKDER

    The Azure CLI's default authentication method for logins uses a web browser and access token to sign in. As suggested by Babafemi You need to specify the tenantid, in your current session you just have to do it once and from then on it won't require that.

    az login --tenant <TenantID>
    

    If you have already done that and the issue remains same, you can follow the link to another similar question that has a few more suggestions which worked for other users with the same error you have encountered here

    https://video2.skills-academy.com/en-us/answers/questions/1296678/az-login-error-failed-to-authenticate-my-guid-defa

    If your issue remains unresolved or have further questions, please let us know in the comments how we can assist. We are here to help you and strive to make your experience better and greatly value your feedback.

    If I have answered your query, please click "Accept as answer" as a token of appreciation

    0 comments No comments

  3. Daniel Lungu 0 Reputation points
    2024-06-20T07:59:21.6666667+00:00

    I have a similar issue.

    az login and az login --tenant <TenantID> does not work.

    In my case it's because I run powershell or terminal as administrator (it was working with previous versions of azure cli).

    So there is a bug if you login into azure cli from powershell or terminal opened as administrator.

    0 comments No comments