azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

`az login` not honoring `core.login_experience_v2 = off`

Open danmacode opened this issue 1 year ago • 1 comments

Describe the bug

When using az login --allow-no-subscriptions --tenant 'abcd1234-1234-1234-1234-1234abcd1234' --output none it does not honor the local configuration file.

Related command

Set the local config to not use the interactive login experience:

$ az --version
azure-cli                         2.61.0

$ az config --local set core.login_experience_v2=off

Verify that local config has core.login_experience_v2 disabled and global config is unset:

$ az config get core.login_experience_v2
Configuration 'core.login_experience_v2'is not set.

$ az config get --local core.login_experience_v2
{
  ...
  "value: "off"
}

Try to connect specifying a tenant id:

$ az login --allow-no-subscriptions --tenant 'abcd1234-1234-1234-1234-1234abcd1234' --output none

However, it prompts the user to select a subscription. If global config is set to core.login_experience_v2=off then there's no prompt.

Errors

No errors

Issue script & Debug output

Retrieving tenants and subscriptions for the selection...

[Tenant and subscription selection]

No     Subscription name                  Subscription ID                       Tenant
-----  ---------------------------------  ------------------------------------  ---------
[1]    Some sub                1231123123 Some tenant

Expected behavior

az login --allow-no-subscriptions --tenant 'abcd1234-1234-1234-1234-1234abcd1234' --output none should not prompt the user to select a subscription

Environment Summary

azure-cli                         2.65.0

core                              2.65.0
telemetry                          1.1.0

Extensions:
account                            0.2.5
automation                       1.0.0b1
init                               0.1.0
next                               0.1.3

Dependencies:
msal                              1.31.0
azure-mgmt-resource               23.1.1

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\danmacode\.azure\cliextensions'

Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb  6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]

Additional context

No response

danmacode avatar Oct 16 '24 22:10 danmacode

Thank you for opening this issue, we will look into it.

yonzhan avatar Oct 16 '24 22:10 yonzhan

Workaround to avoid modifying the global configuration at ~/.azure/config:

az config --local set core.login_experience_v2=off
export AZURE_CONFIG_DIR="$(pwd)"
# execute the rest of your az commands below

danmacode avatar Oct 25 '24 16:10 danmacode

The above noted workaround does not work...I get an error saying that --local is an unrecognized argument.

My company has a tenant with over 100,000 subscriptions in it. The inability to use the AZ CLI is a problem for us, and this would be very simple to fix.

zack4485-skillable avatar Aug 08 '25 17:08 zack4485-skillable

The correct command is

az config set --local core.login_experience_v2=off

You cannot put --local before set.

After running it, the config will be logged at .azure/config under the current directory.

> az config get --local
...
  "core": [
    {
      "name": "login_experience_v2",
      "source": "D:\\temp\\.azure\\config",
      "value": "off"
    },

However, it is not honored during command execution. Actually, it is not login_experience_v2 that doesn't work with local config, but all configuration options.

This issue is tracked by https://github.com/Azure/azure-cli/issues/22007.

jiasli avatar Aug 11 '25 07:08 jiasli

@jiasli I don't actually care that the local config isn't honored. What I care about is that the --allow-no-subscriptions switch doesn't do anything. The AZ CLI is utterly unusable for any customer having more than X subscriptions in a tenant.

This feels like a really small fix to an issue that's been opened for years.

zack4485-skillable avatar Aug 11 '25 16:08 zack4485-skillable

Do I need to make a duplicate of this issue that focuses exclusively on the fact that --allow-no-subscriptions is ignored (irrespective of login_experience_v2)?

zack4485-skillable avatar Aug 12 '25 19:08 zack4485-skillable