Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/azure-cli/azure/cli/command_modules/profile/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,17 @@ def login(cmd, username=None, password=None, tenant=None, scopes=None, allow_no_

# Launch interactive account selection. No JSON output.
if select_subscription:
from ._subscription_selector import SubscriptionSelector
from azure.cli.core._profile import _SUBSCRIPTION_ID

selected = SubscriptionSelector(subscriptions)()
profile.set_active_subscription(selected[_SUBSCRIPTION_ID])

if subscriptions:
from ._subscription_selector import SubscriptionSelector
from azure.cli.core._profile import _SUBSCRIPTION_ID
selected = SubscriptionSelector(subscriptions)()
profile.set_active_subscription(selected[_SUBSCRIPTION_ID])
else:
# By default, if the account has no access to any subscription, CLI will fail earlier in _profile.py.
# When --allow-no-subscriptions is specified, and the account
# - has access to tenant, but no subscription, `subscriptions` will be the tenant account
# - has access to no tenant, `subscriptions` will be []. This line will be hit.
print("\nNo accessible tenant. Make sure your account has access to at least one tenant.\n")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#3150 made az login not fail when --allow-no-subscriptions is provided and the user account has no accessible tenant.

Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using logger.warning or logger.error instead of print for the error message to be consistent with CLI logging patterns. Looking at the surrounding code (lines 220), logger.warning is used for warnings, and this seems like an error or warning message that should follow the same pattern.

Suggested change
print("\nNo accessible tenant. Make sure your account has access to at least one tenant.\n")
logger.warning("\nNo accessible tenant. Make sure your account has access to at least one tenant.\n")

Copilot uses AI. Check for mistakes.
print(LOGIN_ANNOUNCEMENT)
logger.warning(LOGIN_OUTPUT_WARNING)
return
Expand Down
Loading