#!/usr/bin/env bash
set -euo pipefail

# Validate Standard Dplsv6 Family vCPU usage via legacy VM usage API across non‑US commercial regions

REGIONS=(
  australiacentral
  australiaeast
  australiasoutheast
  austriaeast
  belgiumcentral
  brazilsouth
  canadacentral
  canadaeast
  centralindia
  chilecentral
  eastasia
  francecentral
  germanywestcentral
  indonesiacentral
  israelcentral
  italynorth
  japaneast
  japanwest
  koreacentral
  koreasouth
  malaysiawest
  mexicocentral
  newzealandnorth
  northeurope
  polandcentral
  qatarcentral
  southafricanorth
  southafricawest
  southeastasia
  southindia
  spaincentral
  switzerlandnorth
  switzerlandwest
  uaecentral
  uaenorth
  uksouth
  ukwest
  westeurope
  westindia
)

echo -e "Region\tName\tUsage\tLimit"
for region in "${REGIONS[@]}"; do
  echo "Checking $region..." 1>&2
  # List all usage rows, then filter by names containing Dpl and v6, print Name/Usage/Limit
  az vm list-usage --location "$region" --output tsv --query "[].{Name:name.localizedValue,Usage:currentValue,Limit:limit}" \
    | awk -v R="$region" -F '\t' 'tolower($1) ~ /dpl/ && tolower($1) ~ /v6/ { print R"\t"$1"\t"$2"\t"$3 }'
  sleep 0.2
done
