New Login Experience for Azure Subscriptions with az login
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.
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:
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
Microsoft Tech Community – Latest Blogs –Read More