Azure / azure-cli

Azure Command-Line Interface
MIT License
4k stars 2.97k forks source link

Please improve feedback on az upgrade for better experience #29632

Open softchris opened 2 months ago

softchris commented 2 months ago

Related command az upgrade

Is your feature request related to a problem? Please describe.

Updating Azure CLI with MSI from https://aka.ms/installazurecliwindows
Downloading MSI to C:\<user>\AppData\Local\Temp\tmp6ac0qfjo\azure-cli-2.62.0.msi
Installing MSI

Describe the solution you'd like

Thank you for considering

Describe alternatives you've considered

Additional context

yonzhan commented 2 months ago

Thank you for opening this issue, we will look into it.

bebound commented 2 months ago

For progress update, add it to feature request list. For silent mode, it's not possible.

  1. For non-admin user, the UAC window always pops up. See https://github.com/Azure/azure-cli/issues/16617
  2. az exits when installing MSI; otherwise, some files are still in use and the installation fails. See https://github.com/Azure/azure-cli/issues/22741. If we use silent mode, the user won't be able to know whether the installation has finished.
dinowang commented 1 month ago

az upgrade also support update extensions by using --all option.

When I use az upgrade --all to upgrade extesions. It take a lot of time to perform version checking one-by-one.

Since we do have installed version list and available version list. Should can metadata rather than check online for each extensions.

I don't use az upgrade --all now. Use script is faster

  remote_versions=$(az extension list-available --query "[?installed].{name:name, version:version}")
  local_versions=$(az extension list --query "[].{name:name, installed_version:version}")

  versions=$(jq -n --argjson local "$local_versions" --argjson remote "$remote_versions" '
    [$local, $remote] | 
    transpose | 
    map({
      name: .[0].name,
      installed_version: .[0].installed_version,
      version: .[1].version
    })
  ')

  outdated=$(echo "$versions" | jq -r '.[] | select(.installed_version != .version) | .name')

  if [ "$outdated" == "" ];
  then
    echo "No outdated azcli extensions found."
  else
    for name in $(echo "$outdated" | awk '{gsub(/\\r\\n/,RS)} 1'); do
      echo az extension update --name "$name" --allow-preview true --verbose
      az extension update --name "$name" --allow-preview true --verbose
    done
  fi