Skip to content

Commit 5e425e6

Browse files
Merge pull request #79 from microsoft/enhancement/azure-script-verbose-model-region-params
feat: add --models, --regions, and --verbose support
2 parents d6a0ee5 + dcfbaab commit 5e425e6

File tree

2 files changed

+83
-27
lines changed

2 files changed

+83
-27
lines changed

docs/quota_check.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
## Check Quota Availability Before Deployment
22

3-
Before deploying the accelerator, **ensure sufficient quota availability** for the required model.
3+
Before deploying the accelerator, **ensure sufficient quota availability** for the required model.
4+
> **For Global Standard | GPT-4o - the capacity to at least 30K tokens for optimal performance.**
45
56
### Login if you have not done so already
67
```
78
azd auth login
89
```
910

11+
1012
### 📌 Default Models & Capacities:
1113
```
1214
gpt-4o:30
@@ -20,27 +22,34 @@ eastus, uksouth, eastus2, northcentralus, swedencentral, westus, westus2, southc
2022
- Only model(s) provided → The script will check for those models in the default regions.
2123
- Only region(s) provided → The script will check default models in the specified regions.
2224
- Both models and regions provided → The script will check those models in the specified regions.
25+
- `--verbose` passed → Enables detailed logging output for debugging and traceability.
2326

2427
### **Input Formats**
25-
✔️ Run without parameters to check default models & regions:
28+
> Use the --models, --regions, and --verbose options for parameter handling:
29+
30+
✔️ Run without parameters to check default models & regions without verbose logging:
2631
```
2732
./quota_check_params.sh
2833
```
29-
✔️ Model name and required capacity in the format:
34+
✔️ Enable verbose logging:
35+
```
36+
./quota_check_params.sh --verbose
37+
```
38+
✔️ Check specific model(s) in default regions:
3039
```
31-
./quota_check_params.sh gpt-4o:30
40+
./quota_check_params.sh --models gpt-4o:30
3241
```
33-
✔️ Multiple models can be passed, separated by commas:
42+
✔️ Check default models in specific region(s):
3443
```
35-
./quota_check_params.sh gpt-4o:30,text-embedding-ada-002:80
44+
./quota_check_params.sh --regions eastus,westus
3645
```
3746
✔️ Passing Both models and regions:
3847
```
39-
./quota_check_params.sh gpt-4o:30 eastus,westus2
48+
./quota_check_params.sh --models gpt-4o:30 --regions eastus,westus2
4049
```
41-
✔️ Check default models in specific regions:
50+
✔️ All parameters combined:
4251
```
43-
./quota_check_params.sh "" eastus,westus2
52+
./quota_check_params.sh --models gpt-4:30 --regions eastus,westus --verbose
4453
```
4554

4655
### **Sample Output**
@@ -88,4 +97,4 @@ The final table lists regions with available quota. You can select any of these
8897
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
8998
az login
9099
```
91-
6. Rerun the script after installing Azure CLI.
100+
6. Rerun the script after installing Azure CLI.

infra/scripts/quota_check_params.sh

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,53 @@
11
#!/bin/bash
2+
# VERBOSE=false
3+
4+
MODELS=""
5+
REGIONS=""
6+
VERBOSE=false
7+
8+
while [[ $# -gt 0 ]]; do
9+
case "$1" in
10+
--models)
11+
MODELS="$2"
12+
shift 2
13+
;;
14+
--regions)
15+
REGIONS="$2"
16+
shift 2
17+
;;
18+
--verbose)
19+
VERBOSE=true
20+
shift
21+
;;
22+
*)
23+
echo "Unknown option: $1"
24+
exit 1
25+
;;
26+
esac
27+
done
28+
29+
# Fallback to defaults if not provided
30+
[[ -z "$MODELS" ]]
31+
[[ -z "$REGIONS" ]]
32+
33+
echo "Models: $MODELS"
34+
echo "Regions: $REGIONS"
35+
echo "Verbose: $VERBOSE"
36+
37+
for arg in "$@"; do
38+
if [ "$arg" = "--verbose" ]; then
39+
VERBOSE=true
40+
fi
41+
done
42+
43+
log_verbose() {
44+
if [ "$VERBOSE" = true ]; then
45+
echo "$1"
46+
fi
47+
}
248

349
# Default Models and Capacities (Comma-separated in "model:capacity" format)
450
DEFAULT_MODEL_CAPACITY="gpt-4o:30"
5-
651
# Convert the comma-separated string into an array
752
IFS=',' read -r -a MODEL_CAPACITY_PAIRS <<< "$DEFAULT_MODEL_CAPACITY"
853

@@ -41,6 +86,7 @@ else
4186
done
4287
fi
4388

89+
4490
# Set the selected subscription
4591
az account set --subscription "$AZURE_SUBSCRIPTION_ID"
4692
echo "🎯 Active Subscription: $(az account show --query '[name, id]' --output tsv)"
@@ -50,8 +96,8 @@ DEFAULT_REGIONS="eastus,uksouth,eastus2,northcentralus,swedencentral,westus,west
5096
IFS=',' read -r -a DEFAULT_REGION_ARRAY <<< "$DEFAULT_REGIONS"
5197

5298
# Read parameters (if any)
53-
IFS=',' read -r -a USER_PROVIDED_PAIRS <<< "$1"
54-
USER_REGION="$2"
99+
IFS=',' read -r -a USER_PROVIDED_PAIRS <<< "$MODELS"
100+
USER_REGION="$REGIONS"
55101

56102
IS_USER_PROVIDED_PAIRS=false
57103

