Skip to content

Commit b602da0

Browse files
authored
{core} Fix warning message display issue (#31384)
1 parent 593b70b commit b602da0

File tree

1 file changed

+8
-6
lines changed
  • src/azure-cli-core/azure/cli/core

1 file changed

+8
-6
lines changed

src/azure-cli-core/azure/cli/core/cloud.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ def get_clouds(cli_ctx):
583583
except configparser.MissingSectionHeaderError:
584584
os.remove(CLOUD_CONFIG_FILE)
585585
logger.warning("'%s' is in bad format and has been removed.", CLOUD_CONFIG_FILE)
586+
active_cloud_name = get_active_cloud_name(cli_ctx)
586587
for section in config.sections():
587588
c = Cloud(section)
588589
for option in config.options(section):
@@ -602,19 +603,20 @@ def get_clouds(cli_ctx):
602603
"2019-03-01-hybrid",
603604
"2020-09-01-hybrid",
604605
):
605-
logger.error(
606-
"The azure stack profile '%s' has been deprecated and removed, using the 'latest' profile instead.\n"
607-
"To continue using Azure Stack, please install the Azure CLI `2.66.*` (LTS) version. For more details, refer to: https://learn.microsoft.com/en-us/cli/azure/whats-new-overview#important-notice-for-azure-stack-hub-customers", c.profile
608-
)
609-
c.profile = 'latest'
606+
if c.name == active_cloud_name:
607+
# only apply to the active cloud
608+
logger.error(
609+
"The azure stack profile '%s' has been deprecated and removed, using the 'latest' profile instead.\n"
610+
"To continue using Azure Stack, please install the Azure CLI `2.66.*` (LTS) version. For more details, refer to: https://learn.microsoft.com/en-us/cli/azure/whats-new-overview#important-notice-for-azure-stack-hub-customers", c.profile
611+
)
612+
c.profile = 'latest'
610613
else:
611614
raise CLIError('Profile {} does not exist or is not supported.'.format(c.profile))
612615
if not c.endpoints.has_endpoint_set('management') and \
613616
c.endpoints.has_endpoint_set('resource_manager'):
614617
# If management endpoint not set, use resource manager endpoint
615618
c.endpoints.management = c.endpoints.resource_manager
616619
clouds.append(c)
617-
active_cloud_name = get_active_cloud_name(cli_ctx)
618620
for c in clouds:
619621
if c.name == active_cloud_name:
620622
c.is_active = True

0 commit comments

Comments
 (0)