azure-cli
azure-cli copied to clipboard
Use `az upgrade` in quiet mode
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.
hi @fengzhou-msft could you pls share the config to silently upgrade? thanks
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 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.
@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
Same here. I need the ability to update agents without user interaction.
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.
Same here. Managing servers where Azure CLI needs updating is nightmare - cannot be automated.
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?
I need to fix https://github.com/Azure/azure-cli/issues/22741 first.
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 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 Hey, I update my previous comment a bit. Does this command solve the problem?
@bebound I'll give it a go, but it feels like a workaround
This is very annoying, I can't update all my agents remotely. It's devops now days not clickops!
@toby-freemarket Please try https://github.com/Azure/azure-cli/issues/16617#issuecomment-1554316113
@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 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 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 :)