skip to Main Content

I have az cli version 2.44.1 installed. When I perform az login from the command, I get prompted to login on the browser. I then proceed to use my account [email protected]. Once the login on the browser is successful, my command prompt shows a message saying "No subscriptions found for [email protected]". For some reason, azure cli is picking up a different account (the account I’m logged on the PC as) instead of the account I’m selecting in the browser.

I have deleted the contents of .azure folder and redone the steps (hoping to flush the stored credentials) but the result seems to be the same; despite of me selecting [email protected] on the logon window, I see that [email protected] is selected by the azure CLI.

One workaround I have is: I can run the cmd.exe as a different user [email protected] and then run az login from there. This way seems to pick the right account. But I’d like to see if there’s a way to fix it some other way because I’d like to use az cli alongside terraform in my VSCode bash. I’m running Windows 10 Enterprise.

2

Answers


  1. It seems that the issue is related to the credentials stored on your Windows machine. One solution could be to clear the Azure Active Directory (AAD) token cache by running the following command in the command prompt:

    az account clear
    

    This command will clear the AAD token cache, which will force the CLI to prompt you to login again and select the correct account.

    Another solution would be to check the environment variables on your machine to ensure that the correct tenant and subscription are being used. You can check the tenant and subscription by running the following commands:

    az account show
    az account list
    

    If the wrong tenant or subscription is being used, you can set the correct one by running the following commands:

    az account set --subscription="SUBSCRIPTION_ID"
    az account set --tenant="TENANT_ID"
    

    You can also check and manage the stored credentials in the Credential Manager on your Windows machine.

    It is also possible that there is a problem with the installed version of Azure CLI, you could try to update or reinstall it.

    Login or Signup to reply.
  2. I got the same error when I tried it previously in my environment, and I found the issue.

    enter image description here

    Reason:

    "No subscriptions found" indicates that the account has gone through authentication and does not have access to the subscriptions.

    Go to Azure -> All Services > Subscriptions or search for subscription in the search panel, then visit Access control (IAM) and assign the "contributor" role as shown:

    Path:

    enter image description here

    Script:

    az account set --subscription <subscription> //not manadatory
    az login --service-principal --username <APPID> --password <clientsecret> --tenant <>tenantID 
    

    Logged in successfully:

    enter image description here

    Parallelly,

    Upgrade CLI once by giving:

    az upgrade
    

    to check your "CLI is upto date".

    enter image description here

    Execute the command below to check the cli login details for future use.

    az login --debug
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search