Created
July 23, 2024 09:46
-
-
Save yannhowe/0605eb1ef46e11c4c16fe3155c644e3e to your computer and use it in GitHub Desktop.
Count Azure ACI containers
This file contains hidden or 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
#!/bin/bash | |
# Count ACI containers | |
RESOURCE_GROUP="" | |
TOTAL_CONTAINERS=0 | |
CONTAINER_COUNT=0 | |
echo "\$CONTAINER_RESOURCEGROUP | \$CONTAINER_NAME | \$CONTAINER_COUNT" | |
while IFS=$'\t' read -r CONTAINER_NAME CONTAINER_RESOURCEGROUP ; do | |
echo "$CONTAINER_RESOURCEGROUP | $CONTAINER_NAME | $CONTAINER_COUNT" | |
CONTAINER_COUNT="$(az container show -n $CONTAINER_NAME -g $CONTAINER_RESOURCEGROUP --query 'length(containers)')" | |
TOTAL_CONTAINERS=$(($TOTAL_CONTAINERS + $CONTAINER_COUNT)) | |
done <<< "$(az container list --query "[].[name, resourceGroup]" -o tsv)" | |
echo "Total: $TOTAL_CONTAINERS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment