Skip to content

Instantly share code, notes, and snippets.

@dinowang
Last active June 2, 2025 02:53
Show Gist options
  • Save dinowang/fb51fec722760be626890dda4c5bba17 to your computer and use it in GitHub Desktop.
Save dinowang/fb51fec722760be626890dda4c5bba17 to your computer and use it in GitHub Desktop.
#!/bin/bash
az upgrade --all false
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" '
reduce $local[] as $l (
{};
.[$l.name] = {
name: $l.name,
installed_version: $l.installed_version,
version: ($remote[] | select(.name == $l.name) | .version)
}
)
')
outdated=$(echo "$versions" | jq -r '.[] | select(.installed_version != .version) | .name + "," + .version')
if [ "$outdated" = "" ]; then
echo "No outdated azcli extensions found."
else
for line in $(echo $outdated); do
name=$(echo $line | cut -d, -f1)
version=$(echo $line | cut -d, -f2)
echo az extension update --name "$name" --allow-preview true --verbose
echo $version release history: https://github.com/Azure/azure-cli-extensions/blob/main/src/$name/HISTORY.rst
az extension update --name "$name" --allow-preview true --verbose
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment