@@ -96,6 +96,42 @@ hooks:
9696 Write-Host "Warning: post_deploy.py not found, skipping sample data upload" -ForegroundColor Yellow
9797 }
9898
99+ # Create agents in Azure AI Foundry (only when USE_FOUNDRY is enabled)
100+ if ($env:USE_FOUNDRY -eq "true" -and $env:AZURE_AI_PROJECT_ENDPOINT) {
101+ Write-Host ""
102+ Write-Host "===== Creating Foundry Agents =====" -ForegroundColor Yellow
103+ & $python -m pip install -r ./infra/scripts/agent_scripts/requirements.txt --quiet | Out-Null
104+
105+ $solutionName = if ($env:AZURE_AI_SOLUTION_NAME) { $env:AZURE_AI_SOLUTION_NAME } else { "default" }
106+ $gptModel = if ($env:AZURE_AI_MODEL_DEPLOYMENT_NAME) { $env:AZURE_AI_MODEL_DEPLOYMENT_NAME } else { $env:AZURE_OPENAI_GPT_MODEL }
107+
108+ & $python ./infra/scripts/agent_scripts/01_create_agents.py `
109+ --ai_project_endpoint $env:AZURE_AI_PROJECT_ENDPOINT `
110+ --solution_name $solutionName `
111+ --gpt_model_name $gptModel
112+
113+ if ($LASTEXITCODE -eq 0) {
114+ Write-Host "Foundry agents created successfully!" -ForegroundColor Green
115+
116+ # Inject agent name env vars into the ACI now that agents exist
117+ Write-Host "Updating ACI with agent environment variables..." -ForegroundColor Yellow
118+ $subId = (az account show --query id -o tsv)
119+ & $python ./infra/scripts/update_aci_agent_vars.py `
120+ --resource_group $env:RESOURCE_GROUP_NAME `
121+ --aci_name $env:CONTAINER_INSTANCE_NAME `
122+ --solution_name $solutionName `
123+ --subscription_id $subId
124+
125+ if ($LASTEXITCODE -eq 0) {
126+ Write-Host "ACI updated with agent environment variables!" -ForegroundColor Green
127+ } else {
128+ Write-Host "Warning: Failed to update ACI with agent env vars — the backend will use fallback agent names" -ForegroundColor Yellow
129+ }
130+ } else {
131+ Write-Host "Foundry agent creation failed — agents will need to be created manually" -ForegroundColor Yellow
132+ }
133+ }
134+
99135 Write-Host ""
100136 Write-Host "===== Deployment Complete =====" -ForegroundColor Green
101137 Write-Host ""
@@ -142,6 +178,38 @@ hooks:
142178 echo "Warning: post_deploy.py not found, skipping sample data upload"
143179 fi
144180
181+ # Create agents in Azure AI Foundry (only when USE_FOUNDRY is enabled)
182+ if [ "$USE_FOUNDRY" = "true" ] && [ -n "$AZURE_AI_PROJECT_ENDPOINT" ]; then
183+ echo ""
184+ echo "===== Creating Foundry Agents ====="
185+ "$PYTHON_BIN" -m pip install -r ./infra/scripts/agent_scripts/requirements.txt --quiet > /dev/null
186+
187+ SOLUTION_NAME="${AZURE_AI_SOLUTION_NAME:-default}"
188+ GPT_MODEL="${AZURE_AI_MODEL_DEPLOYMENT_NAME:-$AZURE_OPENAI_GPT_MODEL}"
189+
190+ "$PYTHON_BIN" ./infra/scripts/agent_scripts/01_create_agents.py \
191+ --ai_project_endpoint "$AZURE_AI_PROJECT_ENDPOINT" \
192+ --solution_name "$SOLUTION_NAME" \
193+ --gpt_model_name "$GPT_MODEL"
194+
195+ if [ $? -eq 0 ]; then
196+ echo "Foundry agents created successfully!"
197+
198+ # Inject agent name env vars into the ACI now that agents exist
199+ echo "Updating ACI with agent environment variables..."
200+ SUB_ID=$(az account show --query id -o tsv)
201+ "$PYTHON_BIN" ./infra/scripts/update_aci_agent_vars.py \
202+ --resource_group "$RESOURCE_GROUP_NAME" \
203+ --aci_name "$CONTAINER_INSTANCE_NAME" \
204+ --solution_name "$SOLUTION_NAME" \
205+ --subscription_id "$SUB_ID" \
206+ && echo "ACI updated with agent environment variables!" \
207+ || echo "Warning: Failed to update ACI with agent env vars — the backend will use fallback agent names"
208+ else
209+ echo "Foundry agent creation failed - agents will need to be created manually"
210+ fi
211+ fi
212+
145213 echo ""
146214 echo "===== Deployment Complete ====="
147215 echo ""
0 commit comments