azure
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)
Thank you for opening this issue, we will look into it.
Here are some similar issues that might help you. Please check if they can solve your problem.
- #30475
Powered by issue-sentinel
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.
- Could you share the result of
az --version? - Are you using Azure CLI in WSL?
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.
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.
I am not able to repro in Bastion either:
@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
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.
Hi @jiasli , Here is the screenshot
Looks the device login url has become the input for some reason
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.
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]?