Last active
September 3, 2024 16:52
-
-
Save dinowang/8a2818c6efea515f6cf5005dbfb54807 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_update-az-extensions() { | |
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment