-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-analytics.ps1
More file actions
73 lines (57 loc) · 2.53 KB
/
deploy-analytics.ps1
File metadata and controls
73 lines (57 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env pwsh
# LaFontaine Analytics Deployment Script
# This script deploys the analytics backend to Azure Container Apps
Write-Host "🚀 Starting LaFontaine Analytics deployment..." -ForegroundColor Green
# Check if Azure CLI is installed
if (!(Get-Command az -ErrorAction SilentlyContinue)) {
Write-Error "Azure CLI is not installed. Please install it first: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli"
exit 1
}
# Check if azd is installed
if (!(Get-Command azd -ErrorAction SilentlyContinue)) {
Write-Error "Azure Developer CLI (azd) is not installed. Please install it first: https://docs.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd"
exit 1
}
try {
Write-Host "📋 Initializing azd environment..." -ForegroundColor Yellow
# Initialize azd if not already done
if (!(Test-Path ".azure")) {
azd init --template minimal
}
Write-Host "🔧 Setting up environment..." -ForegroundColor Yellow
# Set default environment name if not set
if (!(azd env list | Select-String "default")) {
azd env new default
azd env select default
}
Write-Host "☁️ Provisioning Azure resources..." -ForegroundColor Yellow
# Provision infrastructure
azd provision --preview
# Ask for confirmation
$confirmation = Read-Host "Do you want to proceed with deployment? (y/N)"
if ($confirmation -ne "y" -and $confirmation -ne "Y") {
Write-Host "Deployment cancelled." -ForegroundColor Yellow
exit 0
}
# Deploy the application
Write-Host "🚀 Deploying application..." -ForegroundColor Yellow
azd up
Write-Host "✅ Deployment completed successfully!" -ForegroundColor Green
# Get the analytics API URL
$apiUrl = azd show | Select-String "ANALYTICS_API_URI" | ForEach-Object { $_.ToString().Split(":")[1].Trim() }
if ($apiUrl) {
Write-Host ""
Write-Host "🎉 Your analytics API is now available at:" -ForegroundColor Green
Write-Host " $apiUrl" -ForegroundColor Cyan
Write-Host ""
Write-Host "📝 Next steps:" -ForegroundColor Yellow
Write-Host " 1. Update your frontend globalAnalytics.ts with the API URL above"
Write-Host " 2. Redeploy your frontend to GitHub Pages"
Write-Host " 3. Test the analytics collection"
Write-Host ""
}
} catch {
Write-Error "Deployment failed: $_"
Write-Host "❌ Please check the error messages above and try again." -ForegroundColor Red
exit 1
}