From 1ceafb4a130153b50343f669ecf48f69b5bf945d Mon Sep 17 00:00:00 2001 From: "Ashwal Vishwanath (Persistent Systems Inc)" Date: Wed, 17 Jun 2026 00:16:56 +0530 Subject: [PATCH 1/6] Add swedencentral region, explicit dependsOn for private endpoint, improved quota check fallback logic --- .github/workflows/deploy.yml | 7 +- .github/workflows/job-deploy.yml | 4 +- infra/main.bicep | 6 ++ infra/main_custom.bicep | 6 ++ infra/scripts/checkquota.sh | 134 +++++++++++++++++++++------- infra/scripts/quota_check_params.sh | 45 ++++++++-- 6 files changed, 154 insertions(+), 48 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 58ec8fca..7c425107 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -51,11 +51,8 @@ jobs: run: | chmod +x infra/scripts/checkquota.sh if ! infra/scripts/checkquota.sh; then - # If quota check fails due to insufficient quota, set the flag - if grep -q "No region with sufficient quota found" infra/scripts/checkquota.sh; then - echo "QUOTA_FAILED=true" >> $GITHUB_ENV - fi - exit 1 # Fail the pipeline if any other failure occurs + echo "QUOTA_FAILED=true" >> $GITHUB_ENV + exit 1 fi - name: Send Notification on Quota Failure diff --git a/.github/workflows/job-deploy.yml b/.github/workflows/job-deploy.yml index c131651b..d1f413e6 100644 --- a/.github/workflows/job-deploy.yml +++ b/.github/workflows/job-deploy.yml @@ -337,9 +337,7 @@ jobs: run: | chmod +x infra/scripts/checkquota.sh if ! infra/scripts/checkquota.sh; then - if grep -q "No region with sufficient quota found" infra/scripts/checkquota.sh; then - echo "QUOTA_FAILED=true" >> $GITHUB_ENV - fi + echo "QUOTA_FAILED=true" >> $GITHUB_ENV exit 1 fi diff --git a/infra/main.bicep b/infra/main.bicep index 9f4ec91e..e6b7a7df 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -20,6 +20,7 @@ param solutionName string = 'cps' 'japaneast' 'northeurope' 'southeastasia' + 'swedencentral' 'uksouth' ]) param location string @@ -786,6 +787,11 @@ module avmAiServices 'modules/account/aifoundry.bicep' = { module cognitiveServicePrivateEndpoint 'br/public:avm/res/network/private-endpoint:0.12.0' = if (enablePrivateNetworking && empty(existingProjectResourceId)) { name: take('avm.res.network.private-endpoint.${solutionSuffix}', 64) + dependsOn: [ + avmAiServices + virtualNetwork + avmPrivateDnsZones + ] params: { name: 'pep-aiservices-${solutionSuffix}' location: location diff --git a/infra/main_custom.bicep b/infra/main_custom.bicep index b2263f10..563f18bc 100644 --- a/infra/main_custom.bicep +++ b/infra/main_custom.bicep @@ -23,6 +23,7 @@ param solutionName string = 'cps' 'japaneast' 'northeurope' 'southeastasia' + 'swedencentral' 'uksouth' ]) param location string @@ -789,6 +790,11 @@ module avmAiServices 'modules/account/aifoundry.bicep' = { module cognitiveServicePrivateEndpoint 'br/public:avm/res/network/private-endpoint:0.12.0' = if (enablePrivateNetworking && empty(existingProjectResourceId)) { name: take('avm.res.network.private-endpoint.${solutionSuffix}', 64) + dependsOn: [ + avmAiServices + virtualNetwork + avmPrivateDnsZones + ] params: { name: 'pep-aiservices-${solutionSuffix}' location: location diff --git a/infra/scripts/checkquota.sh b/infra/scripts/checkquota.sh index a85b0db9..cb93439f 100644 --- a/infra/scripts/checkquota.sh +++ b/infra/scripts/checkquota.sh @@ -1,48 +1,71 @@ #!/bin/bash -# List of Azure regions to check for quota (update as needed) -IFS=', ' read -ra REGIONS <<< "$AZURE_REGIONS" +# Enhanced Quota Check Script - Finds available region for GPT-5.1 deployment +# Automatically falls back to next available region if first choice has insufficient quota +# Configuration SUBSCRIPTION_ID="${AZURE_SUBSCRIPTION_ID}" -GPT_MIN_CAPACITY="${GPT_MIN_CAPACITY}" +GPT_MIN_CAPACITY="${GPT_MIN_CAPACITY:-300}" # Default to 300 TPM if not specified -# Verify Azure CLI is already authenticated (via OIDC in the workflow) -echo "Verifying Azure CLI authentication..." +# List of valid Azure regions for GPT-5.1 GlobalStandard (must match Bicep @allowed values) +ALLOWED_REGIONS=("australiaeast" "centralus" "eastasia" "eastus2" "japaneast" "northeurope" "southeastasia" "swedencentral" "uksouth") + +# Parse user-provided regions or use defaults +if [[ -n "$AZURE_REGIONS" ]]; then + IFS=',' read -ra REGIONS <<< "$AZURE_REGIONS" +else + REGIONS=("${ALLOWED_REGIONS[@]}") +fi + +# Verify Azure CLI is authenticated +echo "🔐 Verifying Azure CLI authentication..." if ! az account show > /dev/null 2>&1; then - echo "❌ Error: Azure CLI is not authenticated. Please log in using 'az login'" - exit 1 + echo "❌ Error: Azure CLI is not authenticated. Please log in using 'az login'" + exit 1 fi +# Validate required environment variables echo "🔄 Validating required environment variables..." -if [[ -z "$SUBSCRIPTION_ID" || -z "$GPT_MIN_CAPACITY" || -z "$REGIONS" ]]; then - echo "❌ ERROR: Missing required environment variables." +if [[ -z "$SUBSCRIPTION_ID" ]]; then + echo "❌ ERROR: AZURE_SUBSCRIPTION_ID environment variable is not set." exit 1 fi -echo "🔄 Setting Azure subscription..." +# Set the subscription +echo "🔄 Setting Azure subscription to: $SUBSCRIPTION_ID" if ! az account set --subscription "$SUBSCRIPTION_ID"; then echo "❌ ERROR: Invalid subscription ID or insufficient permissions." exit 1 fi echo "✅ Azure subscription set successfully." -# Define models and their minimum required capacities +# Model configuration declare -A MIN_CAPACITY=( ["OpenAI.GlobalStandard.gpt-5.1"]=$GPT_MIN_CAPACITY ) -VALID_REGION="" -for REGION in "${REGIONS[@]}"; do - echo "----------------------------------------" - echo "🔍 Checking region: $REGION" - - QUOTA_INFO=$(az cognitiveservices usage list --location "$REGION" --output json) +echo "==========================================" +echo "🔍 Quota Check Summary" +echo "==========================================" +echo "Subscription: $SUBSCRIPTION_ID" +echo "Required Model: OpenAI.GlobalStandard.gpt-5.1" +echo "Required Capacity: $GPT_MIN_CAPACITY TPM" +echo "Checking Regions: ${REGIONS[@]}" +echo "==========================================" + +# Function to check quota for a region +check_region_quota() { + local region=$1 + echo "" + echo "🔍 Checking region: $region" + + QUOTA_INFO=$(az cognitiveservices usage list --location "$region" --output json 2>/dev/null) if [ -z "$QUOTA_INFO" ]; then - echo "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping." - continue + echo "⚠️ WARNING: Failed to retrieve quota info for $region (service may be unavailable)" + return 1 fi - INSUFFICIENT_QUOTA=false + local insufficient_quota=false for MODEL in "${!MIN_CAPACITY[@]}"; do MODEL_INFO=$(echo "$QUOTA_INFO" | awk -v model="\"value\": \"$MODEL\"" ' BEGIN { RS="},"; FS="," } @@ -50,9 +73,9 @@ for REGION in "${REGIONS[@]}"; do ') if [ -z "$MODEL_INFO" ]; then - echo "⚠️ WARNING: No quota information found for model: $MODEL in $REGION. Skipping." - INSUFFICIENT_QUOTA=true - continue + echo "⚠️ WARNING: Model $MODEL not available in $region" + insufficient_quota=true + return 1 fi CURRENT_VALUE=$(echo "$MODEL_INFO" | awk -F': ' '/"currentValue"/ {print $2}' | tr -d ',' | tr -d ' ') @@ -66,28 +89,71 @@ for REGION in "${REGIONS[@]}"; do AVAILABLE=$((LIMIT - CURRENT_VALUE)) - echo "✅ Model: $MODEL | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE" + echo " Model: $MODEL" + echo " Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE TPM" if [ "$AVAILABLE" -lt "${MIN_CAPACITY[$MODEL]}" ]; then - echo "❌ ERROR: $MODEL in $REGION has insufficient quota." - INSUFFICIENT_QUOTA=true - break + echo " ❌ INSUFFICIENT: Need $((MIN_CAPACITY[$MODEL] - AVAILABLE)) more TPM" + insufficient_quota=true + else + echo " ✅ SUFFICIENT: $AVAILABLE TPM available (Need: ${MIN_CAPACITY[$MODEL]} TPM)" fi done - if [ "$INSUFFICIENT_QUOTA" = false ]; then + if [ "$insufficient_quota" = false ]; then + return 0 # Region has sufficient quota + else + return 1 # Region has insufficient quota + fi +} + +# Search for a valid region +VALID_REGION="" +for REGION in "${REGIONS[@]}"; do + if check_region_quota "$REGION"; then VALID_REGION="$REGION" break fi - done +# Output results +echo "" +echo "==========================================" if [ -z "$VALID_REGION" ]; then - echo "❌ No region with sufficient quota found. Blocking deployment." - echo "QUOTA_FAILED=true" >> "$GITHUB_ENV" - exit 0 + echo "❌ DEPLOYMENT BLOCKED - No region with sufficient quota" + echo "==========================================" + echo "" + echo "⚠️ All checked regions have insufficient quota for GPT-5.1 GlobalStandard" + echo "" + echo "Options:" + echo "1. Request a quota increase: https://aka.ms/oai/quotarequest" + echo "2. Reduce gptDeploymentCapacity parameter (currently set to $GPT_MIN_CAPACITY TPM)" + echo "3. Try a different Azure subscription" + echo "" + echo "Deployment cannot proceed without sufficient quota." + + # Set failure flag for CI/CD pipelines + if [ -n "$GITHUB_ENV" ]; then + echo "QUOTA_FAILED=true" >> "$GITHUB_ENV" + echo "VALID_REGION=" >> "$GITHUB_ENV" + fi + exit 0 # Exit cleanly so CI can handle the failure else - echo "✅ Suggested Region: $VALID_REGION" - echo "VALID_REGION=$VALID_REGION" >> "$GITHUB_ENV" + echo "✅ DEPLOYMENT APPROVED - Valid region found" + echo "==========================================" + echo "" + echo "Selected Region: $VALID_REGION" + echo "This region has sufficient quota for GPT-5.1 GlobalStandard deployment" + echo "" + + # Export for CI/CD pipelines + if [ -n "$GITHUB_ENV" ]; then + echo "QUOTA_FAILED=false" >> "$GITHUB_ENV" + echo "VALID_REGION=$VALID_REGION" >> "$GITHUB_ENV" + fi + + # Also export as environment variable for immediate use + export VALID_REGION + echo "Environment variable set: VALID_REGION=$VALID_REGION" exit 0 fi diff --git a/infra/scripts/quota_check_params.sh b/infra/scripts/quota_check_params.sh index e6fd625f..320a1d64 100644 --- a/infra/scripts/quota_check_params.sh +++ b/infra/scripts/quota_check_params.sh @@ -92,8 +92,8 @@ az account set --subscription "$AZURE_SUBSCRIPTION_ID" echo "🎯 Active Subscription: $(az account show --query '[name, id]' --output tsv)" # Default Regions to check (Comma-separated, now configurable) -# GPT-5.1 Global Standard availability as of 2026-02 -DEFAULT_REGIONS="australiaeast,canadaeast,eastus2,japaneast,koreacentral,swedencentral,switzerlandnorth,uksouth" +# These regions match Bicep @allowed values and support GPT-5.1 GlobalStandard as of 2026-02 +DEFAULT_REGIONS="eastus2,swedencentral,northeurope,southeastasia,uksouth,japaneast,eastasia,centralus,australiaeast" IFS=',' read -r -a DEFAULT_REGION_ARRAY <<< "$DEFAULT_REGIONS" # Read parameters (if any) @@ -230,8 +230,23 @@ done if [ ${#TABLE_ROWS[@]} -eq 0 ]; then echo "--------------------------------------------------------------------------------------------------------------------" - - echo "❌ No regions have sufficient quota for all required models. Please request a quota increase: https://aka.ms/oai/stuquotarequest" + echo "❌ DEPLOYMENT BLOCKED - No regions have sufficient quota for all required models." + echo "--------------------------------------------------------------------------------------------------------------------" + echo "" + echo "Please request a quota increase: https://aka.ms/oai/quotarequest" + echo "" + echo "Options:" + echo "1. Request quota increase for GPT-5.1 GlobalStandard" + echo "2. Reduce the gptDeploymentCapacity parameter (currently: 150 TPM)" + echo "3. Use a different Azure subscription" + echo "" + + # Set failure flag for CI/CD + if [ -n "$GITHUB_ENV" ]; then + echo "QUOTA_CHECK_FAILED=true" >> "$GITHUB_ENV" + echo "SELECTED_REGION=" >> "$GITHUB_ENV" + fi + exit 1 else echo "---------------------------------------------------------------------------------------------------------------------" printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |\n" "No." "Region" "Model Name" "Limit" "Used" "Available" @@ -240,7 +255,25 @@ else echo "$ROW" done echo "---------------------------------------------------------------------------------------------------------------------" - echo "➡️ To request a quota increase, visit: https://aka.ms/oai/stuquotarequest" + + # Auto-select the first valid region + SELECTED_REGION="${VALID_REGIONS[0]}" + echo "" + echo "✅ DEPLOYMENT APPROVED" + echo "---------------------------------------------------------------------------------------------------------------------" + echo "Selected Region: $SELECTED_REGION" + echo "This region has sufficient quota for GPT-5.1 deployment" + echo "" + + # Export for CI/CD pipelines and future use + if [ -n "$GITHUB_ENV" ]; then + echo "QUOTA_CHECK_FAILED=false" >> "$GITHUB_ENV" + echo "SELECTED_REGION=$SELECTED_REGION" >> "$GITHUB_ENV" + fi + + # Also export as environment variable + export SELECTED_REGION + echo "Environment variable set: SELECTED_REGION=$SELECTED_REGION" fi -echo "✅ Script completed." \ No newline at end of file +echo "✅ Quota check script completed." \ No newline at end of file From 0137481d58aa871b6e2dcdc1f37fe3c41fa9e47d Mon Sep 17 00:00:00 2001 From: "Ashwal Vishwanath (Persistent Systems Inc)" Date: Wed, 17 Jun 2026 01:02:10 +0530 Subject: [PATCH 2/6] Fix quota check to use effective deployment capacity and region fallback --- infra/scripts/checkquota.sh | 55 +++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/infra/scripts/checkquota.sh b/infra/scripts/checkquota.sh index cb93439f..d9364037 100644 --- a/infra/scripts/checkquota.sh +++ b/infra/scripts/checkquota.sh @@ -5,14 +5,55 @@ # Configuration SUBSCRIPTION_ID="${AZURE_SUBSCRIPTION_ID}" -GPT_MIN_CAPACITY="${GPT_MIN_CAPACITY:-300}" # Default to 300 TPM if not specified +# AZURE_ENV_GPT_MODEL_CAPACITY is the value used by deployment parameters; default stays at 300. +DEPLOYMENT_CAPACITY="${AZURE_ENV_GPT_MODEL_CAPACITY:-300}" +# GPT_MIN_CAPACITY remains supported for backward compatibility in workflows. +GPT_MIN_CAPACITY="${GPT_MIN_CAPACITY:-0}" + +# Prevent quota check/deployment mismatch by always checking at least deployment capacity. +if [[ "$GPT_MIN_CAPACITY" =~ ^[0-9]+$ ]] && [[ "$DEPLOYMENT_CAPACITY" =~ ^[0-9]+$ ]]; then + if [ "$GPT_MIN_CAPACITY" -gt "$DEPLOYMENT_CAPACITY" ]; then + REQUIRED_CAPACITY="$GPT_MIN_CAPACITY" + else + REQUIRED_CAPACITY="$DEPLOYMENT_CAPACITY" + fi +else + echo "❌ ERROR: GPT_MIN_CAPACITY and AZURE_ENV_GPT_MODEL_CAPACITY must be integers." + exit 1 +fi # List of valid Azure regions for GPT-5.1 GlobalStandard (must match Bicep @allowed values) ALLOWED_REGIONS=("australiaeast" "centralus" "eastasia" "eastus2" "japaneast" "northeurope" "southeastasia" "swedencentral" "uksouth") -# Parse user-provided regions or use defaults +# Parse user-provided regions or use defaults. +# If user provides preferred regions, keep that priority and then append any +# remaining allowed regions as automatic fallback candidates. if [[ -n "$AZURE_REGIONS" ]]; then - IFS=',' read -ra REGIONS <<< "$AZURE_REGIONS" + IFS=',' read -ra USER_REGIONS <<< "$AZURE_REGIONS" + REGIONS=() + + # Keep user preference order first. + for region in "${USER_REGIONS[@]}"; do + clean_region="$(echo "$region" | xargs | tr '[:upper:]' '[:lower:]')" + if [[ -n "$clean_region" ]]; then + REGIONS+=("$clean_region") + fi + done + + # Append remaining allowed regions for fallback. + for allowed_region in "${ALLOWED_REGIONS[@]}"; do + exists=false + for current_region in "${REGIONS[@]}"; do + if [[ "$current_region" == "$allowed_region" ]]; then + exists=true + break + fi + done + + if [[ "$exists" == false ]]; then + REGIONS+=("$allowed_region") + fi + done else REGIONS=("${ALLOWED_REGIONS[@]}") fi @@ -41,7 +82,7 @@ echo "✅ Azure subscription set successfully." # Model configuration declare -A MIN_CAPACITY=( - ["OpenAI.GlobalStandard.gpt-5.1"]=$GPT_MIN_CAPACITY + ["OpenAI.GlobalStandard.gpt-5.1"]=$REQUIRED_CAPACITY ) echo "==========================================" @@ -49,7 +90,9 @@ echo "🔍 Quota Check Summary" echo "==========================================" echo "Subscription: $SUBSCRIPTION_ID" echo "Required Model: OpenAI.GlobalStandard.gpt-5.1" -echo "Required Capacity: $GPT_MIN_CAPACITY TPM" +echo "Deployment Capacity: $DEPLOYMENT_CAPACITY TPM" +echo "Minimum Quota Threshold Input: $GPT_MIN_CAPACITY TPM" +echo "Effective Required Capacity: $REQUIRED_CAPACITY TPM" echo "Checking Regions: ${REGIONS[@]}" echo "==========================================" @@ -127,7 +170,7 @@ if [ -z "$VALID_REGION" ]; then echo "" echo "Options:" echo "1. Request a quota increase: https://aka.ms/oai/quotarequest" - echo "2. Reduce gptDeploymentCapacity parameter (currently set to $GPT_MIN_CAPACITY TPM)" + echo "2. Reduce gptDeploymentCapacity parameter (currently set to $DEPLOYMENT_CAPACITY TPM)" echo "3. Try a different Azure subscription" echo "" echo "Deployment cannot proceed without sufficient quota." From 5c12ef5393919a48292a10df9d608cf24f48b5ef Mon Sep 17 00:00:00 2001 From: "Ashwal Vishwanath (Persistent Systems Inc)" Date: Wed, 17 Jun 2026 01:56:53 +0530 Subject: [PATCH 3/6] Add swedencentral replica region pairing for Log Analytics workspace replication --- infra/main.bicep | 1 + infra/main_custom.bicep | 1 + 2 files changed, 2 insertions(+) diff --git a/infra/main.bicep b/infra/main.bicep index e6b7a7df..34c40e41 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -171,6 +171,7 @@ var replicaRegionPairs = { japaneast: 'eastasia' northeurope: 'westeurope' southeastasia: 'eastasia' + swedencentral: 'northeurope' uksouth: 'westeurope' westeurope: 'northeurope' } diff --git a/infra/main_custom.bicep b/infra/main_custom.bicep index 563f18bc..71add0f0 100644 --- a/infra/main_custom.bicep +++ b/infra/main_custom.bicep @@ -174,6 +174,7 @@ var replicaRegionPairs = { japaneast: 'eastasia' northeurope: 'westeurope' southeastasia: 'eastasia' + swedencentral: 'northeurope' uksouth: 'westeurope' westeurope: 'northeurope' } From 4fd854e80b7563eb432a829d25001cbe10f79ef4 Mon Sep 17 00:00:00 2001 From: "Ashwal Vishwanath (Persistent Systems Inc)" Date: Wed, 17 Jun 2026 17:49:46 +0530 Subject: [PATCH 4/6] Revert non-Bicep changes from recent infra commits --- .github/workflows/deploy.yml | 7 +- .github/workflows/job-deploy.yml | 4 +- infra/scripts/checkquota.sh | 179 ++++++---------------------- infra/scripts/quota_check_params.sh | 45 +------ 4 files changed, 49 insertions(+), 186 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7c425107..58ec8fca 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -51,8 +51,11 @@ jobs: run: | chmod +x infra/scripts/checkquota.sh if ! infra/scripts/checkquota.sh; then - echo "QUOTA_FAILED=true" >> $GITHUB_ENV - exit 1 + # If quota check fails due to insufficient quota, set the flag + if grep -q "No region with sufficient quota found" infra/scripts/checkquota.sh; then + echo "QUOTA_FAILED=true" >> $GITHUB_ENV + fi + exit 1 # Fail the pipeline if any other failure occurs fi - name: Send Notification on Quota Failure diff --git a/.github/workflows/job-deploy.yml b/.github/workflows/job-deploy.yml index d1f413e6..c131651b 100644 --- a/.github/workflows/job-deploy.yml +++ b/.github/workflows/job-deploy.yml @@ -337,7 +337,9 @@ jobs: run: | chmod +x infra/scripts/checkquota.sh if ! infra/scripts/checkquota.sh; then - echo "QUOTA_FAILED=true" >> $GITHUB_ENV + if grep -q "No region with sufficient quota found" infra/scripts/checkquota.sh; then + echo "QUOTA_FAILED=true" >> $GITHUB_ENV + fi exit 1 fi diff --git a/infra/scripts/checkquota.sh b/infra/scripts/checkquota.sh index d9364037..a85b0db9 100644 --- a/infra/scripts/checkquota.sh +++ b/infra/scripts/checkquota.sh @@ -1,114 +1,48 @@ #!/bin/bash -# Enhanced Quota Check Script - Finds available region for GPT-5.1 deployment -# Automatically falls back to next available region if first choice has insufficient quota +# List of Azure regions to check for quota (update as needed) +IFS=', ' read -ra REGIONS <<< "$AZURE_REGIONS" -# Configuration SUBSCRIPTION_ID="${AZURE_SUBSCRIPTION_ID}" -# AZURE_ENV_GPT_MODEL_CAPACITY is the value used by deployment parameters; default stays at 300. -DEPLOYMENT_CAPACITY="${AZURE_ENV_GPT_MODEL_CAPACITY:-300}" -# GPT_MIN_CAPACITY remains supported for backward compatibility in workflows. -GPT_MIN_CAPACITY="${GPT_MIN_CAPACITY:-0}" - -# Prevent quota check/deployment mismatch by always checking at least deployment capacity. -if [[ "$GPT_MIN_CAPACITY" =~ ^[0-9]+$ ]] && [[ "$DEPLOYMENT_CAPACITY" =~ ^[0-9]+$ ]]; then - if [ "$GPT_MIN_CAPACITY" -gt "$DEPLOYMENT_CAPACITY" ]; then - REQUIRED_CAPACITY="$GPT_MIN_CAPACITY" - else - REQUIRED_CAPACITY="$DEPLOYMENT_CAPACITY" - fi -else - echo "❌ ERROR: GPT_MIN_CAPACITY and AZURE_ENV_GPT_MODEL_CAPACITY must be integers." - exit 1 -fi - -# List of valid Azure regions for GPT-5.1 GlobalStandard (must match Bicep @allowed values) -ALLOWED_REGIONS=("australiaeast" "centralus" "eastasia" "eastus2" "japaneast" "northeurope" "southeastasia" "swedencentral" "uksouth") - -# Parse user-provided regions or use defaults. -# If user provides preferred regions, keep that priority and then append any -# remaining allowed regions as automatic fallback candidates. -if [[ -n "$AZURE_REGIONS" ]]; then - IFS=',' read -ra USER_REGIONS <<< "$AZURE_REGIONS" - REGIONS=() - - # Keep user preference order first. - for region in "${USER_REGIONS[@]}"; do - clean_region="$(echo "$region" | xargs | tr '[:upper:]' '[:lower:]')" - if [[ -n "$clean_region" ]]; then - REGIONS+=("$clean_region") - fi - done - - # Append remaining allowed regions for fallback. - for allowed_region in "${ALLOWED_REGIONS[@]}"; do - exists=false - for current_region in "${REGIONS[@]}"; do - if [[ "$current_region" == "$allowed_region" ]]; then - exists=true - break - fi - done - - if [[ "$exists" == false ]]; then - REGIONS+=("$allowed_region") - fi - done -else - REGIONS=("${ALLOWED_REGIONS[@]}") -fi +GPT_MIN_CAPACITY="${GPT_MIN_CAPACITY}" -# Verify Azure CLI is authenticated -echo "🔐 Verifying Azure CLI authentication..." +# Verify Azure CLI is already authenticated (via OIDC in the workflow) +echo "Verifying Azure CLI authentication..." if ! az account show > /dev/null 2>&1; then - echo "❌ Error: Azure CLI is not authenticated. Please log in using 'az login'" - exit 1 + echo "❌ Error: Azure CLI is not authenticated. Please log in using 'az login'" + exit 1 fi -# Validate required environment variables echo "🔄 Validating required environment variables..." -if [[ -z "$SUBSCRIPTION_ID" ]]; then - echo "❌ ERROR: AZURE_SUBSCRIPTION_ID environment variable is not set." +if [[ -z "$SUBSCRIPTION_ID" || -z "$GPT_MIN_CAPACITY" || -z "$REGIONS" ]]; then + echo "❌ ERROR: Missing required environment variables." exit 1 fi -# Set the subscription -echo "🔄 Setting Azure subscription to: $SUBSCRIPTION_ID" +echo "🔄 Setting Azure subscription..." if ! az account set --subscription "$SUBSCRIPTION_ID"; then echo "❌ ERROR: Invalid subscription ID or insufficient permissions." exit 1 fi echo "✅ Azure subscription set successfully." -# Model configuration +# Define models and their minimum required capacities declare -A MIN_CAPACITY=( - ["OpenAI.GlobalStandard.gpt-5.1"]=$REQUIRED_CAPACITY + ["OpenAI.GlobalStandard.gpt-5.1"]=$GPT_MIN_CAPACITY ) -echo "==========================================" -echo "🔍 Quota Check Summary" -echo "==========================================" -echo "Subscription: $SUBSCRIPTION_ID" -echo "Required Model: OpenAI.GlobalStandard.gpt-5.1" -echo "Deployment Capacity: $DEPLOYMENT_CAPACITY TPM" -echo "Minimum Quota Threshold Input: $GPT_MIN_CAPACITY TPM" -echo "Effective Required Capacity: $REQUIRED_CAPACITY TPM" -echo "Checking Regions: ${REGIONS[@]}" -echo "==========================================" - -# Function to check quota for a region -check_region_quota() { - local region=$1 - echo "" - echo "🔍 Checking region: $region" - - QUOTA_INFO=$(az cognitiveservices usage list --location "$region" --output json 2>/dev/null) +VALID_REGION="" +for REGION in "${REGIONS[@]}"; do + echo "----------------------------------------" + echo "🔍 Checking region: $REGION" + + QUOTA_INFO=$(az cognitiveservices usage list --location "$REGION" --output json) if [ -z "$QUOTA_INFO" ]; then - echo "⚠️ WARNING: Failed to retrieve quota info for $region (service may be unavailable)" - return 1 + echo "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping." + continue fi - local insufficient_quota=false + INSUFFICIENT_QUOTA=false for MODEL in "${!MIN_CAPACITY[@]}"; do MODEL_INFO=$(echo "$QUOTA_INFO" | awk -v model="\"value\": \"$MODEL\"" ' BEGIN { RS="},"; FS="," } @@ -116,9 +50,9 @@ check_region_quota() { ') if [ -z "$MODEL_INFO" ]; then - echo "⚠️ WARNING: Model $MODEL not available in $region" - insufficient_quota=true - return 1 + echo "⚠️ WARNING: No quota information found for model: $MODEL in $REGION. Skipping." + INSUFFICIENT_QUOTA=true + continue fi CURRENT_VALUE=$(echo "$MODEL_INFO" | awk -F': ' '/"currentValue"/ {print $2}' | tr -d ',' | tr -d ' ') @@ -132,71 +66,28 @@ check_region_quota() { AVAILABLE=$((LIMIT - CURRENT_VALUE)) - echo " Model: $MODEL" - echo " Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE TPM" + echo "✅ Model: $MODEL | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE" if [ "$AVAILABLE" -lt "${MIN_CAPACITY[$MODEL]}" ]; then - echo " ❌ INSUFFICIENT: Need $((MIN_CAPACITY[$MODEL] - AVAILABLE)) more TPM" - insufficient_quota=true - else - echo " ✅ SUFFICIENT: $AVAILABLE TPM available (Need: ${MIN_CAPACITY[$MODEL]} TPM)" + echo "❌ ERROR: $MODEL in $REGION has insufficient quota." + INSUFFICIENT_QUOTA=true + break fi done - if [ "$insufficient_quota" = false ]; then - return 0 # Region has sufficient quota - else - return 1 # Region has insufficient quota - fi -} - -# Search for a valid region -VALID_REGION="" -for REGION in "${REGIONS[@]}"; do - if check_region_quota "$REGION"; then + if [ "$INSUFFICIENT_QUOTA" = false ]; then VALID_REGION="$REGION" break fi + done -# Output results -echo "" -echo "==========================================" if [ -z "$VALID_REGION" ]; then - echo "❌ DEPLOYMENT BLOCKED - No region with sufficient quota" - echo "==========================================" - echo "" - echo "⚠️ All checked regions have insufficient quota for GPT-5.1 GlobalStandard" - echo "" - echo "Options:" - echo "1. Request a quota increase: https://aka.ms/oai/quotarequest" - echo "2. Reduce gptDeploymentCapacity parameter (currently set to $DEPLOYMENT_CAPACITY TPM)" - echo "3. Try a different Azure subscription" - echo "" - echo "Deployment cannot proceed without sufficient quota." - - # Set failure flag for CI/CD pipelines - if [ -n "$GITHUB_ENV" ]; then - echo "QUOTA_FAILED=true" >> "$GITHUB_ENV" - echo "VALID_REGION=" >> "$GITHUB_ENV" - fi - exit 0 # Exit cleanly so CI can handle the failure + echo "❌ No region with sufficient quota found. Blocking deployment." + echo "QUOTA_FAILED=true" >> "$GITHUB_ENV" + exit 0 else - echo "✅ DEPLOYMENT APPROVED - Valid region found" - echo "==========================================" - echo "" - echo "Selected Region: $VALID_REGION" - echo "This region has sufficient quota for GPT-5.1 GlobalStandard deployment" - echo "" - - # Export for CI/CD pipelines - if [ -n "$GITHUB_ENV" ]; then - echo "QUOTA_FAILED=false" >> "$GITHUB_ENV" - echo "VALID_REGION=$VALID_REGION" >> "$GITHUB_ENV" - fi - - # Also export as environment variable for immediate use - export VALID_REGION - echo "Environment variable set: VALID_REGION=$VALID_REGION" + echo "✅ Suggested Region: $VALID_REGION" + echo "VALID_REGION=$VALID_REGION" >> "$GITHUB_ENV" exit 0 fi diff --git a/infra/scripts/quota_check_params.sh b/infra/scripts/quota_check_params.sh index 320a1d64..e6fd625f 100644 --- a/infra/scripts/quota_check_params.sh +++ b/infra/scripts/quota_check_params.sh @@ -92,8 +92,8 @@ az account set --subscription "$AZURE_SUBSCRIPTION_ID" echo "🎯 Active Subscription: $(az account show --query '[name, id]' --output tsv)" # Default Regions to check (Comma-separated, now configurable) -# These regions match Bicep @allowed values and support GPT-5.1 GlobalStandard as of 2026-02 -DEFAULT_REGIONS="eastus2,swedencentral,northeurope,southeastasia,uksouth,japaneast,eastasia,centralus,australiaeast" +# GPT-5.1 Global Standard availability as of 2026-02 +DEFAULT_REGIONS="australiaeast,canadaeast,eastus2,japaneast,koreacentral,swedencentral,switzerlandnorth,uksouth" IFS=',' read -r -a DEFAULT_REGION_ARRAY <<< "$DEFAULT_REGIONS" # Read parameters (if any) @@ -230,23 +230,8 @@ done if [ ${#TABLE_ROWS[@]} -eq 0 ]; then echo "--------------------------------------------------------------------------------------------------------------------" - echo "❌ DEPLOYMENT BLOCKED - No regions have sufficient quota for all required models." - echo "--------------------------------------------------------------------------------------------------------------------" - echo "" - echo "Please request a quota increase: https://aka.ms/oai/quotarequest" - echo "" - echo "Options:" - echo "1. Request quota increase for GPT-5.1 GlobalStandard" - echo "2. Reduce the gptDeploymentCapacity parameter (currently: 150 TPM)" - echo "3. Use a different Azure subscription" - echo "" - - # Set failure flag for CI/CD - if [ -n "$GITHUB_ENV" ]; then - echo "QUOTA_CHECK_FAILED=true" >> "$GITHUB_ENV" - echo "SELECTED_REGION=" >> "$GITHUB_ENV" - fi - exit 1 + + echo "❌ No regions have sufficient quota for all required models. Please request a quota increase: https://aka.ms/oai/stuquotarequest" else echo "---------------------------------------------------------------------------------------------------------------------" printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |\n" "No." "Region" "Model Name" "Limit" "Used" "Available" @@ -255,25 +240,7 @@ else echo "$ROW" done echo "---------------------------------------------------------------------------------------------------------------------" - - # Auto-select the first valid region - SELECTED_REGION="${VALID_REGIONS[0]}" - echo "" - echo "✅ DEPLOYMENT APPROVED" - echo "---------------------------------------------------------------------------------------------------------------------" - echo "Selected Region: $SELECTED_REGION" - echo "This region has sufficient quota for GPT-5.1 deployment" - echo "" - - # Export for CI/CD pipelines and future use - if [ -n "$GITHUB_ENV" ]; then - echo "QUOTA_CHECK_FAILED=false" >> "$GITHUB_ENV" - echo "SELECTED_REGION=$SELECTED_REGION" >> "$GITHUB_ENV" - fi - - # Also export as environment variable - export SELECTED_REGION - echo "Environment variable set: SELECTED_REGION=$SELECTED_REGION" + echo "➡️ To request a quota increase, visit: https://aka.ms/oai/stuquotarequest" fi -echo "✅ Quota check script completed." \ No newline at end of file +echo "✅ Script completed." \ No newline at end of file From 03c64a9a153b4ef7f2bc03f705b738cd6e888383 Mon Sep 17 00:00:00 2001 From: "Ashwal Vishwanath (Persistent Systems Inc)" Date: Wed, 17 Jun 2026 17:51:47 +0530 Subject: [PATCH 5/6] Regenerate main.json from main.bicep --- infra/main.json | 57 ++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/infra/main.json b/infra/main.json index 7aa9114e..e229ed6e 100644 --- a/infra/main.json +++ b/infra/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "12545195410241248179" + "version": "0.41.2.15936", + "templateHash": "13688965963984718310" }, "name": "Content Processing Solution Accelerator", "description": "Bicep template to deploy the Content Processing Solution Accelerator with AVM compliance." @@ -31,6 +31,7 @@ "japaneast", "northeurope", "southeastasia", + "swedencentral", "uksouth" ], "metadata": { @@ -236,6 +237,7 @@ "japaneast": "eastasia", "northeurope": "westeurope", "southeastasia": "eastasia", + "swedencentral": "northeurope", "uksouth": "westeurope", "westeurope": "northeurope" }, @@ -337,8 +339,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "13206959925771644022" + "version": "0.41.2.15936", + "templateHash": "9214155150153257283" } }, "definitions": { @@ -19306,8 +19308,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "13200482898648544945" + "version": "0.41.2.15936", + "templateHash": "9239705490942549918" } }, "parameters": { @@ -23332,8 +23334,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "15729887991536611208" + "version": "0.41.2.15936", + "templateHash": "9876669373068522244" } }, "parameters": { @@ -23936,8 +23938,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "8672669912945312056" + "version": "0.41.2.15936", + "templateHash": "12855415461261727542" }, "name": "Container Registry Module" }, @@ -36183,8 +36185,8 @@ "avmContainerApp_API", "avmContainerApp_Workflow", "avmManagedIdentity", - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageBlob)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageQueue)]", + "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageBlob)]", "virtualNetwork" ] }, @@ -36314,8 +36316,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "9621562991003135575" + "version": "0.41.2.15936", + "templateHash": "7483150072560687929" }, "name": "Cognitive Services", "description": "This module deploys a Cognitive Service." @@ -37574,8 +37576,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "8864856500234357706" + "version": "0.41.2.15936", + "templateHash": "8679467951413798233" } }, "definitions": { @@ -39307,8 +39309,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "312284397710022090" + "version": "0.41.2.15936", + "templateHash": "15190023661808709780" } }, "definitions": { @@ -39461,8 +39463,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "276675105610077046" + "version": "0.41.2.15936", + "templateHash": "10223824188701156939" } }, "definitions": { @@ -39679,8 +39681,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "8864856500234357706" + "version": "0.41.2.15936", + "templateHash": "8679467951413798233" } }, "definitions": { @@ -41412,8 +41414,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "312284397710022090" + "version": "0.41.2.15936", + "templateHash": "15190023661808709780" } }, "definitions": { @@ -41566,8 +41568,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.43.8.12551", - "templateHash": "276675105610077046" + "version": "0.41.2.15936", + "templateHash": "10223824188701156939" } }, "definitions": { @@ -42487,10 +42489,7 @@ }, "dependsOn": [ "avmAiServices", - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]", - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').contentUnderstanding)]", - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]", - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]", + "avmPrivateDnsZones", "virtualNetwork" ] }, From 6fdac2e519b7e13064f5ce5482cbcd69c0ed1235 Mon Sep 17 00:00:00 2001 From: "Ashwal Vishwanath (Persistent Systems Inc)" Date: Wed, 17 Jun 2026 18:53:31 +0530 Subject: [PATCH 6/6] Regenerate main.json using Bicep v0.44.1 --- infra/main.json | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/infra/main.json b/infra/main.json index e229ed6e..7aa966c0 100644 --- a/infra/main.json +++ b/infra/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "13688965963984718310" + "version": "0.44.1.10279", + "templateHash": "3841741921827855283" }, "name": "Content Processing Solution Accelerator", "description": "Bicep template to deploy the Content Processing Solution Accelerator with AVM compliance." @@ -339,8 +339,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "9214155150153257283" + "version": "0.44.1.10279", + "templateHash": "4148028483891244972" } }, "definitions": { @@ -19308,8 +19308,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "9239705490942549918" + "version": "0.44.1.10279", + "templateHash": "14763088429533772999" } }, "parameters": { @@ -23334,8 +23334,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "9876669373068522244" + "version": "0.44.1.10279", + "templateHash": "14944034125601240095" } }, "parameters": { @@ -23938,8 +23938,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "12855415461261727542" + "version": "0.44.1.10279", + "templateHash": "3008626070117491750" }, "name": "Container Registry Module" }, @@ -36185,8 +36185,8 @@ "avmContainerApp_API", "avmContainerApp_Workflow", "avmManagedIdentity", - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageQueue)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageBlob)]", + "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageQueue)]", "virtualNetwork" ] }, @@ -36316,8 +36316,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "7483150072560687929" + "version": "0.44.1.10279", + "templateHash": "9717412251971567270" }, "name": "Cognitive Services", "description": "This module deploys a Cognitive Service." @@ -37576,8 +37576,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "8679467951413798233" + "version": "0.44.1.10279", + "templateHash": "7181684108515692296" } }, "definitions": { @@ -39309,8 +39309,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "15190023661808709780" + "version": "0.44.1.10279", + "templateHash": "4868310155755856428" } }, "definitions": { @@ -39463,8 +39463,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "10223824188701156939" + "version": "0.44.1.10279", + "templateHash": "4168378797065634217" } }, "definitions": { @@ -39681,8 +39681,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "8679467951413798233" + "version": "0.44.1.10279", + "templateHash": "7181684108515692296" } }, "definitions": { @@ -41414,8 +41414,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "15190023661808709780" + "version": "0.44.1.10279", + "templateHash": "4868310155755856428" } }, "definitions": { @@ -41568,8 +41568,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.41.2.15936", - "templateHash": "10223824188701156939" + "version": "0.44.1.10279", + "templateHash": "4168378797065634217" } }, "definitions": {