azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

Use `az upgrade` in quiet mode

Open cnovel opened this issue 4 years ago • 6 comments

Is your feature request related to a problem? Please describe. I'd like to use az upgrade without the need of human intervention on Windows. Currently, running az upgrade -y --all still prompts a dialog where you have to accept license and click on next.

Describe the solution you'd like az upgrade --yes --all --quiet upgrades all the az cli quietly, without any dialog or human interaction.

Describe alternatives you've considered ~~Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi would be doable, but it is way less elegant, and not cross platform.~~ Scratch that, I just tried and it doesn't work for updating from 2.16.0 to 2.18.0.

cnovel avatar Jan 21 '21 09:01 cnovel

hi @fengzhou-msft could you pls share the config to silently upgrade? thanks

yungezz avatar Jan 21 '21 13:01 yungezz

You can use --only-show-errors to suppress warnings and infos from Azure CLI. But admin privilege is needed with user confirmation or password when updating MSI, Debian and RPM packages.

BTW, for the command to update MSI quietly, you need to start the Powershell as admin.

fengzhou-msft avatar Jan 27 '21 15:01 fengzhou-msft

@fengzhou-msft I tried using PS and CMD as admin and ran the below without success. az upgrade -y --all --only-show-errors and az upgrade -y --only-show-errors

It started the MSI dialog and asked me to accept the license and click next to continue as mentioned in the issue description.

abhi-msft avatar Jul 15 '21 02:07 abhi-msft

@jiasli Any updates on this issue?

I'm trying to setup an automated process to update our self-hosted Azure DevOps agents. This 'accept license->next' is the only stopper that remains for us.

Thx

sburbano avatar May 05 '22 11:05 sburbano

Same here. I need the ability to update agents without user interaction.

celluj34 avatar May 16 '22 19:05 celluj34

Hello, I have same problem. I am using multiple agents and I need uprade azure client there automatically without use interaction. There is no problem run powershell as administrator.

fridrichovsky avatar Aug 12 '22 13:08 fridrichovsky

Same here. Managing servers where Azure CLI needs updating is nightmare - cannot be automated.

geidans avatar Oct 01 '22 08:10 geidans

Yes please. Probably we need an accepteula or something too

az upgrade -y --all --only-show-errors --accepteula

Ubuntu users get to install and update az via apt. No fair :( winget?

ncook-hxgn avatar Mar 01 '23 13:03 ncook-hxgn

I need to fix https://github.com/Azure/azure-cli/issues/22741 first.

bebound avatar Mar 02 '23 03:03 bebound

Reviewing this issue again, I found that the UAC windows during installation is required for non-admin user. This is a OS behavior, we have nothing to do about it. You can the disccusion in winget: https://github.com/microsoft/winget-cli/issues/218 So adding this parameter is not of much use.

For admin user, you can use this command to update CLI to latest version without prompt, then run az upgrade again to update extensions. $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; Remove-Item .\AzureCLI.msi

Ref: https://review.learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?branch=live&tabs=powershell#powershell

bebound avatar May 19 '23 09:05 bebound

@bebound the problem is that even an admin user using the CLI must still check a box in a dialog to accept the license, which means admin users can't automate the use of the CLI to update update az across multiple machines with e.g. Invoke-Command, or even something more complex like ansible. That's why we need an --accepteula, like SysInternals and many other things: to prevent the need for a dialog, not to avoid UAC.

ncook-hxgn avatar May 19 '23 09:05 ncook-hxgn

@ncook-hxgn Hey, I update my previous comment a bit. Does this command solve the problem?

bebound avatar May 22 '23 02:05 bebound

@bebound I'll give it a go, but it feels like a workaround

ncook-hxgn avatar May 23 '23 09:05 ncook-hxgn

This is very annoying, I can't update all my agents remotely. It's devops now days not clickops!

toby-freemarket avatar May 31 '23 14:05 toby-freemarket

@toby-freemarket Please try https://github.com/Azure/azure-cli/issues/16617#issuecomment-1554316113

bebound avatar Jun 02 '23 02:06 bebound

@toby-freemarket Please try #16617 (comment)

I've tried this command as admin, but it doesn't work. The msiexec process starts, but it seems to hang and never actually installs/updates anything, and eventually dies.

jasonfy2k avatar Jun 06 '23 11:06 jasonfy2k

@jasonfy2k This should not happen. Do you have any system policy prevents the MSI installation, are you able to install the MSI manually as admin?

bebound avatar Jun 06 '23 12:06 bebound

@bebound my mistake, I was running the process under the wrong user. It would still be nice to have a native flag built-in to handle this, but your solution works for me, thank you :)

jasonfy2k avatar Jun 06 '23 13:06 jasonfy2k