Skip to content

Commit 69a836d

Browse files
committed
readMe updates
1 parent a96e2b8 commit 69a836d

File tree

5 files changed

+298
-0
lines changed

5 files changed

+298
-0
lines changed

docs/AzureGPTQuotaSettings.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## How to Check & Update Quota
2+
3+
1. **Navigate** to the [Azure AI Foundry portal](https://ai.azure.com/).
4+
2. **Select** the AI Project associated with this accelerator.
5+
3. **Go to** the `Management Center` from the bottom-left navigation menu.
6+
4. Select `Quota`
7+
- Click on the `GlobalStandard` dropdown.
8+
- Select the required **GPT model** (`GPT-4, GPT-4o`) or **Embeddings model** (`text-embedding-ada-002`).
9+
- Choose the **region** where the deployment is hosted.
10+
5. Request More Quota or delete any unused model deployments as needed.

docs/images/read_me/git_bash.png

29.3 KB
Loading
12.6 KB
Loading

docs/quota_check.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
## Check Quota Availability Before Deployment
2+
3+
Before deploying the accelerator, **ensure sufficient quota availability** for the required model. \
4+
5+
### 📌 Default Models & Capacities:
6+
```
7+
gpt-4o:30, text-embedding-ada-002:80, gpt-4:30
8+
```
9+
### 📌 Default Regions:
10+
```
11+
eastus, uksouth, eastus2, northcentralus, swedencentral, westus, westus2, southcentralus, canadacentral
12+
```
13+
### Usage Scenarios:
14+
- No parameters passed → Default models and capacities will be checked in default regions.
15+
- Only model(s) provided → The script will check for those models in the default regions.
16+
- Only region(s) provided → The script will check default models in the specified regions.
17+
- Both models and regions provided → The script will check those models in the specified regions.
18+
19+
### **Input Formats**
20+
✔️ Run without parameters to check default models & regions:
21+
```
22+
./quota_check_params.sh
23+
```
24+
✔️ Model name and required capacity in the format:
25+
```
26+
./quota_check_params.sh gpt-4o:30
27+
```
28+
✔️ Multiple models can be passed, separated by commas:
29+
```
30+
./quota_check_params.sh gpt-4o:30,text-embedding-ada-002:80
31+
```
32+
✔️ Passing Both models and regions:
33+
```
34+
./quota_check_params.sh gpt-4o:30 eastus,westus2
35+
```
36+
✔️ Check default models in specific regions:
37+
```
38+
./quota_check_params.sh "" eastus,westus2
39+
```
40+
41+
### **Sample Output**
42+
The final table lists regions with available quota. You can select any of these regions for deployment.
43+
44+
![quota-check-ouput](images/read_me/quota-check-output.png)
45+
46+
---
47+
### **If using Azure Portal and Cloud Shell**
48+
49+
1. Navigate to the [Azure Portal](https://portal.azure.com).
50+
2. Click on **Azure Cloud Shell** in the top right navigation menu.
51+
3. Run the appropriate command based on your requirement:
52+
53+
**To check quota for the deployment**
54+
55+
```sh
56+
curl -L -o quota_check_params.sh "https://raw.githubusercontent.com/microsoft/document-generation-solution-accelerator/main/scripts/quota_check_params.sh"
57+
chmod +x quota_check_params.sh
58+
./quota_check_params.sh
59+
```
60+
- Refer to [Input Formats](#input-formats) for detailed commands.
61+
62+
### **If using VS Code or Codespaces**
63+
1. Open the terminal in VS Code or Codespaces.
64+
2. If you're using VS Code, click the dropdown on the right side of the terminal window, and select `Git Bash`.
65+
![git_bash](images/read_me/git_bash.png)
66+
3. Navigate to the `scripts` folder where the script files are located and make the script as executable:
67+
```sh
68+
cd scripts
69+
chmod +x quota_check_params.sh
70+
```
71+
4. Run the appropriate script based on your requirement:
72+
73+
**To check quota for the deployment**
74+
75+
```sh
76+
./quota_check_params.sh
77+
```
78+
- Refer to [Input Formats](#input-formats) for detailed commands.
79+
80+
5. If you see the error `_bash: az: command not found_`, install Azure CLI:
81+
82+
```sh
83+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
84+
az login
85+
```
86+
6. Rerun the script after installing Azure CLI.

scripts/quota_check_params.sh

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
#!/bin/bash
2+
3+
# Default Models and Capacities (Comma-separated in "model:capacity" format)
4+
DEFAULT_MODEL_CAPACITY="gpt-4o:30,text-embedding-ada-002:80,gpt-4:30"
5+
6+
# Convert the comma-separated string into an array
7+
IFS=',' read -r -a MODEL_CAPACITY_PAIRS <<< "$DEFAULT_MODEL_CAPACITY"
8+
9+
echo "🔄 Fetching available Azure subscriptions..."
10+
SUBSCRIPTIONS=$(az account list --query "[?state=='Enabled'].{Name:name, ID:id}" --output tsv)
11+
SUB_COUNT=$(echo "$SUBSCRIPTIONS" | wc -l)
12+
13+
if [ "$SUB_COUNT" -eq 0 ]; then
14+
echo "❌ ERROR: No active Azure subscriptions found. Please log in using 'az login' and ensure you have an active subscription."
15+
exit 1
16+
elif [ "$SUB_COUNT" -eq 1 ]; then
17+
# If only one subscription, automatically select it
18+
AZURE_SUBSCRIPTION_ID=$(echo "$SUBSCRIPTIONS" | awk '{print $2}')
19+
if [ -z "$AZURE_SUBSCRIPTION_ID" ]; then
20+
echo "❌ ERROR: No active Azure subscriptions found. Please log in using 'az login' and ensure you have an active subscription."
21+
exit 1
22+
fi
23+
echo "✅ Using the only available subscription: $AZURE_SUBSCRIPTION_ID"
24+
else
25+
# If multiple subscriptions exist, prompt the user to choose one
26+
echo "Multiple subscriptions found:"
27+
echo "$SUBSCRIPTIONS" | awk '{print NR")", $1, "-", $2}'
28+
29+
while true; do
30+
echo "Enter the number of the subscription to use:"
31+
read SUB_INDEX
32+
33+
# Validate user input
34+
if [[ "$SUB_INDEX" =~ ^[0-9]+$ ]] && [ "$SUB_INDEX" -ge 1 ] && [ "$SUB_INDEX" -le "$SUB_COUNT" ]; then
35+
AZURE_SUBSCRIPTION_ID=$(echo "$SUBSCRIPTIONS" | awk -v idx="$SUB_INDEX" 'NR==idx {print $2}')
36+
echo "✅ Selected Subscription: $AZURE_SUBSCRIPTION_ID"
37+
break
38+
else
39+
echo "❌ Invalid selection. Please enter a valid number from the list."
40+
fi
41+
done
42+
fi
43+
44+
# Set the selected subscription
45+
az account set --subscription "$AZURE_SUBSCRIPTION_ID"
46+
echo "🎯 Active Subscription: $(az account show --query '[name, id]' --output tsv)"
47+
48+
# Default Regions to check (Comma-separated, now configurable)
49+
DEFAULT_REGIONS="eastus,uksouth,eastus2,northcentralus,swedencentral,westus,westus2,southcentralus,canadacentral"
50+
IFS=',' read -r -a DEFAULT_REGION_ARRAY <<< "$DEFAULT_REGIONS"
51+
52+
# Read parameters (if any)
53+
IFS=',' read -r -a USER_PROVIDED_PAIRS <<< "$1"
54+
USER_REGION="$2"
55+
56+
IS_USER_PROVIDED_PAIRS=false
57+
58+
if [ ${#USER_PROVIDED_PAIRS[@]} -lt 1 ]; then
59+
echo "No parameters provided, using default model-capacity pairs: ${MODEL_CAPACITY_PAIRS[*]}"
60+
else
61+
echo "Using provided model and capacity pairs: ${USER_PROVIDED_PAIRS[*]}"
62+
IS_USER_PROVIDED_PAIRS=true
63+
MODEL_CAPACITY_PAIRS=("${USER_PROVIDED_PAIRS[@]}")
64+
fi
65+
66+
declare -a FINAL_MODEL_NAMES
67+
declare -a FINAL_CAPACITIES
68+
declare -a TABLE_ROWS
69+
70+
for PAIR in "${MODEL_CAPACITY_PAIRS[@]}"; do
71+
MODEL_NAME=$(echo "$PAIR" | cut -d':' -f1 | tr '[:upper:]' '[:lower:]')
72+
CAPACITY=$(echo "$PAIR" | cut -d':' -f2)
73+
74+
if [ -z "$MODEL_NAME" ] || [ -z "$CAPACITY" ]; then
75+
echo "❌ ERROR: Invalid model and capacity pair '$PAIR'. Both model and capacity must be specified."
76+
exit 1
77+
fi
78+
79+
FINAL_MODEL_NAMES+=("$MODEL_NAME")
80+
FINAL_CAPACITIES+=("$CAPACITY")
81+
82+
done
83+
84+
echo "🔄 Using Models: ${FINAL_MODEL_NAMES[*]} with respective Capacities: ${FINAL_CAPACITIES[*]}"
85+
echo "----------------------------------------"
86+
87+
# Check if the user provided a region, if not, use the default regions
88+
if [ -n "$USER_REGION" ]; then
89+
echo "🔍 User provided region: $USER_REGION"
90+
IFS=',' read -r -a REGIONS <<< "$USER_REGION"
91+
else
92+
echo "No region specified, using default regions: ${DEFAULT_REGION_ARRAY[*]}"
93+
REGIONS=("${DEFAULT_REGION_ARRAY[@]}")
94+
APPLY_OR_CONDITION=true
95+
fi
96+
97+
echo "✅ Retrieved Azure regions. Checking availability..."
98+
INDEX=1
99+
100+
VALID_REGIONS=()
101+
for REGION in "${REGIONS[@]}"; do
102+
echo "----------------------------------------"
103+
echo "🔍 Checking region: $REGION"
104+
105+
QUOTA_INFO=$(az cognitiveservices usage list --location "$REGION" --output json | tr '[:upper:]' '[:lower:]')
106+
if [ -z "$QUOTA_INFO" ]; then
107+
echo "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping."
108+
continue
109+
fi
110+
111+
TEXT_EMBEDDING_AVAILABLE=false
112+
AT_LEAST_ONE_MODEL_AVAILABLE=false
113+
TEMP_TABLE_ROWS=()
114+
115+
for index in "${!FINAL_MODEL_NAMES[@]}"; do
116+
MODEL_NAME="${FINAL_MODEL_NAMES[$index]}"
117+
REQUIRED_CAPACITY="${FINAL_CAPACITIES[$index]}"
118+
FOUND=false
119+
INSUFFICIENT_QUOTA=false
120+
121+
if [ "$MODEL_NAME" = "text-embedding-ada-002" ]; then
122+
MODEL_TYPES=("openai.standard.$MODEL_NAME")
123+
else
124+
MODEL_TYPES=("openai.standard.$MODEL_NAME" "openai.globalstandard.$MODEL_NAME")
125+
fi
126+
127+
for MODEL_TYPE in "${MODEL_TYPES[@]}"; do
128+
FOUND=false
129+
INSUFFICIENT_QUOTA=false
130+
echo "🔍 Checking model: $MODEL_NAME with required capacity: $REQUIRED_CAPACITY ($MODEL_TYPE)"
131+
132+
MODEL_INFO=$(echo "$QUOTA_INFO" | awk -v model="\"value\": \"$MODEL_TYPE\"" '
133+
BEGIN { RS="},"; FS="," }
134+
$0 ~ model { print $0 }
135+
')
136+
137+
if [ -z "$MODEL_INFO" ]; then
138+
FOUND=false
139+
echo "⚠️ WARNING: No quota information found for model: $MODEL_NAME in region: $REGION for model type: $MODEL_TYPE."
140+
continue
141+
fi
142+
143+
if [ -n "$MODEL_INFO" ]; then
144+
FOUND=true
145+
CURRENT_VALUE=$(echo "$MODEL_INFO" | awk -F': ' '/"currentvalue"/ {print $2}' | tr -d ',' | tr -d ' ')
146+
LIMIT=$(echo "$MODEL_INFO" | awk -F': ' '/"limit"/ {print $2}' | tr -d ',' | tr -d ' ')
147+
148+
CURRENT_VALUE=${CURRENT_VALUE:-0}
149+
LIMIT=${LIMIT:-0}
150+
151+
CURRENT_VALUE=$(echo "$CURRENT_VALUE" | cut -d'.' -f1)
152+
LIMIT=$(echo "$LIMIT" | cut -d'.' -f1)
153+
154+
AVAILABLE=$((LIMIT - CURRENT_VALUE))
155+
echo "✅ Model: $MODEL_TYPE | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE"
156+
157+
if [ "$AVAILABLE" -ge "$REQUIRED_CAPACITY" ]; then
158+
FOUND=true
159+
if [ "$MODEL_NAME" = "text-embedding-ada-002" ]; then
160+
TEXT_EMBEDDING_AVAILABLE=true
161+
fi
162+
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")")
164+
else
165+
INSUFFICIENT_QUOTA=true
166+
fi
167+
fi
168+
169+
if [ "$FOUND" = false ]; then
170+
echo "❌ No models found for model: $MODEL_NAME in region: $REGION (${MODEL_TYPES[*]})"
171+
elif [ "$INSUFFICIENT_QUOTA" = true ]; then
172+
echo "⚠️ Model $MODEL_NAME in region: $REGION has insufficient quota (${MODEL_TYPES[*]})."
173+
fi
174+
done
175+
done
176+
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
178+
VALID_REGIONS+=("$REGION")
179+
TABLE_ROWS+=("${TEMP_TABLE_ROWS[@]}")
180+
INDEX=$((INDEX + 1))
181+
elif [ ${#USER_PROVIDED_PAIRS[@]} -eq 0 ]; then
182+
echo "🚫 Skipping $REGION as it does not meet quota requirements."
183+
fi
184+
185+
done
186+
187+
if [ ${#TABLE_ROWS[@]} -eq 0 ]; then
188+
echo "------------------------------------------------------------------------------------------------------------------"
189+
190+
echo "❌ No regions have sufficient quota for all required models. Please request a quota increase: https://aka.ms/oai/stuquotarequest"
191+
else
192+
echo "----------------------------------------------------------------------------------------------------------------------"
193+
printf "| %-4s | %-20s | %-45s | %-10s | %-10s | %-10s |\n" "No." "Region" "Model Name" "Limit" "Used" "Available"
194+
echo "----------------------------------------------------------------------------------------------------------------------"
195+
for ROW in "${TABLE_ROWS[@]}"; do
196+
echo "$ROW"
197+
done
198+
echo "----------------------------------------------------------------------------------------------------------------------"
199+
echo "➡️ To request a quota increase, visit: https://aka.ms/oai/stuquotarequest"
200+
fi
201+
202+
echo "✅ Script completed."

0 commit comments

Comments
 (0)