Skip to content

Instantly share code, notes, and snippets.

@yannhowe
Created July 23, 2024 09:46
Show Gist options
  • Save yannhowe/0605eb1ef46e11c4c16fe3155c644e3e to your computer and use it in GitHub Desktop.
Save yannhowe/0605eb1ef46e11c4c16fe3155c644e3e to your computer and use it in GitHub Desktop.
Count Azure ACI containers
#!/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