@@ -99,12 +145,12 @@ INDEX=1
99145

100146
VALID_REGIONS=()
101147
for REGION in "${REGIONS[@]}"; do
102-
echo "----------------------------------------"
103-
echo "🔍 Checking region: $REGION"
148+
log_verbose "----------------------------------------"
149+
log_verbose "🔍 Checking region: $REGION"
104150

105151
QUOTA_INFO=$(az cognitiveservices usage list --location "$REGION" --output json | tr '[:upper:]' '[:lower:]')
106152
if [ -z "$QUOTA_INFO" ]; then
107-
echo "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping."
153+
log_verbose "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping."
108154
continue
109155
fi
110156

@@ -127,7 +173,7 @@ for REGION in "${REGIONS[@]}"; do
127173
for MODEL_TYPE in "${MODEL_TYPES[@]}"; do
128174
FOUND=false
129175
INSUFFICIENT_QUOTA=false
130-
echo "🔍 Checking model: $MODEL_NAME with required capacity: $REQUIRED_CAPACITY ($MODEL_TYPE)"
176+
log_verbose "🔍 Checking model: $MODEL_NAME with required capacity: $REQUIRED_CAPACITY ($MODEL_TYPE)"
131177

132178
MODEL_INFO=$(echo "$QUOTA_INFO" | awk -v model="\"value\": \"$MODEL_TYPE\"" '
133179
BEGIN { RS="},"; FS="," }
@@ -136,7 +182,7 @@ for REGION in "${REGIONS[@]}"; do
136182

137183
if [ -z "$MODEL_INFO" ]; then
138184
FOUND=false
139-
echo "⚠️ WARNING: No quota information found for model: $MODEL_NAME in region: $REGION for model type: $MODEL_TYPE."
185+
log_verbose "⚠️ WARNING: No quota information found for model: $MODEL_NAME in region: $REGION for model type: $MODEL_TYPE."
140186
continue
141187
fi
142188

@@ -152,24 +198,25 @@ for REGION in "${REGIONS[@]}"; do
152198
LIMIT=$(echo "$LIMIT" | cut -d'.' -f1)
153199

154200
AVAILABLE=$((LIMIT - CURRENT_VALUE))
155-
echo "✅ Model: $MODEL_TYPE | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE"
201+
log_verbose "✅ Model: $MODEL_TYPE | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE"
156202

157203
if [ "$AVAILABLE" -ge "$REQUIRED_CAPACITY" ]; then
158204
FOUND=true
159205
if [ "$MODEL_NAME" = "text-embedding-ada-002" ]; then
160206
TEXT_EMBEDDING_AVAILABLE=true
161207
fi
162208
AT_LEAST_ONE_MODEL_AVAILABLE=true
163-
TEMP_TABLE_ROWS+=("$(printf "| %-4s | %-20s | %-45s | %-10s | %-10s | %-10s |" "$INDEX" "$REGION" "$MODEL_TYPE" "$LIMIT" "$CURRENT_VALUE" "$AVAILABLE")")
209+
TEMP_TABLE_ROWS+=("$(printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |" "$INDEX" "$REGION" "$MODEL_TYPE" "$LIMIT" "$CURRENT_VALUE" "$AVAILABLE")")
164210
else
165211
INSUFFICIENT_QUOTA=true
166212
fi
167213
fi
168214

169215
if [ "$FOUND" = false ]; then
170-
echo "❌ No models found for model: $MODEL_NAME in region: $REGION (${MODEL_TYPES[*]})"
216+
log_verbose "❌ No models found for model: $MODEL_NAME in region: $REGION (${MODEL_TYPES[*]})"
217+
171218
elif [ "$INSUFFICIENT_QUOTA" = true ]; then
172-
echo "⚠️ Model $MODEL_NAME in region: $REGION has insufficient quota (${MODEL_TYPES[*]})."
219+
log_verbose "⚠️ Model $MODEL_NAME in region: $REGION has insufficient quota (${MODEL_TYPES[*]})."
173220
fi
174221
done
175222
done
@@ -185,17 +232,17 @@ if { [ "$IS_USER_PROVIDED_PAIRS" = true ] && [ "$INSUFFICIENT_QUOTA" = false ] &
185232
done
186233

187234
if [ ${#TABLE_ROWS[@]} -eq 0 ]; then
188-
echo "------------------------------------------------------------------------------------------------------------------"
235+
echo "--------------------------------------------------------------------------------------------------------------------"
189236

190237
echo "❌ No regions have sufficient quota for all required models. Please request a quota increase: https://aka.ms/oai/stuquotarequest"
191238
else
192-
echo "----------------------------------------------------------------------------------------------------------------------"
193-
printf "| %-4s | %-20s | %-45s | %-10s | %-10s | %-10s |\n" "No." "Region" "Model Name" "Limit" "Used" "Available"
194-
echo "----------------------------------------------------------------------------------------------------------------------"
239+
echo "---------------------------------------------------------------------------------------------------------------------"
240+
printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |\n" "No." "Region" "Model Name" "Limit" "Used" "Available"
241+
echo "---------------------------------------------------------------------------------------------------------------------"
195242
for ROW in "${TABLE_ROWS[@]}"; do
196243
echo "$ROW"
197244
done
198-
echo "----------------------------------------------------------------------------------------------------------------------"
245+
echo "---------------------------------------------------------------------------------------------------------------------"
199246
echo "➡️ To request a quota increase, visit: https://aka.ms/oai/stuquotarequest"
200247
fi
201248

0 commit comments

Comments
 (0)