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

azure

Open GummaVamsi opened this issue 6 months ago • 2 comments

Describe the bug

[Tenant and subscription selection]

No Subscription name Subscription ID Tenant


[1] * Azure subscription 1 0c355f40-740b-489b-a9a4-574ffcbf59e4 Default Directory

The default is marked with an *; the default tenant is 'Default Directory' and subscription is 'Azure subscription 1' (0c355f40-740b-489b-a9a4-574ffcbf59e4).

Select a subscription and tenant (Type a number or Enter for no changes): Invalid selection. Select a subscription and tenant (Type a number or Enter for no changes): 1

Tenant: Default Directory Subscription: Azure subscription 1 (0c355f40-740b-489b-a9a4-574ffcbf59e4)

[Announcements] With the new Azure CLI login experience, you can select the subscription you want to use more easily. Learn more about it and its configuration at https://go.microsoft.com/fwlink/?linkid=2271236

If you encounter any problem, please open an issue at https://aka.ms/azclibug

[Warning] The login output has been updated. Please be aware that it no longer displays the full list of available subscriptions by default.

PS /home/vamsi>

Related command

az vm create

Errors

No Subscription name Subscription ID Tenant


[1] * Azure subscription 1 0c355f40-740b-489b-a9a4-574ffcbf59e4 Default Directory

The default is marked with an *; the default tenant is 'Default Directory' and subscription is 'Azure subscription 1' (0c355f40-740b-489b-a9a4-574ffcbf59e4).

Select a subscription and tenant (Type a number or Enter for no changes): Invalid selection. Select a subscription and tenant (Type a number or Enter for no changes): 1

Tenant: Default Directory Subscription: Azure subscription 1 (0c355f40-740b-489b-a9a4-574ffcbf59e4)

Issue script & Debug output

output here

Expected behavior

No Subscription name Subscription ID Tenant


[1] * Azure subscription 1 0c355f40-740b-489b-a9a4-574ffcbf59e4 Default Directory

The default is marked with an *; the default tenant is 'Default Directory' and subscription is 'Azure subscription 1' (0c355f40-740b-489b-a9a4-574ffcbf59e4).

Select a subscription and tenant (Type a number or Enter for no changes): Invalid selection. Select a subscription and tenant (Type a number or Enter for no changes): 1

Tenant: Default Directory Subscription: Azure subscription 1 (0c355f40-740b-489b-a9a4-574ffcbf59e4)

Environment Summary

azure

Additional context

No Subscription name Subscription ID Tenant


[1] * Azure subscription 1 0c355f40-740b-489b-a9a4-574ffcbf59e4 Default Directory

The default is marked with an *; the default tenant is 'Default Directory' and subscription is 'Azure subscription 1' (0c355f40-740b-489b-a9a4-574ffcbf59e4).

Select a subscription and tenant (Type a number or Enter for no changes): Invalid selection. Select a subscription and tenant (Type a number or Enter for no changes): 1

Tenant: Default Directory Subscription: Azure subscription 1 (0c355f40-740b-489b-a9a4-574ffcbf59e4)

GummaVamsi avatar Jun 08 '25 07:06 GummaVamsi

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

yonzhan avatar Jun 08 '25 07:06 yonzhan

Here are some similar issues that might help you. Please check if they can solve your problem.

  • #30475

Powered by issue-sentinel

github-actions[bot] avatar Jun 08 '25 07:06 github-actions[bot]

Image

The Invalid selection. warning should be shown in the next line, not the same line as Select a subscription and tenant (Type a number or Enter for no changes):. I doubt there is some issue with the terminal, making Azure CLI receiving invalid characters.

  1. Could you share the result of az --version?
  2. Are you using Azure CLI in WSL?

jiasli avatar Nov 14 '25 06:11 jiasli

Hi @jiasli

My customer encounter the same experience, when it first ask for user to choose subscription, no matter user type Enter directly to choose default choice or enter a number to choose a subscription, command will return "invalid selection", and then if entering the same choice it works. Here is a screenshot about choose default but receive invalid selection.

Image

In my scenario, user is using an Azure Linux VM running AZ CLI, and customer first report the issue when using AZCLI 2.71.0, then they upgrade to 2.79.0, issue still occurs. And User is using Bastion to connect to Azure VM.

kagoesy avatar Nov 17 '25 01:11 kagoesy

I am not able to repro in Bastion either:

Image Image

@kagoesy, could you verify if the same issue happens when using SSH to connect to the Azure VM and call az login?

Meanwhile, you may follow https://learn.microsoft.com/en-us/cli/azure/authenticate-azure-cli-interactively?view=azure-cli-latest#subscription-selector to disable the subscription selector:

az config set core.login_experience_v2=off

jiasli avatar Nov 17 '25 07:11 jiasli

To further know what character Azure CLI receives, please edit the below file with

sudo nano --linenumbers /opt/az/lib/python3.13/site-packages/azure/cli/command_modules/profile/_subscription_selector.py

At line 78, add

            print(repr(select_index))

Then reproduce this issue. The output will show what character Azure CLI receives.

jiasli avatar Nov 17 '25 08:11 jiasli

Hi @jiasli , Here is the screenshot

Image

Looks the device login url has become the input for some reason

kagoesy avatar Nov 19 '25 08:11 kagoesy

I changed L87 to print the input text:

logger.warning("Invalid selection: %s", select_index)

The only possibility I can think of is that you right clicked the text and the text got pasted to the terminal.

Image

In Bastion, you don't need to right click to copy text. Simply selecting the text and it will be copied to the clipboard.

Could you share a screenshot which contains the output before [Tenant and subscription selection]?

jiasli avatar Nov 20 '25 05:11 jiasli