Blog Post

Microsoft Developer Community Blog
2 MIN READ

New Login Experience for Azure Subscriptions with az login

Chris_Ayers's avatar
Chris_Ayers
Icon for Microsoft rankMicrosoft
Jun 05, 2024

Introduction

If you have multiple Azure subscriptions, you might have experienced the frustration of logging into the wrong one with the az login command. This can cause errors and confusion when you try to run commands or access resources in the wrong subscription.

Fortunately, there is a new login experience that makes it easier to select the right subscription. This feature was announced at the Build 2024 conference and is available in version v2.61.0 of the Azure CLI.

 

old az login experience

How to use the new az login experience

To use the new login experience, you need to update your Azure CLI to the latest version. There are a few ways to do this as documented here: https://learn.microsoft.com/en-us/cli/azure/update-azure-cli. You can manually do this by running the command:

  • az upgrade

Once you have the latest version, you can run the az login command as usual. However, instead of logging into the default subscription, you will see a list of your available subscriptions and a prompt to choose one. For example:

 

new az login experience

 

You can hit enter and log into the default or enter the number of the subscription you want to log into. The subscription you choose will be set as the default for the current session. You can verify this by running the command:

  • az account show

If you want to switch to a different subscription, you can run the az login command again and choose another one. You can also use the az account set command with the subscription ID or name.

Benefits of the new az login experience

The new login experience has several benefits for Azure users who have multiple subscriptions:

  • Reduces Errors and Confusion: Minimizes the risk of logging into the wrong subscription.
  • Saves Time and Effort: Avoids the need to run additional commands to set or change the default subscription.
  • Improves User Experience: Provides an interactive and intuitive way to choose the subscription.

The new login experience for Azure subscriptions with az login is a welcome feature that makes it easier to work with multiple subscriptions.

 

For more information, visit Sign in with Azure CLI at a command line | Microsoft Learn

Updated Jun 04, 2024
Version 1.0
  • I have set az config set core.login_experience_v2=off, But it seems the authentication part is still the "new experience"

     

    I find the new sign-in experience far slower than the old experience since having to select account, entering username and pasting the password from my password manager rather than just opening the correct browser beforehand where I can use my password manager to autofill the password and press enter before getting an MFA prompt.

  • "az login" should output "You're signed in to subscription XXX, please run az account set to change it". Only show the selection on first login. My current list is about 100 lines (or 1000 as JSON), but I almost never change the subscription, so it's entirely wasted output.

  • richeney's avatar
    richeney
    Copper Contributor

    I like the new experience. Much easier, A few suggestions:

    • az account set (with no arguments) could trigger the new experience (assuming az config set core.login_experience_v2 != off)
    • option to change the sort order, e.g.
      • alphabetical (default)
      • recently used (top)
      • recently used (bottom)
    • option to limit the size of the list
    • option to filter in or out certain tenants
    • option to filter in or filter out certain subscriptions

    Perhaps more az config core. properties?

  • Yes, in the docs they show the config setting to disable: 
    # disable the subscription selector (v. 2.61.0 and up)
    az config set core.login_experience_v2=off

  • Is there a way to disable this? The list can be really long, and I almost never change subscription on login.