Skip to content
Merged
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
59 changes: 43 additions & 16 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,60 @@ hooks:
postdeploy:
windows:
run: |
Write-Host "To upload Team Configurations to Cosmos. Run the following command in PowerShell:"
Write-Host "infra\scripts\Upload-Team-Config.ps1" -ForegroundColor Cyan
Write-Host ""
Write-Host "To index Sample Data into Azure Search. Run the following command in PowerShell:"
Write-Host "infra\scripts\Process-Sample-Data.ps1" -ForegroundColor Cyan
Write-Host "===============================================================" -ForegroundColor Yellow
Write-Host " POST-DEPLOYMENT STEPS (PowerShell) " -ForegroundColor Green
Write-Host "===============================================================" -ForegroundColor Yellow
Write-Host ""
Write-Host "To upload team configurations and index sample data both in one command, you can use the following command in PowerShell:"
Write-Host "infra\scripts\Team-Config-And-Data.ps1" -ForegroundColor Cyan

Write-Host " STEP 1: Upload Team Configurations to Cosmos DB" -ForegroundColor White
Write-Host " 👉 Run the following command in PowerShell:" -ForegroundColor White
Write-Host " infra\scripts\Upload-Team-Config.ps1" -ForegroundColor Cyan
Write-Host ""

Write-Host " STEP 2: Index Sample Data into Azure Search" -ForegroundColor White
Write-Host " 👉 Run the following command in PowerShell:" -ForegroundColor White
Write-Host " infra\scripts\Process-Sample-Data.ps1" -ForegroundColor Cyan
Write-Host ""

Write-Host "💡 Alternatively, you can run above BOTH steps together using:" -ForegroundColor Yellow
Write-Host " infra\scripts\Team-Config-And-Data.ps1" -ForegroundColor Cyan
Write-Host ""

Write-Host "🌐 Access your deployed Frontend application at:" -ForegroundColor Green
Write-Host " https://$env:webSiteDefaultHostname" -ForegroundColor Cyan
Write-Host ""
Write-Host "You can access the deployed Frontend application at the following URL:"
Write-Host "https://$env:webSiteDefaultHostname" -ForegroundColor Cyan
shell: pwsh
interactive: true
posix:
run: |
Blue='\033[0;34m'
Green='\033[0;32m'
Yellow='\033[1;33m'
NC='\033[0m'
echo "To upload Team Configurations to Cosmos. Run the following command in Bash:"
echo "${Blue}bash infra/scripts/upload_team_config.sh"

echo ""
echo "${Yellow}==============================================================="
echo "${Green} POST-DEPLOYMENT STEPS (Bash) "
echo "${Yellow}===============================================================${NC}"
echo ""

echo " STEP 1: Upload Team Configurations to Cosmos DB"
echo " 👉 Run the following command in Bash:"
echo " ${Blue}bash infra/scripts/upload_team_config.sh${NC}"
echo ""

echo " STEP 2: Index Sample Data into Azure Search"
echo " 👉 Run the following command in Bash:"
echo " ${Blue}bash infra/scripts/process_sample_data.sh${NC}"
echo ""
echo "${NC}To index Sample Data into Azure Search. Run the following command in Bash:"
echo "${Blue}bash infra/scripts/process_sample_data.sh"

echo "💡 Alternatively, you can run above BOTH steps together using:"
echo " ${Blue}bash infra/scripts/team_config_and_data.sh${NC}"
echo ""
echo "${NC}To upload team configurations and index sample data both in one command, you can use the following command in Bash:"
echo "${Blue}bash infra/scripts/team_config_and_data.sh"

echo "🌐 Access your deployed Frontend application at:"
echo " ${Blue}https://$webSiteDefaultHostname${NC}"
echo ""
echo "${NC}You can access the deployed Frontend application at the following URL:"
echo "${Blue}https://$webSiteDefaultHostname"
shell: sh
interactive: true
59 changes: 43 additions & 16 deletions azure_custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,60 @@ hooks:
postdeploy:
windows:
run: |
Write-Host "To upload Team Configurations to Cosmos. Run the following command in PowerShell:"
Write-Host "infra\scripts\Upload-Team-Config.ps1" -ForegroundColor Cyan
Write-Host ""
Write-Host "To index Sample Data into Azure Search. Run the following command in PowerShell:"
Write-Host "infra\scripts\Process-Sample-Data.ps1" -ForegroundColor Cyan
Write-Host "===============================================================" -ForegroundColor Yellow
Write-Host " POST-DEPLOYMENT STEPS (PowerShell) " -ForegroundColor Green
Write-Host "===============================================================" -ForegroundColor Yellow
Write-Host ""
Write-Host "If you want to run both scripts as single command, you can use the following command in PowerShell:"
Write-Host "infra\scripts\Team-Config-And-Data.ps1" -ForegroundColor Cyan

