Skip to content

[Packaging] Azure CLI container based on Azure Linux 4.0 - #33850

Open
mansoor sarfraz (msarfraz) wants to merge 9 commits into
devfrom
msarfraz/azure-linux4
Open

[Packaging] Azure CLI container based on Azure Linux 4.0#33850
mansoor sarfraz (msarfraz) wants to merge 9 commits into
devfrom
msarfraz/azure-linux4

Conversation

@msarfraz

Copy link
Copy Markdown
Contributor

Azure Linux version is updated from 3.0 to 4.0(beta)
https://github.com/microsoft/azurelinux

Copilot AI lite review requested due to automatic review settings August 5, 2026 00:51
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@yonzhan

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Azure Linux–based Azure CLI container/RPM build pipeline from Azure Linux 3.0 to Azure Linux 4.0 (beta), aligning the Docker build inputs, artifact naming, and documentation with the new base image and RPM output paths.

Changes:

  • Switch the Azure Linux base image reference from mcr.microsoft.com/azurelinux/base/core:3.0 to mcr.microsoft.com/azurelinux-beta/base/core:4.0 in build assets.
  • Update RPM output paths for Azure Linux builds to /root/rpmbuild/RPMS/... to match current rpmbuild output layout.
  • Rename Azure Linux pipeline matrix labels and artifact names from 3.0 to 4.0 for consistency.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
scripts/release/rpm/README.md Updates the Azure Linux RPM extraction example to the Azure Linux 4.0 RPM name and rpmbuild output path.
scripts/release/rpm/pipeline_azurelinux.sh Updates the inline guidance/example base image reference for Azure Linux builds to 4.0 beta.
scripts/release/rpm/azurelinux.dockerfile Updates the default base image and adjusts expected/copied RPM output paths for Azure Linux 4.0.
azure-pipelines.yml Updates Azure Linux pipeline jobs to use the 4.0 beta image and renames related artifacts from 3.0 to 4.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/azure-cli-core/azure/cli/core/extension/operations.py:262

  • The warning message has a grammar issue ("if not exist"), which is user-facing and makes the output harder to understand. Rephrase to "if not present" (or similar).
                logger.warning(
                    'This extension depends on %s and they will be installed first if not exist.',
                    ' '.join(rpm_packages)
                )

src/azure-cli-core/azure/cli/core/extension/operations.py:220

  • get_linux_distro() can return (None, None) (e.g., missing /etc/os-release or missing VERSION_ID). Calling .lower() / .startswith() on None will raise, which would break extension install on some Linux environments. Coerce distname/distversion to empty strings before using them.
        distname, distversion = get_linux_distro()
        distname = distname.lower().strip()
        is_azure_linux_4 = 'azure linux' in distname and distversion.startswith('4.')

scripts/release/rpm/azurelinux.dockerfile:32

  • find / -xdev ... | head -n 1 scans the whole filesystem in the build container, which can be slow and occasionally brittle. Since the RPM should only be under the rpmbuild topdirs for AZL3/AZL4, restrict the search to those directories and use -quit to stop at the first match.
    RPM_PATH=$(find / -xdev -type f -name "azure-cli-${cli_version}-1.*.rpm" 2>/dev/null | head -n 1) && \

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/azure-cli-core/azure/cli/core/extension/operations.py:257

  • Azure Linux 4.x branch invokes tdnf directly; if tdnf is not present, subprocess.call will raise FileNotFoundError and bypass the intended CLIError messaging. Add an explicit shutil.which('tdnf') check (similar to the Homebrew branch’s brew check) and fail fast with a clear CLIError.
            elif is_azure_linux_4:
                rpm_packages = ['gcc', 'libpq-devel', 'python3-devel', 'binutils', 'glibc-devel', 'kernel-headers']
                rpm_install_cmd = ['tdnf', 'install', '-y'] + rpm_packages
                if os.geteuid() != 0:  # pylint: disable=no-member

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py:498

  • This assertion doesn't actually validate that yum wasn't used: the yum install command in _install_deps_for_psycopg2 uses postgresql-devel (and not the AZL package list), so this assertNotIn will always pass even if the code accidentally calls yum. Consider asserting that none of the subprocess calls start with yum/sudo yum instead.
        azure_linux_packages = ['gcc', 'libpq-devel', 'python3-devel', 'binutils', 'glibc-devel', 'kernel-headers']
        subprocess_call.assert_any_call(['tdnf', 'install', '-y'] + azure_linux_packages)
        self.assertNotIn(mock.call(['yum', 'install', '-y'] + azure_linux_packages),
                         subprocess_call.call_args_list)

src/azure-cli-core/azure/cli/core/extension/operations.py:221

  • get_linux_distro() returns version_id from /etc/os-release, which may be '4' (no dot) or include surrounding whitespace. The current startswith('4.') check can miss Azure Linux 4 and skip installing psycopg2 build deps. Consider normalizing distversion and checking major version more robustly.
        distname, distversion = get_linux_distro()
        distname = (distname or '').lower().strip()
        distversion = distversion or ''
        is_azure_linux_4 = 'azure linux' in distname and distversion.startswith('4.')

src/azure-cli-core/azure/cli/core/extension/operations.py:270

  • The warning says the packages "will be installed ... if not present", but this branch always runs tdnf install unconditionally. Either add an installed-check (like the DEB path does) or adjust the message to avoid implying conditional behavior.
                logger.warning(
                    'This extension depends on %s and they will be installed first if not present.',
                    ' '.join(rpm_packages)
                )

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

scripts/release/rpm/azurelinux.dockerfile:32

  • The RPM_PATH=$(...) || RPM_PATH="" fallback is ineffective because a variable assignment returns a successful status, so the || branch will never run. Also, find can exit non-zero when any of the searched base directories is missing, which can make this step brittle if the shell is ever run with -e semantics.

Simplify the assignment and explicitly ignore find failures while still allowing the later -z "$RPM_PATH" guard to handle the "not found" case.

    RPM_PATH=$(find /usr/src/azl/RPMS /root/rpmbuild/RPMS -type f -name "azure-cli-${cli_version}-1.*.rpm" 2>/dev/null | head -n 1) || RPM_PATH="" && \

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants