11#! /bin/bash
22
3- # Parameters
3+ # Default Models and Capacities (Comma-separated)
4+ DEFAULT_MODELS=" gpt-4o,text-embedding-ada-002,gpt-4"
5+ DEFAULT_CAPACITY=" 30,80,30" # Each model will be paired with a capacity in order
6+
7+ # Convert the comma-separated strings into arrays
8+ IFS=' ,' read -r -a MODEL_NAMES <<< " $DEFAULT_MODELS"
9+ IFS=' ,' read -r -a CAPACITIES <<< " $DEFAULT_CAPACITY"
10+
11+ # Default Regions to check (Comma-separated, now configurable)
12+ DEFAULT_REGIONS=" eastus,uksouth,eastus2,northcentralus,swedencentral,westus,westus2,southcentralus,canadacentral"
13+ IFS=' ,' read -r -a DEFAULT_REGION_ARRAY <<< " $DEFAULT_REGIONS" # Split into an array
14+
15+ # Read parameters (if any)
416IFS=' ,' read -r -a MODEL_CAPACITY_PAIRS <<< " $1" # Split the comma-separated model and capacity pairs into an array
517USER_REGION=" $2 "
618
19+ # If no parameters are passed, use default models and regions
720if [ ${# MODEL_CAPACITY_PAIRS[@]} -lt 1 ]; then
8- echo " ❌ ERROR: At least one model and capacity pairs must be provided as arguments."
9- exit 1
21+ echo " No parameters provided, using default models: ${MODEL_NAMES[*]} with respective capacities: ${CAPACITIES[*]} "
22+ # Use default models and their respective capacities
23+ for i in " ${! MODEL_NAMES[@]} " ; do
24+ MODEL_CAPACITY_PAIRS+=(" ${MODEL_NAMES[$i]} :${CAPACITIES[$i]} " )
25+ done
26+ else
27+ echo " Using provided model and capacity pairs: ${MODEL_CAPACITY_PAIRS[*]} "
1028fi
1129
1230# Extract model names and required capacities into arrays
13- declare -a MODEL_NAMES
14- declare -a CAPACITIES
31+ declare -a FINAL_MODEL_NAMES
32+ declare -a FINAL_CAPACITIES
1533
1634for PAIR in " ${MODEL_CAPACITY_PAIRS[@]} " ; do
1735 MODEL_NAME=$( echo " $PAIR " | cut -d' :' -f1)
@@ -22,11 +40,11 @@ for PAIR in "${MODEL_CAPACITY_PAIRS[@]}"; do
2240 exit 1
2341 fi
2442
25- MODEL_NAMES +=(" $MODEL_NAME " )
26- CAPACITIES +=(" $CAPACITY " )
43+ FINAL_MODEL_NAMES +=(" $MODEL_NAME " )
44+ FINAL_CAPACITIES +=(" $CAPACITY " )
2745done
2846
29- echo " 🔄 Using Models: ${MODEL_NAMES [*]} with respective Capacities: ${CAPACITIES [*]} "
47+ echo " 🔄 Using Models: ${FINAL_MODEL_NAMES [*]} with respective Capacities: ${FINAL_CAPACITIES [*]} "
3048
3149echo " 🔄 Fetching available Azure subscriptions..."
3250SUBSCRIPTIONS=$( az account list --query " [?state=='Enabled'].{Name:name, ID:id}" --output tsv)
5876
5977# Set the selected subscription
6078az account set --subscription " $AZURE_SUBSCRIPTION_ID "
61- echo " 🎯 Active Subscription: $( az account show --query ' [name, id]' --output table) "
62-
63- # List of regions to check
64- DEFAULT_REGIONS=(" eastus" " uksouth" " eastus2" " northcentralus" " swedencentral" " westus" " westus2" " southcentralus" " canadacentral" )
79+ echo " 🎯 Active Subscription: $( az account show --query ' [name, id]' --output tsv) "
6580
66- # Prioritize user- provided region if given
81+ # Check if the user provided a region, if not, use the default regions
6782if [ -n " $USER_REGION " ]; then
68- # Ensure the user- provided region is checked first
69- REGIONS=( " $USER_REGION " " ${DEFAULT_REGIONS[@]} " )
83+ echo " 🔍 User provided region: $USER_REGION "
84+ IFS= ' , ' read -r -a REGIONS <<< " $USER_REGION" # Split into an array using comma
7085else
71- REGIONS=(" ${DEFAULT_REGIONS[@]} " )
86+ echo " No region specified, using default regions: ${DEFAULT_REGION_ARRAY[*]} "
87+ REGIONS=(" ${DEFAULT_REGION_ARRAY[@]} " )
7288fi
7389
7490echo " ✅ Retrieved Azure regions. Checking availability..."
91+ declare -a TABLE_ROWS
92+ INDEX=1
7593
7694VALID_REGIONS=()
7795for REGION in " ${REGIONS[@]} " ; do
@@ -85,13 +103,13 @@ for REGION in "${REGIONS[@]}"; do
85103 continue
86104 fi
87105
88- # Initialize a flag to track if both models have sufficient quota in the region
89- BOTH_MODELS_AVAILABLE=true
106+ # Initialize a flag to track if all models have sufficient quota in the region
107+ ALL_MODELS_AVAILABLE=true
108+
109+ for index in " ${! FINAL_MODEL_NAMES[@]} " ; do
110+ MODEL_NAME=" ${FINAL_MODEL_NAMES[$index]} "
111+ REQUIRED_CAPACITY=" ${FINAL_CAPACITIES[$index]} "
90112
91- for index in " ${! MODEL_NAMES[@]} " ; do
92- MODEL_NAME=" ${MODEL_NAMES[$index]} "
93- REQUIRED_CAPACITY=" ${CAPACITIES[$index]} "
94-
95113 echo " 🔍 Checking model: $MODEL_NAME with required capacity: $REQUIRED_CAPACITY "
96114
97115 # Extract model quota information
@@ -102,7 +120,7 @@ for REGION in "${REGIONS[@]}"; do
102120
103121 if [ -z " $MODEL_INFO " ]; then
104122 echo " ⚠️ WARNING: No quota information found for model: OpenAI.Standard.$MODEL_NAME in $REGION . Skipping."
105- BOTH_MODELS_AVAILABLE =false
123+ ALL_MODELS_AVAILABLE =false
106124 break # If any model is not available, no need to check further for this region
107125 fi
108126
@@ -123,37 +141,30 @@ for REGION in "${REGIONS[@]}"; do
123141 if [ " $AVAILABLE " -lt " $REQUIRED_CAPACITY " ]; then
124142 echo " ❌ ERROR: 'OpenAI.Standard.$MODEL_NAME ' in $REGION has insufficient quota. Required: $REQUIRED_CAPACITY , Available: $AVAILABLE "
125143 echo " ➡️ To request a quota increase, visit: https://aka.ms/oai/stuquotarequest"
126- BOTH_MODELS_AVAILABLE=false
127- break
144+ ALL_MODELS_AVAILABLE=false
145+ else
146+ TABLE_ROWS+=(" $( printf " | %-4s | %-20s | %-35s | %-10s | %-10s | %-10s |" " $INDEX " " $REGION " " $MODEL_NAME " " $LIMIT " " $CURRENT_VALUE " " $AVAILABLE " ) " )
147+
148+ INDEX=$(( INDEX + 1 ))
128149 fi
129150 done
130151
131- # If both models have sufficient quota, add region to valid regions
132- if [ " $BOTH_MODELS_AVAILABLE " = true ]; then
152+ # If all models have sufficient quota, add region to valid regions
153+ if [ " $ALL_MODELS_AVAILABLE " = true ]; then
133154 echo " ✅ All models have sufficient quota in $REGION ."
134155 VALID_REGIONS+=(" $REGION " )
135156 fi
136157done
137158
138- # Determine final result and display in table format
139- if [ ${# VALID_REGIONS[@]} -eq 0 ]; then
140- echo " ----------------------------------------"
141- echo " ❌ No region with sufficient quota found for all models. Blocking deployment."
142- echo " ----------------------------------------"
143- exit 0
144- else
145- echo " ----------------------------------------"
146- echo " ✅ Suggested Regions with Sufficient Quota"
147- echo " ----------------------------------------"
148- printf " | %-5s | %-20s |\n" " No." " Region"
149- echo " ----------------------------------------"
150-
151- INDEX=1
152- for REGION in " ${VALID_REGIONS[@]} " ; do
153- printf " | %-5s | %-20s |\n" " $INDEX " " $REGION "
154- INDEX=$(( INDEX + 1 ))
155- done
156-
157- echo " ----------------------------------------"
158- exit 0
159- fi
159+ # Print table header
160+ echo " ----------------------------------------------------------------------------------------------------------"
161+ printf " | %-4s | %-20s | %-35s | %-10s | %-10s | %-10s |\n" " No." " Region" " Model Name" " Limit" " Used" " Available"
162+ echo " ----------------------------------------------------------------------------------------------------------"
163+
164+ for ROW in " ${TABLE_ROWS[@]} " ; do
165+ echo " $ROW "
166+ done
167+
168+ echo " ----------------------------------------------------------------------------------------------------------"
169+ echo " ➡️ To request a quota increase, visit: https://aka.ms/oai/stuquotarequest"
170+ echo " ✅ Script completed."
0 commit comments