Write-Host " STEP 1: Upload Team Configurations to Cosmos DB" -ForegroundColor White
Write-Host " 👉 Run the following command in PowerShell:" -ForegroundColor White
Write-Host " infra\scripts\Upload-Team-Config.ps1" -ForegroundColor Cyan
Write-Host ""

Write-Host " STEP 2: Index Sample Data into Azure Search" -ForegroundColor White
Write-Host " 👉 Run the following command in PowerShell:" -ForegroundColor White
Write-Host " infra\scripts\Process-Sample-Data.ps1" -ForegroundColor Cyan
Write-Host ""

Write-Host "💡 Alternatively, you can run above BOTH steps together using:" -ForegroundColor Yellow
Write-Host " infra\scripts\Team-Config-And-Data.ps1" -ForegroundColor Cyan
Write-Host ""

Write-Host "🌐 Access your deployed Frontend application at:" -ForegroundColor Green
Write-Host " https://$env:webSiteDefaultHostname" -ForegroundColor Cyan
Write-Host ""
Write-Host "You can access the deployed Frontend application at the following URL:"
Write-Host "https://$env:webSiteDefaultHostname" -ForegroundColor Cyan
shell: pwsh
interactive: true
posix:
run: |
Blue='\033[0;34m'
Green='\033[0;32m'
Yellow='\033[1;33m'
NC='\033[0m'
echo "To upload Team Configurations to Cosmos. Run the following command in Bash:"
echo "${Blue}bash infra/scripts/upload_team_config.sh"

echo ""
echo "${NC}To index Sample Data into Azure Search. Run the following command in Bash:"
echo "${Blue}bash infra/scripts/process_sample_data.sh"
echo "${Yellow}==============================================================="
echo "${Green} POST-DEPLOYMENT STEPS (Bash) "
echo "${Yellow}===============================================================${NC}"
echo ""
echo "${NC}If you want to run both scripts as single command, you can use the following command in Bash:"
echo "${Blue}bash infra/scripts/team_config_and_data.sh"

echo " STEP 1: Upload Team Configurations to Cosmos DB"
echo " 👉 Run the following command in Bash:"
echo " ${Blue}bash infra/scripts/upload_team_config.sh${NC}"
echo ""

echo " STEP 2: Index Sample Data into Azure Search"
echo " 👉 Run the following command in Bash:"
echo " ${Blue}bash infra/scripts/process_sample_data.sh${NC}"
echo ""

echo "💡 Alternatively, you can run above BOTH steps together using:"
echo " ${Blue}bash infra/scripts/team_config_and_data.sh${NC}"
echo ""

echo "🌐 Access your deployed Frontend application at:"
echo " ${Blue}https://$webSiteDefaultHostname${NC}"
echo ""
echo "${NC}You can access the deployed Frontend application at the following URL:"
echo "${Blue}https://$webSiteDefaultHostname"
shell: sh
interactive: true
44 changes: 44 additions & 0 deletions infra/scripts/upload_team_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
import sys
import os
import requests
import json

def check_team_exists(backend_url, team_id, user_principal_id):
"""
Check if a team already exists in the database.

Args:
backend_url: The backend endpoint URL
team_id: The team ID to check
user_principal_id: User principal ID for authentication

Returns:
exists: bool
"""
check_endpoint = backend_url.rstrip('/') + f'/api/v3/team_configs/{team_id}'
headers = {
'x-ms-client-principal-id': user_principal_id
}

try:
response = requests.get(check_endpoint, headers=headers)
if response.status_code == 200:
return True
elif response.status_code == 404:
return False
else:
print(f"Error checking team {team_id}: Status {response.status_code}, Response: {response.text}")
return False
except Exception as e:
print(f"Exception checking team {team_id}: {str(e)}")
return False

if len(sys.argv) < 2:
print("Usage: python upload_team_config.py <backend_endpoint> <directory_path> [<user_principal_id>]")
Expand Down Expand Up @@ -28,6 +59,19 @@
file_path = os.path.join(directory_path, filename)
if os.path.isfile(file_path):
print(f"Uploading file: {filename}")
# Check if team already exists
team_exists = check_team_exists(backend_url, team_id, user_principal_id)
if team_exists:
try:
with open(file_path, 'r', encoding='utf-8') as f:
team_data = json.load(f)
team_name = team_data.get('name', 'Unknown')
print(f"Team '{team_name}' (ID: {team_id}) already exists!")
continue
except Exception as e:
print(f"Error reading {filename}: {str(e)}")
continue

try:
with open(file_path, 'rb') as file_data:
files = {
Expand Down
Loading