How to upgrade Azure CLI when MSI fails with "Failed to connect to server. Error: 0x80070005"


I need to update Azure CLI on a machine I don't administer but where I can run scripts remotely and thus I basically have CLI access. When using the recommended PowerShell script to install Azure CLI, modified so that is does not hang inside Invoke-WebRequest and so that it logs the installation details, I see the installation fails with log message "Failed to connect to server. Error: 0x80070005".

I looked up the error code 0x80070005 means "Access Denied by DCOM". I also read that the "server" is actually the Windows Installer service commanded by the msiexec client.

Is it possible to upgrade the Azure CLI without assistance of the machine's administrator? How to investigate further in this direction?

My script so far:

Invoke-WebRequest -Uri -OutFile AzureCLI.msi -UseBasicParsing
Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet /L*v! AzureCLI.log'
Get-Content AzureCLI.log
rm AzureCLI.msi, AzureCLI.log

The log is:

=== Verbose logging started: 3/12/2021  1:49:26  Build type: SHIP UNICODE 5.00.10011.00  Calling process: C:\windows\system32\msiexec.exe ===
MSI (c) (D4:F0) [01:49:26:301]: Resetting cached policy values
MSI (c) (D4:F0) [01:49:26:301]: Machine policy value 'Debug' is 0
MSI (c) (D4:F0) [01:49:26:301]: ******* RunEngine:
           ******* Product: AzureCLI.msi
           ******* Action: 
           ******* CommandLine: **********
MSI (c) (D4:F0) [01:49:26:317]: Client-side and UI is none or basic: Running entire install on the server.
MSI (c) (D4:F0) [01:49:26:317]: Grabbed execution mutex.
MSI (c) (D4:F0) [01:49:26:332]: Failed to connect to server. Error: 0x80070005

MSI (c) (D4:F0) [01:49:26:332]: Note: 1: 2774 2: 0x80070005 
1: 2774 2: 0x80070005 
MSI (c) (D4:F0) [01:49:26:332]: Failed to connect to server.
MSI (c) (D4:F0) [01:49:26:348]: MainEngineThread is returning 1601
=== Verbose logging stopped: 3/12/2021  1:49:26 ===

In the past, I was able to install Azure CLI on several such machines from scratch, using the above mentioned recommended PowerShell oneliner. The machine is an Azure DevOps Server agent and I can edit and run Azure Pipelines that use it. I know I should best ask the administrators, but they are in a separate department of the enterprise and they are notoriously inaccessible, unreliable and they let everyone jump through stupid meaningless hoops. Our Scrum team found it is usually most efficient when we ourselves take care of everything we technically can and only ask them for things only they can do.

Thought about using az upgrade, but it calls powershell.exe -NoProfile "Start-Process msiexec.exe -Wait -ArgumentList '/i'" under the hood, which is not an unattended installation (/quiet is missing). It saves the MSI download when the current version is already installed and handles also other package managers on other OSes, but I don't need any of this right now.

Also thought about using a tool installer task but I do not know about any for Azure CLI, certainly not in our DevOps Server.

asked on Stack Overflow Mar 12, 2021 by Palec

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0