Insight Tech APAC Blog Logo

The new login experience for Azure CLI

stephentulp
July 8, 2024

2 minutes to read

Background

When you have several Azure Subscriptions, logging into Azure via the az login command doesn’t always put you into the Subscription you want to work in. Annoying at best, at worst this can lead to unintentional modification or destruction of the wrong resource.

The good news is that a revamped login process has been introduced to streamline selection of the appropriate subscription. This enhancement is incorporated into Azure CLI’s version v2.61.0, simplifying your Azure management experience.

In Action

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.

The new login az login experience no longer sets your default subscription. Instead, you are presented with a list of all available subscriptions. If you have logged in previously, your last accessed subscription will be denoted with a star (*). To jump back in, hit Enter to access the last subscription. ```

/Azure CLI

Enter the number of the subscription you want to log into and the subscription you choose will be set as the default for the current session.

/Azure CLI2

If you run the az account show command you will get details of the current context.

{
  "environmentName": "AzureCloud",
  "homeTenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "isDefault": true,
  "managedByTenants": [],
  "name": "sub-insight-sap-prd-01",
  "state": "Enabled",
  "tenantDefaultDomain": "insightaudemo.onmicrosoft.com",
  "tenantDisplayName": "Insight AU Demo Pty Ltd",
  "tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "user": {
    "name": "stephen.tulp@insightaudemo.onmicrosoft.com",
    "type": "user"
}

Conclusion

The new enhanced login feature introduces several advantages for Azure users juggling multiple subscriptions:

  • Minimise Mistakes: It significantly lowers the chances of accidentally signing into an incorrect subscription.
  • Saves Time and Effort: Eliminates the need to execute extra commands for adjusting the default subscription.
  • Elevate the User Experience: Offers a user-friendly and engaging method for selecting the desired subscription.

This update to the Azure az login process is a much-appreciated improvement, streamlining the login experience across multiple Azure subscriptions.