Skip to content

Commit ba65c5f

Browse files
Merge pull request #77 from microsoft/enhancement/azure-script-verbose-model-region-params
feat: add --models, --regions, and --verbose support
2 parents 35b7359 + f8512e9 commit ba65c5f

File tree

2 files changed

+91
-31
lines changed

2 files changed

+91
-31
lines changed

docs/quota_check.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
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 200K tokens for optimal performance.**
5+
6+
### Login if you have not done so already
7+
```
8+
azd auth login
9+
```
10+
411

512
### 📌 Default Models & Capacities:
613
```
7-
gpt-4o:30, gpt-4:30
14+
gpt-4o:5
815
```
916
### 📌 Default Regions:
1017
```
@@ -15,27 +22,34 @@ eastus, uksouth, eastus2, northcentralus, swedencentral, westus, westus2, southc
1522
- Only model(s) provided → The script will check for those models in the default regions.
1623
- Only region(s) provided → The script will check default models in the specified regions.
1724
- 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.
1826

1927
### **Input Formats**
20-
✔️ 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:
2131
```
2232
./quota_check_params.sh
2333
```
24-
✔️ 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:
2539
```
26-
./quota_check_params.sh gpt-4o:30
40+
./quota_check_params.sh --models gpt-4o:30
2741
```
28-
✔️ Multiple models can be passed, separated by commas:
42+
✔️ Check default models in specific region(s):
2943
```
30-
./quota_check_params.sh gpt-4o:30,gpt-4:80
44+
./quota_check_params.sh --regions eastus,westus
3145
```
3246
✔️ Passing Both models and regions:
3347
```
34-
./quota_check_params.sh gpt-4o:30 eastus,westus2
48+
./quota_check_params.sh --models gpt-4o:30 --regions eastus,westus2
3549
```
36-
✔️ Check default models in specific regions:
50+
✔️ All parameters combined:
3751
```
38-
./quota_check_params.sh "" eastus,westus2
52+
./quota_check_params.sh --models gpt-4:30 --regions eastus,westus --verbose
3953
```
4054

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

scripts/quota_check_params.sh

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,52 @@
11
#!/bin/bash
22

3-
# Default Models and Capacities (Comma-separated in "model:capacity" format)
4-
DEFAULT_MODEL_CAPACITY="gpt-4o:30,gpt-4:30"
3+
MODELS=""
4+
REGIONS=""
5+
VERBOSE=false
6+
7+
while [[ $# -gt 0 ]]; do
8+
case "$1" in
9+
--models)
10+
MODELS="$2"
11+
shift 2
12+
;;
13+
--regions)
14+
REGIONS="$2"
15+
shift 2
16+
;;
17+
--verbose)
18+
VERBOSE=true
19+
shift
20+
;;
21+
*)
22+
echo "Unknown option: $1"
23+
exit 1
24+
;;
25+
esac
26+
done
27+
28+
# Fallback to defaults if not provided
29+
[[ -z "$MODELS" ]]
30+
[[ -z "$REGIONS" ]]
531

32+
echo "Models: $MODELS"
33+
echo "Regions: $REGIONS"
34+
echo "Verbose: $VERBOSE"
35+
36+
for arg in "$@"; do
37+
if [ "$arg" = "--verbose" ]; then
38+
VERBOSE=true
39+
fi
40+
done
41+
42+
log_verbose() {
43+
if [ "$VERBOSE" = true ]; then
44+
echo "$1"
45+
fi
46+
}
47+
48+
# Default Models and Capacities (Comma-separated in "model:capacity" format)
49+
DEFAULT_MODEL_CAPACITY="gpt-4o:5"
650
# Convert the comma-separated string into an array
751
IFS=',' read -r -a MODEL_CAPACITY_PAIRS <<< "$DEFAULT_MODEL_CAPACITY"
852

@@ -41,6 +85,7 @@ else
4185
done
4286
fi
4387

88+
4489
# Set the selected subscription
4590
az account set --subscription "$AZURE_SUBSCRIPTION_ID"
4691
echo "🎯 Active Subscription: $(az account show --query '[name, id]' --output tsv)"
@@ -50,8 +95,8 @@ DEFAULT_REGIONS="eastus,uksouth,eastus2,northcentralus,swedencentral,westus,west
5095
IFS=',' read -r -a DEFAULT_REGION_ARRAY <<< "$DEFAULT_REGIONS"
5196

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

56101
IS_USER_PROVIDED_PAIRS=false
57102

@@ -99,12 +144,12 @@ INDEX=1
99144

100145
VALID_REGIONS=()
101146
for REGION in "${REGIONS[@]}"; do
102-
echo "----------------------------------------"
103-
echo "🔍 Checking region: $REGION"
147+
log_verbose "----------------------------------------"
148+
log_verbose "🔍 Checking region: $REGION"
104149

105150
QUOTA_INFO=$(az cognitiveservices usage list --location "$REGION" --output json | tr '[:upper:]' '[:lower:]')
106151
if [ -z "$QUOTA_INFO" ]; then
107-
echo "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping."
152+
log_verbose "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping."
108153
continue
109154
fi
110155

@@ -127,7 +172,7 @@ for REGION in "${REGIONS[@]}"; do
127172
for MODEL_TYPE in "${MODEL_TYPES[@]}"; do
128173
FOUND=false
129174
INSUFFICIENT_QUOTA=false
130-
echo "🔍 Checking model: $MODEL_NAME with required capacity: $REQUIRED_CAPACITY ($MODEL_TYPE)"
175+
log_verbose "🔍 Checking model: $MODEL_NAME with required capacity: $REQUIRED_CAPACITY ($MODEL_TYPE)"
131176

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

137182
if [ -z "$MODEL_INFO" ]; then
138183
FOUND=false
139-
echo "⚠️ WARNING: No quota information found for model: $MODEL_NAME in region: $REGION for model type: $MODEL_TYPE."
184+
log_verbose "⚠️ WARNING: No quota information found for model: $MODEL_NAME in region: $REGION for model type: $MODEL_TYPE."
140185
continue
141186
fi
142187

@@ -152,29 +197,30 @@ for REGION in "${REGIONS[@]}"; do
152197
LIMIT=$(echo "$LIMIT" | cut -d'.' -f1)
153198

154199
AVAILABLE=$((LIMIT - CURRENT_VALUE))
155-
echo "✅ Model: $MODEL_TYPE | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE"
200+
log_verbose "✅ Model: $MODEL_TYPE | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE"
156201

157202
if [ "$AVAILABLE" -ge "$REQUIRED_CAPACITY" ]; then
158203
FOUND=true
159204
if [ "$MODEL_NAME" = "text-embedding-ada-002" ]; then
160205
TEXT_EMBEDDING_AVAILABLE=true
161206
fi
162207
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")")
208+
TEMP_TABLE_ROWS+=("$(printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |" "$INDEX" "$REGION" "$MODEL_TYPE" "$LIMIT" "$CURRENT_VALUE" "$AVAILABLE")")
164209
else
165210
INSUFFICIENT_QUOTA=true
166211
fi
167212
fi
168213

169214
if [ "$FOUND" = false ]; then
170-
echo "❌ No models found for model: $MODEL_NAME in region: $REGION (${MODEL_TYPES[*]})"
215+
log_verbose "❌ No models found for model: $MODEL_NAME in region: $REGION (${MODEL_TYPES[*]})"
216+
171217
elif [ "$INSUFFICIENT_QUOTA" = true ]; then
172-
echo "⚠️ Model $MODEL_NAME in region: $REGION has insufficient quota (${MODEL_TYPES[*]})."
218+
log_verbose "⚠️ Model $MODEL_NAME in region: $REGION has insufficient quota (${MODEL_TYPES[*]})."
173219
fi
174220
done
175221
done
176222

177-
if { [ "$IS_USER_PROVIDED_PAIRS" = true ] && [ "$INSUFFICIENT_QUOTA" = false ] && [ "$FOUND" = true ]; } || { [ "$TEXT_EMBEDDING_AVAILABLE" = true ] && { [ "$APPLY_OR_CONDITION" != true ] || [ "$AT_LEAST_ONE_MODEL_AVAILABLE" = true ]; }; }; then
223+
if { [ "$IS_USER_PROVIDED_PAIRS" = true ] && [ "$INSUFFICIENT_QUOTA" = false ] && [ "$FOUND" = true ]; } || { [ "$APPLY_OR_CONDITION" != true ] || [ "$AT_LEAST_ONE_MODEL_AVAILABLE" = true ]; }; then
178224
VALID_REGIONS+=("$REGION")
179225
TABLE_ROWS+=("${TEMP_TABLE_ROWS[@]}")
180226
INDEX=$((INDEX + 1))
@@ -185,18 +231,18 @@ if { [ "$IS_USER_PROVIDED_PAIRS" = true ] && [ "$INSUFFICIENT_QUOTA" = false ] &
185231
done
186232

187233
if [ ${#TABLE_ROWS[@]} -eq 0 ]; then
188-
echo "------------------------------------------------------------------------------------------------------------------"
234+
echo "--------------------------------------------------------------------------------------------------------------------"
189235

190236
echo "❌ No regions have sufficient quota for all required models. Please request a quota increase: https://aka.ms/oai/stuquotarequest"
191237
else
192-
echo "----------------------------------------------------------------------------------------------------------------------"
193-
printf "| %-4s | %-20s | %-45s | %-10s | %-10s | %-10s |\n" "No." "Region" "Model Name" "Limit" "Used" "Available"
194-
echo "----------------------------------------------------------------------------------------------------------------------"
238+
echo "---------------------------------------------------------------------------------------------------------------------"
239+
printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |\n" "No." "Region" "Model Name" "Limit" "Used" "Available"
240+
echo "---------------------------------------------------------------------------------------------------------------------"
195241
for ROW in "${TABLE_ROWS[@]}"; do
196242
echo "$ROW"
197243
done
198-
echo "----------------------------------------------------------------------------------------------------------------------"
244+
echo "---------------------------------------------------------------------------------------------------------------------"
199245
echo "➡️ To request a quota increase, visit: https://aka.ms/oai/stuquotarequest"
200246
fi
201247

202-
echo "✅ Script completed."
248+
echo "✅ Script completed."

0 commit comments

Comments
 (0)