diff --git a/infra/scripts/Team-Config-And-Data.ps1 b/infra/scripts/Team-Config-And-Data.ps1 index 7c1e188c7..65948cccb 100644 --- a/infra/scripts/Team-Config-And-Data.ps1 +++ b/infra/scripts/Team-Config-And-Data.ps1 @@ -48,6 +48,28 @@ function Get-ValuesFromAzdEnv { return $true } +function Get-DeploymentValue { + param( + [object]$DeploymentOutputs, + [string]$PrimaryKey, + [string]$FallbackKey + ) + + $value = $null + + # Try primary key first + if ($DeploymentOutputs.PSObject.Properties[$PrimaryKey]) { + $value = $DeploymentOutputs.$PrimaryKey.value + } + + # If primary key failed, try fallback key + if (-not $value -and $DeploymentOutputs.PSObject.Properties[$FallbackKey]) { + $value = $DeploymentOutputs.$FallbackKey.value + } + + return $value +} + function Get-ValuesFromAzDeployment { Write-Host "Getting values from Azure deployment outputs..." @@ -67,12 +89,12 @@ function Get-ValuesFromAzDeployment { return $false } - # Extract specific outputs - $script:storageAccount = $deploymentOutputs.azurE_STORAGE_ACCOUNT_NAME.value - $script:blobContainer = $deploymentOutputs.azurE_STORAGE_CONTAINER_NAME.value - $script:aiSearch = $deploymentOutputs.azurE_AI_SEARCH_NAME.value - $script:aiSearchIndex = $deploymentOutputs.azurE_AI_SEARCH_INDEX_NAME.value - $script:backendUrl = $deploymentOutputs.backenD_URL.value + # Extract specific outputs with fallback logic + $script:storageAccount = Get-DeploymentValue -DeploymentOutputs $deploymentOutputs -PrimaryKey "azurE_STORAGE_ACCOUNT_NAME" -FallbackKey "azureStorageAccountName" + $script:blobContainer = Get-DeploymentValue -DeploymentOutputs $deploymentOutputs -PrimaryKey "azurE_STORAGE_CONTAINER_NAME" -FallbackKey "azureStorageContainerName" + $script:aiSearch = Get-DeploymentValue -DeploymentOutputs $deploymentOutputs -PrimaryKey "azurE_AI_SEARCH_NAME" -FallbackKey "azureAiSearchName" + $script:aiSearchIndex = Get-DeploymentValue -DeploymentOutputs $deploymentOutputs -PrimaryKey "azurE_AI_SEARCH_INDEX_NAME" -FallbackKey "azureAiSearchIndexName" + $script:backendUrl = Get-DeploymentValue -DeploymentOutputs $deploymentOutputs -PrimaryKey "backenD_URL" -FallbackKey "backendUrl" # Validate that we extracted all required values if (-not $script:storageAccount -or -not $script:blobContainer -or -not $script:aiSearch -or -not $script:aiSearchIndex -or -not $script:backendUrl) { diff --git a/infra/scripts/team_config_and_data.sh b/infra/scripts/team_config_and_data.sh index b917180f3..d7aaf214a 100644 --- a/infra/scripts/team_config_and_data.sh +++ b/infra/scripts/team_config_and_data.sh @@ -47,6 +47,19 @@ get_values_from_azd_env() { return 0 } +# Helper function to extract value with fallback +extract_value() { + local primary_key="$1" + local fallback_key="$2" + local result + + result=$(echo "$deploymentOutputs" | grep -A 3 "\"$primary_key\"" | grep '"value"' | sed 's/.*"value": *"\([^"]*\)".*/\1/') + if [ -z "$result" ]; then + result=$(echo "$deploymentOutputs" | grep -A 3 "\"$fallback_key\"" | grep '"value"' | sed 's/.*"value": *"\([^"]*\)".*/\1/') + fi + echo "$result" +} + get_values_from_az_deployment() { echo "Getting values from Azure deployment outputs..." @@ -66,12 +79,12 @@ get_values_from_az_deployment() { return 1 fi - # Extract specific outputs - storageAccount=$(echo "$deploymentOutputs" | grep -A 3 '"azurE_STORAGE_ACCOUNT_NAME"' | grep '"value"' | sed 's/.*"value": *"\([^"]*\)".*/\1/') - blobContainer=$(echo "$deploymentOutputs" | grep -A 3 '"azurE_STORAGE_CONTAINER_NAME"' | grep '"value"' | sed 's/.*"value": *"\([^"]*\)".*/\1/') - aiSearch=$(echo "$deploymentOutputs" | grep -A 3 '"azurE_AI_SEARCH_NAME"' | grep '"value"' | sed 's/.*"value": *"\([^"]*\)".*/\1/') - aiSearchIndex=$(echo "$deploymentOutputs" | grep -A 3 '"azurE_AI_SEARCH_INDEX_NAME"' | grep '"value"' | sed 's/.*"value": *"\([^"]*\)".*/\1/') - backendUrl=$(echo "$deploymentOutputs" | grep -A 3 '"backenD_URL"' | grep '"value"' | sed 's/.*"value": *"\([^"]*\)".*/\1/') + # Extract all values using the helper function + storageAccount=$(extract_value "azurE_STORAGE_ACCOUNT_NAME" "azureStorageAccountName") + blobContainer=$(extract_value "azurE_STORAGE_CONTAINER_NAME" "azureStorageContainerName") + aiSearch=$(extract_value "azurE_AI_SEARCH_NAME" "azureAiSearchName") + aiSearchIndex=$(extract_value "azurE_AI_SEARCH_INDEX_NAME" "azureAiSearchIndexName") + backendUrl=$(extract_value "backenD_URL" "backendUrl") # Validate that we extracted all required values if [ -z "$storageAccount" ] || [ -z "$blobContainer" ] || [ -z "$aiSearch" ] || [ -z "$aiSearchIndex" ] || [ -z "$backendUrl" ]; then