@@ -214,6 +214,70 @@ function Get-ValuesFromAzDeployment {
214214 return $true
215215}
216216
217+ function Get-ValuesUsingSolutionSuffix {
218+ Write-Host " Getting values from resource naming convention using solution suffix..."
219+
220+ # Get the solution suffix from resource group tags
221+ $solutionSuffix = az group show -- name $ResourceGroup -- query " tags.SolutionSuffix" - o tsv
222+ if (-not $solutionSuffix ) {
223+ Write-Host " Error: Could not find SolutionSuffix tag in resource group."
224+ return $false
225+ }
226+
227+ Write-Host " Found solution suffix: $solutionSuffix "
228+
229+ # Reconstruct resource names using same naming convention as Bicep
230+ $script :storageAccount = " st$solutionSuffix " -replace ' -' , ' ' # Remove dashes like Bicep does
231+ $script :aiSearch = " srch-$solutionSuffix "
232+ $containerAppName = " ca-$solutionSuffix "
233+
234+ # Query dynamic value (backend URL) from Container App
235+ Write-Host " Querying backend URL from Container App..."
236+ $backendFqdn = az containerapp show `
237+ -- name $containerAppName `
238+ -- resource- group $ResourceGroup `
239+ -- query " properties.configuration.ingress.fqdn" `
240+ - o tsv 2> $null
241+
242+ if (-not $backendFqdn ) {
243+ Write-Host " Error: Could not get Container App FQDN. Container App may not be deployed yet."
244+ return $false
245+ }
246+
247+ $script :backendUrl = " https://$backendFqdn "
248+
249+ # Hardcoded container names (These don't follow the suffix pattern in Bicep, hence need to be changed here if changed in Bicep)
250+ $script :blobContainerForRetailCustomer = " retail-dataset-customer"
251+ $script :blobContainerForRetailOrder = " retail-dataset-order"
252+ $script :blobContainerForRFPSummary = " rfp-summary-dataset"
253+ $script :blobContainerForRFPRisk = " rfp-risk-dataset"
254+ $script :blobContainerForRFPCompliance = " rfp-compliance-dataset"
255+ $script :blobContainerForContractSummary = " contract-summary-dataset"
256+ $script :blobContainerForContractRisk = " contract-risk-dataset"
257+ $script :blobContainerForContractCompliance = " contract-compliance-dataset"
258+
259+ # Hardcoded index names (These don't follow the suffix pattern in Bicep, hence need to be changed here if changed in Bicep)
260+ $script :aiSearchIndexForRetailCustomer = " macae-retail-customer-index"
261+ $script :aiSearchIndexForRetailOrder = " macae-retail-order-index"
262+ $script :aiSearchIndexForRFPSummary = " macae-rfp-summary-index"
263+ $script :aiSearchIndexForRFPRisk = " macae-rfp-risk-index"
264+ $script :aiSearchIndexForRFPCompliance = " macae-rfp-compliance-index"
265+ $script :aiSearchIndexForContractSummary = " contract-summary-doc-index"
266+ $script :aiSearchIndexForContractRisk = " contract-risk-doc-index"
267+ $script :aiSearchIndexForContractCompliance = " contract-compliance-doc-index"
268+
269+ $script :directoryPath = " data/agent_teams"
270+
271+ # Validate that we got all critical values
272+ if (-not $script :storageAccount -or -not $script :aiSearch -or -not $script :backendUrl ) {
273+ Write-Host " Error: Failed to reconstruct all required resource names."
274+ return $false
275+ }
276+
277+ Write-Host " Successfully reconstructed values from resource naming convention."
278+ return $true
279+ }
280+
217281# Main script execution with cleanup handling
218282try {
219283# Authenticate with Azure
@@ -301,14 +365,24 @@ if (-not $ResourceGroup) {
301365 exit 1
302366 }
303367} else {
304- # Resource group provided - use deployment outputs
368+ # Resource group provided - try deployment outputs first, then fallback to naming convention
305369 Write-Host " Resource group provided: $ResourceGroup "
306370
307371 if (-not (Get-ValuesFromAzDeployment )) {
308- Write-Host " Failed to get values from deployment outputs."
309- exit 1
372+ Write-Host " "
373+ Write-Host " Warning: Could not retrieve values from deployment outputs (deployment may be deleted)."
374+ Write-Host " Attempting fallback method: reconstructing values from resource naming convention..."
375+ Write-Host " "
376+
377+ if (-not (Get-ValuesUsingSolutionSuffix )) {
378+ Write-Host " "
379+ Write-Host " Error: Both methods failed to retrieve configuration values."
380+ Write-Host " Please ensure:"
381+ Write-Host " 1. The deployment exists and has a DeploymentName tag, OR"
382+ Write-Host " 2. The resource group has a SolutionSuffix tag"
383+ exit 1
384+ }
310385 }
311- }
312386
313387# Interactive Use Case Selection
314388Write-Host " "
@@ -787,12 +861,11 @@ if($useCaseSelection -eq "2" -or $useCaseSelection -eq "all" -or $useCaseSelecti
787861 Write-Host " Python script to index data for Retail Customer Satisfaction successfully executed."
788862}
789863
790- Write-Host " Script executed successfully. Sample Data Processed Successfully."
791-
792864if ($isTeamConfigFailed -or $isSampleDataFailed ) {
793865 Write-Host " `n One or more tasks failed. Please check the error messages above."
794866 exit 1
795867} else {
868+ Write-Host " `n Script executed successfully. Sample Data Processed Successfully."
796869 if ($useCaseSelection -eq " 1" -or $useCaseSelection -eq " 2" -or $useCaseSelection -eq " 5" -or $useCaseSelection -eq " all" -or $useCaseSelection -eq " 6" ){
797870 Write-Host " `n Team configuration upload and sample data processing completed successfully."
798871 }else {
0 commit comments