@@ -109,7 +109,8 @@ function Set-DeploymentValues($Region, $Capacity) {
109109
110110function Manual-Prompt {
111111 while ($true ) {
112- $ManualRegion = Read-Host " `n Please enter a region you want to try manually"
112+ Write-Host " `n 📍 Recommended regions (≥ $RECOMMENDED_TOKENS tokens available): $ ( $RecommendedRegions -join ' , ' ) "
113+ $ManualRegion = Read-Host " Please enter a region you want to try manually"
113114 if (-not $ManualRegion ) {
114115 Write-Host " ❌ ERROR: No region entered. Exiting."
115116 exit 1
@@ -151,80 +152,57 @@ function Manual-Prompt {
151152 }
152153}
153154
154- # Start validation and execution
155+ # Start validation and quota checks
155156Validate- Inputs
156157
157158Write-Host " `n 🔍 Checking quota in the requested region '$Location '..."
158159$PrimaryResult = Check- Quota - Region $Location
159-
160160if ($PrimaryResult ) {
161- $AllResults += $PrimaryResult
162- if ($PrimaryResult.Available -ge $Capacity ) {
163- if ($RecommendedRegions -notcontains $Location -and $RecommendedRegions.Count -gt 0 ) {
164- Write-Host " `n ⚠️ Selected region '$Location ' has sufficient quota but is not among the recommended regions (≥ $RECOMMENDED_TOKENS tokens)."
165- Write-Host " 🚨 Your application may not work as expected due to limited quota."
166- Write-Host " `n ℹ️ Recommended regions: $ ( $RecommendedRegions -join ' , ' ) "
167- if (Confirm-Action " ❓ Do you want to choose a recommended region instead?" ) {
168- Show-Table
169- exit 0
170- } else {
171- if ($Capacity -gt $RECOMMENDED_TOKENS ) {
172- Write-Host " `n ⚠️ Reducing capacity to $RECOMMENDED_TOKENS in '$BicepParamsFile ' for safer deployment..."
173- (Get-Content $BicepParamsFile ) -replace " capacity\s*:\s*\d+" , " capacity: $RECOMMENDED_TOKENS " | Set-Content $BicepParamsFile
174- Write-Host " ✅ Updated '$BicepParamsFile ' with capacity $RECOMMENDED_TOKENS ."
175- }
176- Set-DeploymentValues $Location $Capacity
177- Write-Host " ✅ Proceeding with '$Location ' as selected."
178- exit 0
179- }
180- } else {
181- Write-Host " `n ✅ Sufficient quota found in original region '$Location '."
182- if ($PrimaryResult.Available -lt $RECOMMENDED_TOKENS ) {
183- Write-Host " `n ⚠️ You have provided a capacity of $Capacity , which is less than the recommended minimum ($RECOMMENDED_TOKENS )."
184- Write-Host " 🚨 This may cause performance issues or unexpected behavior."
185- if ($RecommendedRegions.Count -gt 0 ) {
186- Write-Host " ℹ️ Recommended regions (≥ $RECOMMENDED_TOKENS tokens available): $ ( $RecommendedRegions -join ' , ' ) "
187- }
188- if (-not (Confirm-Action " ❓ Proceed anyway?" )) {
189- Write-Host " ❌ Deployment aborted by user. Please select another region or capacity."
190- exit 1
191- }
192- }
193- Set-DeploymentValues $Location $Capacity
194- exit 0
195- }
196- } else {
197- Write-Host " `n ⚠️ Insufficient quota in '$Location ' (Available: $ ( $PrimaryResult.Available ) , Required: $Capacity ). Checking fallback regions..."
198- }
199- } else {
200- Write-Host " `n ⚠️ Could not retrieve quota info for region '$Location '."
161+ $AllResults = @ ($AllResults ) + $PrimaryResult
201162}
202163
203164foreach ($region in $PreferredRegions ) {
204- if ($region -eq $Location ) { continue }
205- $result = Check- Quota - Region $region
206- if ($result ) {
207- $AllResults += $result
208- if ($result.Available -ge $Capacity ) {
209- $EligibleFallbacks += $region
165+ if ($region -ne $Location ) {
166+ $fallbackResult = Check- Quota - Region $region
167+ if ($fallbackResult ) {
168+ $AllResults = @ ($AllResults ) + $fallbackResult
169+ if ($fallbackResult.Available -ge $Capacity ) {
170+ $EligibleFallbacks += $region
171+ }
210172 }
211173 }
212174}
213175
214176Show-Table
215177
216- if ($EligibleFallbacks.Count -gt 0 ) {
217- Write-Host " `n ➡️ Found fallback regions with sufficient quota."
178+ if ($Capacity -lt $RECOMMENDED_TOKENS ) {
179+ Write-Host " `n ⚠️ You have entered a capacity of $Capacity , which is less than the recommended minimum ($RECOMMENDED_TOKENS )."
180+ Write-Host " 🚨 This may cause performance issues or unexpected behavior."
181+ Write-Host " ℹ️ Recommended regions (≥ $RECOMMENDED_TOKENS tokens available):"
218182 if ($RecommendedRegions.Count -gt 0 ) {
219- Write-Host " `n ℹ️ Recommended regions (≥ $RECOMMENDED_TOKENS tokens available):"
220183 foreach ($region in $RecommendedRegions ) {
221184 Write-Host " - $region "
222185 }
186+ } else {
187+ Write-Host " ❌ No recommended regions currently available."
223188 }
224- Write-Host " `n ❗ The originally selected region '$Location ' does not have enough quota."
189+ if (-not (Confirm-Action " ❓ Proceed anyway?" )) {
190+ Manual- Prompt
191+ exit 0
192+ }
193+ }
194+
195+ if ($PrimaryResult -and $PrimaryResult.Available -ge $Capacity ) {
196+ Set-DeploymentValues $Location $Capacity
197+ Write-Host " ✅ Proceeding with '$Location ' as selected."
198+ exit 0
199+ }
200+
201+ Write-Host " `n ❗ The originally selected region '$Location ' does not have enough quota."
202+ if ($EligibleFallbacks.Count -gt 0 ) {
225203 Write-Host " 👉 You can manually choose one of the recommended fallback regions for deployment."
226204} else {
227- Write-Host " `n ❌ ERROR: No region has sufficient quota."
205+ Write-Host " ❌ ERROR: No region has sufficient quota."
228206}
229207
230208Manual- Prompt
0 commit comments