Skip to content

Conversation

@jiasli
Copy link
Member

@jiasli jiasli commented Aug 11, 2021

Symptom

Fix #19171, #18566

Directly installing from URL may be blocked by policy: #19171. The exact reason for the failure is unclear, and installing MSI from a URL is always problematic.

Change

Download MSI to a temp folder and install it with msiexec.exe. This also gives the user a chance to manually install the MSI in case of msiexec.exe failure.

Testing Guide

In upgrade_version, after retrieving the installer:

force

local_version = '2.26.0'
installer = 'MSI'

so that _upgrade_on_windows can be triggered.

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

A couple nits, but overall LGTM. Thanks!

Directly installing from URL may be blocked by policy: https://github.com/Azure/azure-cli/issues/19171
This also gives the user a chance to manually install the MSI in case of msiexec.exe failure.
"""
logger.warning("Updating Azure CLI with MSI from https://aka.ms/installazurecliwindows")
Copy link
Member

Choose a reason for hiding this comment

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

This was logger.debug before. Intentional change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

I want the command to be more explicit and give the user more information about what it is doing internally. Otherwise, in case of failure, all that the user can see is CLI upgrade failed. (No different from Something occurred.)

To view the details, the user must specify --debug which is definitely not user-friendly.

import tempfile
tmp_dir = tempfile.mkdtemp()
msi_path = os.path.join(tmp_dir, file_name)
logger.warning("Downloading MSI to %s", msi_path)
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, isn't this more of a logger.debug?

Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above.

@jiasli jiasli merged commit 7f89f1d into Azure:dev Aug 31, 2021
@jiasli jiasli deleted the upgrade-msi branch August 31, 2021 03:14
"or run 'pip install --upgrade azure-cli' in this container")
elif installer == 'MSI':
logger.debug("Update azure cli with MSI from https://aka.ms/installazurecliwindows")
exit_code = subprocess.call(['powershell.exe', '-NoProfile', "Start-Process msiexec.exe -Wait -ArgumentList '/i https://aka.ms/installazurecliwindows'"]) # pylint: disable=line-too-long
Copy link
Member Author

Choose a reason for hiding this comment

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

There is no need to launch PowerShell and let it launch msiexec.exe. Directly launching msiexec.exe is sufficient.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az upgrade fails on Windows 10: The system administrator has set policies to prevent this installation.

5 participants