Skip to content

{Packaging} Add warning message for Azure Linux 2.0 #31545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025
Merged
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
13 changes: 12 additions & 1 deletion src/azure-cli/azure/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
start_time = timeit.default_timer()

import sys
import os

from azure.cli.core import telemetry
from azure.cli.core import get_default_cli
Expand All @@ -22,6 +23,14 @@

logger = get_logger(__name__)

AZURELINUX2_WARNING_MESSAGE = (
"Azure CLI 2.74.0 is the final version available on Azure Linux (Mariner) 2.0 and will not receive further "
"updates. "
"We recommend migrating to Azure Linux 3.0 to access newer versions of Azure CLI and continue receiving updates. "
"For more information: https://go.microsoft.com/fwlink/?linkid=2322402. "
"To disable this warning message, set AZURE_CLI_DISABLE_AZURELINUX2_WARNING environment variable to any value. "
)


def cli_main(cli, args):
return cli.invoke(args)
Expand Down Expand Up @@ -96,7 +105,6 @@ def cli_main(cli, args):
else:
upgrade_exit_code = subprocess.call(cmd, shell=platform.system() == 'Windows')
else:
import os
devnull = open(os.devnull, 'w')
cmd.append('-y')
upgrade_exit_code = subprocess.call(cmd, shell=platform.system() == 'Windows', stdout=devnull)
Expand All @@ -115,6 +123,9 @@ def cli_main(cli, args):
except Exception as ex: # pylint: disable=broad-except
logger.debug("Intercept survey prompt failed. %s", str(ex))

if 'AZURE_CLI_DISABLE_AZURELINUX2_WARNING' not in os.environ:
logger.warning(AZURELINUX2_WARNING_MESSAGE)
Comment on lines +126 to +127
Copy link
Member Author

@jiasli jiasli May 23, 2025

Choose a reason for hiding this comment

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

The warning can also be disabled by az config set core.only_show_errors=true, but as #29628 (comment) mentioned, this will disable other warning messages too.

Introducing an environment variable AZURE_CLI_DISABLE_AZURELINUX2_WARNING will make it possible to disable only this warning message.

Adding a config option core.disable_azurelinux2_warning is also possible but a little bit too heavy and formal, an requires official documentation. AZURE_CLI_DISABLE_AZURELINUX2_WARNING is only a one-time feature and will not exist in the dev branch of Azure CLI.


telemetry.set_init_time_elapsed("{:.6f}".format(init_finish_time - start_time))
telemetry.set_invoke_time_elapsed("{:.6f}".format(invoke_finish_time - init_finish_time))
telemetry.conclude()