Skip to content

Commit 87bd074

Browse files
committed
fix(post_deploy): fail script on step errors and add azure-ai-projects dep
- Add azure-ai-projects to requirements.txt (fixes vector store ModuleNotFoundError) - Track step failures with $script:hasErrors flag - Exit with code 1 and report errors when any step fails - Change WARNING to ERROR with red output for failed steps - Only print 'ready to use' when all steps succeed
1 parent ad7838c commit 87bd074

2 files changed

Lines changed: 32 additions & 12 deletions

File tree

infra/scripts/post_deploy.ps1

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ param(
2424

2525
Set-StrictMode -Version Latest
2626
$ErrorActionPreference = "Stop"
27+
$script:hasErrors = $false
2728

2829
# ──────────────────────────────────────────────────────────────────────────────
2930
# Helper functions
@@ -394,7 +395,8 @@ $env:COSMOSDB_CONTAINER = $cosmosContainer
394395

395396
$seedTeamsScript | & $pythonCmd -
396397
if ($LASTEXITCODE -ne 0) {
397-
Write-Host "WARNING: Team config seeding had errors." -ForegroundColor Yellow
398+
Write-Host " ERROR: Team config seeding had errors." -ForegroundColor Red
399+
$script:hasErrors = $true
398400
}
399401

400402
# ──────────────────────────────────────────────────────────────────────────────
@@ -427,6 +429,7 @@ if ($selectedDataPacks.Count -gt 0) {
427429
$result = Deploy-ContentPack -PackPath $packPath -StorageAccountName $storageAccount -AiSearchName $aiSearchName -PythonCmd $pythonCmd
428430
if (-not $result) {
429431
$isSampleDataFailed = $true
432+
$script:hasErrors = $true
430433
Write-Host " Error in data deployment for $packPath" -ForegroundColor Red
431434
}
432435
}
@@ -440,7 +443,8 @@ if ($selectedDataPacks.Count -gt 0) {
440443
$env:AZURE_AI_PROJECT_ENDPOINT = $projectEndpoint
441444
$process = Start-Process -FilePath $pythonCmd -ArgumentList "infra/scripts/seed_vector_stores.py" -Wait -NoNewWindow -PassThru
442445
if ($process.ExitCode -ne 0) {
443-
Write-Host " WARNING: Vector store creation failed. Run 'python infra/scripts/seed_vector_stores.py' manually." -ForegroundColor Yellow
446+
Write-Host " ERROR: Vector store creation failed. Run 'python infra/scripts/seed_vector_stores.py' manually." -ForegroundColor Red
447+
$script:hasErrors = $true
444448
} else {
445449
Write-Host " Vector stores created successfully."
446450
}
@@ -455,7 +459,8 @@ if ($selectedDataPacks.Count -gt 0) {
455459
$env:AZURE_OPENAI_ENDPOINT = $openaiEndpoint
456460
$process = Start-Process -FilePath $pythonCmd -ArgumentList "infra/scripts/seed_knowledge_bases.py" -Wait -NoNewWindow -PassThru
457461
if ($process.ExitCode -ne 0) {
458-
Write-Host " WARNING: Knowledge base seeding failed. Run 'python infra/scripts/seed_knowledge_bases.py' manually." -ForegroundColor Yellow
462+
Write-Host " ERROR: Knowledge base seeding failed. Run 'python infra/scripts/seed_knowledge_bases.py' manually." -ForegroundColor Red
463+
$script:hasErrors = $true
459464
} else {
460465
Write-Host " Knowledge bases seeded successfully."
461466
}
@@ -467,12 +472,25 @@ if ($selectedDataPacks.Count -gt 0) {
467472
# Done
468473
# ──────────────────────────────────────────────────────────────────────────────
469474

470-
Write-Host "`n========================================" -ForegroundColor Green
471-
Write-Host " Post-deployment data seeding complete!" -ForegroundColor Green
472-
Write-Host "========================================" -ForegroundColor Green
473-
Write-Host "`nThe application is ready to use."
474-
$frontendHost = $(azd env get-value webSiteDefaultHostname 2>$null)
475-
if ($frontendHost) {
476-
Write-Host "Frontend: https://$frontendHost"
475+
if ($script:hasErrors) {
476+
Write-Host "`n========================================" -ForegroundColor Red
477+
Write-Host " Post-deployment seeding completed with ERRORS" -ForegroundColor Red
478+
Write-Host "========================================" -ForegroundColor Red
479+
Write-Host "`nOne or more steps failed. Review the output above and re-run the failed steps manually." -ForegroundColor Yellow
480+
$frontendHost = $(azd env get-value webSiteDefaultHostname 2>$null)
481+
if ($frontendHost) {
482+
Write-Host "Frontend: https://$frontendHost"
483+
}
484+
Write-Host ""
485+
exit 1
486+
} else {
487+
Write-Host "`n========================================" -ForegroundColor Green
488+
Write-Host " Post-deployment data seeding complete!" -ForegroundColor Green
489+
Write-Host "========================================" -ForegroundColor Green
490+
Write-Host "`nThe application is ready to use."
491+
$frontendHost = $(azd env get-value webSiteDefaultHostname 2>$null)
492+
if ($frontendHost) {
493+
Write-Host "Frontend: https://$frontendHost"
494+
}
495+
Write-Host ""
477496
}
478-
Write-Host ""

infra/scripts/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ aiohttp
66
requests==2.32.5
77
httpx
88
azure-core
9+
azure-ai-projects
910
PyPDF2
10-
python-docx
11+
python-docx
12+
python-dotenv

0 commit comments

Comments
 (0)