Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
Type: enablePrivateNetworking ? 'WAF' : 'Non-WAF'
CreatedBy: createdBy
DeploymentName: deployment().name
SolutionSuffix: solutionSuffix
}
}
}
Expand Down
1 change: 1 addition & 0 deletions infra/main_custom.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
Type: enablePrivateNetworking ? 'WAF' : 'Non-WAF'
CreatedBy: createdBy
DeploymentName: deployment().name
SolutionSuffix: solutionSuffix
}
}
}
Expand Down
83 changes: 80 additions & 3 deletions infra/scripts/Selecting-Team-Config-And-Data.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,70 @@ function Get-ValuesFromAzDeployment {
return $true
}

function Get-ValuesUsingSolutionSuffix {
Write-Host "Getting values from resource naming convention using solution suffix..."

# Get the solution suffix from resource group tags
$solutionSuffix = az group show --name $ResourceGroup --query "tags.SolutionSuffix" -o tsv
if (-not $solutionSuffix) {
Write-Host "Error: Could not find SolutionSuffix tag in resource group."
return $false
}

Write-Host "Found solution suffix: $solutionSuffix"

# Reconstruct resource names using same naming convention as Bicep
$script:storageAccount = "st$solutionSuffix" -replace '-', '' # Remove dashes like Bicep does
$script:aiSearch = "srch-$solutionSuffix"
$containerAppName = "ca-$solutionSuffix"

# Query dynamic value (backend URL) from Container App
Write-Host "Querying backend URL from Container App..."
$backendFqdn = az containerapp show `
--name $containerAppName `
--resource-group $ResourceGroup `
--query "properties.configuration.ingress.fqdn" `
-o tsv 2>$null

if (-not $backendFqdn) {
Write-Host "Error: Could not get Container App FQDN. Container App may not be deployed yet."
return $false
}

$script:backendUrl = "https://$backendFqdn"

# Hardcoded container names (These don't follow the suffix pattern in Bicep, hence need to be changed here if changed in Bicep)
$script:blobContainerForRetailCustomer = "retail-dataset-customer"
$script:blobContainerForRetailOrder = "retail-dataset-order"
$script:blobContainerForRFPSummary = "rfp-summary-dataset"
$script:blobContainerForRFPRisk = "rfp-risk-dataset"
$script:blobContainerForRFPCompliance = "rfp-compliance-dataset"
$script:blobContainerForContractSummary = "contract-summary-dataset"
$script:blobContainerForContractRisk = "contract-risk-dataset"
$script:blobContainerForContractCompliance = "contract-compliance-dataset"

# Hardcoded index names (These don't follow the suffix pattern in Bicep, hence need to be changed here if changed in Bicep)
$script:aiSearchIndexForRetailCustomer = "macae-retail-customer-index"
$script:aiSearchIndexForRetailOrder = "macae-retail-order-index"
$script:aiSearchIndexForRFPSummary = "macae-rfp-summary-index"
$script:aiSearchIndexForRFPRisk = "macae-rfp-risk-index"
$script:aiSearchIndexForRFPCompliance = "macae-rfp-compliance-index"
$script:aiSearchIndexForContractSummary = "contract-summary-doc-index"
$script:aiSearchIndexForContractRisk = "contract-risk-doc-index"
$script:aiSearchIndexForContractCompliance = "contract-compliance-doc-index"

$script:directoryPath = "data/agent_teams"

# Validate that we got all critical values
if (-not $script:storageAccount -or -not $script:aiSearch -or -not $script:backendUrl) {
Write-Host "Error: Failed to reconstruct all required resource names."
return $false
}

Write-Host "Successfully reconstructed values from resource naming convention."
return $true
}

# Authenticate with Azure
try {
$null = az account show 2>$null
Expand Down Expand Up @@ -233,12 +297,23 @@ if (-not $ResourceGroup) {
exit 1
}
} else {
# Resource group provided - use deployment outputs
# Resource group provided - try deployment outputs first, then fallback to naming convention
Write-Host "Resource group provided: $ResourceGroup"

if (-not (Get-ValuesFromAzDeployment)) {
Write-Host "Failed to get values from deployment outputs."
exit 1
Write-Host ""
Write-Host "Warning: Could not retrieve values from deployment outputs (deployment may be deleted)."
Write-Host "Attempting fallback method: reconstructing values from resource naming convention..."
Write-Host ""

if (-not (Get-ValuesUsingSolutionSuffix)) {
Write-Host ""
Write-Host "Error: Both methods failed to retrieve configuration values."
Write-Host "Please ensure:"
Write-Host " 1. The deployment exists and has a DeploymentName tag, OR"
Write-Host " 2. The resource group has a SolutionSuffix tag"
exit 1
}
}
}

