Skip to content

Commit 9f54771

Browse files
Merge pull request #334 from microsoft/psl-update-subscription-in-script
fix: updated the subscription code in the script
2 parents 7f17e06 + 4a72695 commit 9f54771

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

scripts/quota_check_params.sh

+32
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,38 @@ DEFAULT_MODEL_CAPACITY="gpt-4o:30,text-embedding-ada-002:80,gpt-4:30"
66
# Convert the comma-separated string into an array
77
IFS=',' read -r -a MODEL_CAPACITY_PAIRS <<< "$DEFAULT_MODEL_CAPACITY"
88

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 1 ]; then
14+
# If only one subscription, automatically select it
15+
AZURE_SUBSCRIPTION_ID=$(echo "$SUBSCRIPTIONS" | awk '{print $2}')
16+
echo "✅ Using the only available subscription: $AZURE_SUBSCRIPTION_ID"
17+
else
18+
# If multiple subscriptions exist, prompt the user to choose one
19+
echo "Multiple subscriptions found:"
20+
echo "$SUBSCRIPTIONS" | awk '{print NR")", $1, "-", $2}'
21+
22+
while true; do
23+
echo "Enter the number of the subscription to use:"
24+
read SUB_INDEX
25+
26+
# Validate user input
27+
if [[ "$SUB_INDEX" =~ ^[0-9]+$ ]] && [ "$SUB_INDEX" -ge 1 ] && [ "$SUB_INDEX" -le "$SUB_COUNT" ]; then
28+
AZURE_SUBSCRIPTION_ID=$(echo "$SUBSCRIPTIONS" | awk -v idx="$SUB_INDEX" 'NR==idx {print $2}')
29+
echo "✅ Selected Subscription: $AZURE_SUBSCRIPTION_ID"
30+
break
31+
else
32+
echo "❌ Invalid selection. Please enter a valid number from the list."
33+
fi
34+
done
35+
fi
36+
37+
# Set the selected subscription
38+
az account set --subscription "$AZURE_SUBSCRIPTION_ID"
39+
echo "🎯 Active Subscription: $(az account show --query '[name, id]' --output tsv)"
40+
941
# Default Regions to check (Comma-separated, now configurable)
1042
DEFAULT_REGIONS="eastus,uksouth,eastus2,northcentralus,swedencentral,westus,westus2,southcentralus,canadacentral"
1143
IFS=',' read -r -a DEFAULT_REGION_ARRAY <<< "$DEFAULT_REGIONS"

0 commit comments

Comments
 (0)