diff --git a/src/azure-cli-core/azure/cli/core/cloud.py b/src/azure-cli-core/azure/cli/core/cloud.py index 5ffdb6892eb..ac0d909bd16 100644 --- a/src/azure-cli-core/azure/cli/core/cloud.py +++ b/src/azure-cli-core/azure/cli/core/cloud.py @@ -583,6 +583,7 @@ def get_clouds(cli_ctx): except configparser.MissingSectionHeaderError: os.remove(CLOUD_CONFIG_FILE) logger.warning("'%s' is in bad format and has been removed.", CLOUD_CONFIG_FILE) + active_cloud_name = get_active_cloud_name(cli_ctx) for section in config.sections(): c = Cloud(section) for option in config.options(section): @@ -602,11 +603,13 @@ def get_clouds(cli_ctx): "2019-03-01-hybrid", "2020-09-01-hybrid", ): - logger.error( - "The azure stack profile '%s' has been deprecated and removed, using the 'latest' profile instead.\n" - "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 - ) - c.profile = 'latest' + if c.name == active_cloud_name: + # only apply to the active cloud + logger.error( + "The azure stack profile '%s' has been deprecated and removed, using the 'latest' profile instead.\n" + "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 + ) + c.profile = 'latest' else: raise CLIError('Profile {} does not exist or is not supported.'.format(c.profile)) if not c.endpoints.has_endpoint_set('management') and \ @@ -614,7 +617,6 @@ def get_clouds(cli_ctx): # If management endpoint not set, use resource manager endpoint c.endpoints.management = c.endpoints.resource_manager clouds.append(c) - active_cloud_name = get_active_cloud_name(cli_ctx) for c in clouds: if c.name == active_cloud_name: c.is_active = True