Expand Down Expand Up @@ -434,6 +509,7 @@ if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection
Write-Host "Error: Failed to enable public access for storage account."
exit 1
}
Start-Sleep -Seconds 60
}
else {
Write-Host "Public access is already enabled for storage account: $storageAccount"
Expand All @@ -448,6 +524,7 @@ if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection
Write-Host "Error: Failed to enable public access for search service."
exit 1
}
Start-Sleep -Seconds 60
}
else {
Write-Host "Public access is already enabled for search service: $AiSearch"
Expand Down
83 changes: 80 additions & 3 deletions infra/scripts/selecting_team_config_and_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,70 @@ function get_values_from_az_deployment() {
return 0
}

function get_values_using_solution_suffix() {
echo "Getting values from resource naming convention using solution suffix..."

# Get the solution suffix from resource group tags
solutionSuffix=$(az group show --name "$ResourceGroup" --query "tags.SolutionSuffix" -o tsv)
if [[ -z "$solutionSuffix" ]]; then
echo "Error: Could not find SolutionSuffix tag in resource group."
return 1
fi

echo "Found solution suffix: $solutionSuffix"

# Reconstruct resource names using same naming convention as Bicep
storageAccount=$(echo "st${solutionSuffix}" | tr -d '-') # Remove dashes like Bicep does
aiSearch="srch-${solutionSuffix}"
containerAppName="ca-${solutionSuffix}"

# Query dynamic value (backend URL) from Container App
echo "Querying backend URL from Container App..."
backendFqdn=$(az containerapp show \
--name "$containerAppName" \
--resource-group "$ResourceGroup" \
--query "properties.configuration.ingress.fqdn" \
-o tsv 2>/dev/null)

if [[ -z "$backendFqdn" ]]; then
echo "Error: Could not get Container App FQDN. Container App may not be deployed yet."
return 1
fi

backendUrl="https://${backendFqdn}"

# Hardcoded container names (These don't follow the suffix pattern in Bicep, hence need to be changed here if changed in Bicep)
blobContainerForRetailCustomer="retail-dataset-customer"
blobContainerForRetailOrder="retail-dataset-order"
blobContainerForRFPSummary="rfp-summary-dataset"
blobContainerForRFPRisk="rfp-risk-dataset"
blobContainerForRFPCompliance="rfp-compliance-dataset"
blobContainerForContractSummary="contract-summary-dataset"
blobContainerForContractRisk="contract-risk-dataset"
blobContainerForContractCompliance="contract-compliance-dataset"

# Hardcoded index names (These don't follow the suffix pattern in Bicep, hence need to be changed here if changed in Bicep)
aiSearchIndexForRetailCustomer="macae-retail-customer-index"
aiSearchIndexForRetailOrder="macae-retail-order-index"
aiSearchIndexForRFPSummary="macae-rfp-summary-index"
aiSearchIndexForRFPRisk="macae-rfp-risk-index"
aiSearchIndexForRFPCompliance="macae-rfp-compliance-index"
aiSearchIndexForContractSummary="contract-summary-doc-index"
aiSearchIndexForContractRisk="contract-risk-doc-index"
aiSearchIndexForContractCompliance="contract-compliance-doc-index"

directoryPath="data/agent_teams"

# Validate that we got all critical values
if [[ -z "$storageAccount" || -z "$aiSearch" || -z "$backendUrl" ]]; then
echo "Error: Failed to reconstruct all required resource names."
return 1
fi

echo "Successfully reconstructed values from resource naming convention."
return 0
}

# Authenticate with Azure
if az account show &> /dev/null; then
echo "Already authenticated with Azure."
Expand Down Expand Up @@ -231,12 +295,23 @@ if [[ -z "$ResourceGroup" ]]; then
exit 1
fi
else
# Resource group provided - use deployment outputs
# Resource group provided - use deployment outputs, then fallback to naming convention
echo "Resource group provided: $ResourceGroup"

if ! get_values_from_az_deployment; then
echo "Failed to get values from deployment outputs."
exit 1
echo ""
echo "Warning: Could not retrieve values from deployment outputs (deployment may be deleted)."
echo "Attempting fallback method: reconstructing values from resource naming convention..."
echo ""

if ! get_values_using_solution_suffix; then
echo ""
echo "Error: Both methods failed to retrieve configuration values."
echo "Please ensure:"
echo " 1. The deployment exists and has a DeploymentName tag, OR"
echo " 2. The resource group has a SolutionSuffix tag"
exit 1
fi
fi
fi

Expand Down Expand Up @@ -409,6 +484,7 @@ if [[ "$useCaseSelection" == "1" || "$useCaseSelection" == "2" || "$useCaseSelec
echo "Error: Failed to enable public access for storage account."
exit 1
fi
sleep 60
else
echo "Public access is already enabled for storage account: $storageAccount"
fi
Expand All @@ -422,6 +498,7 @@ if [[ "$useCaseSelection" == "1" || "$useCaseSelection" == "2" || "$useCaseSelec
echo "Error: Failed to enable public access for search service."
exit 1
fi
sleep 60
else
echo "Public access is already enabled for search service: $aiSearch"
fi
Expand Down
Loading