Deploy your Calendar Integration Backend using Azure Portal
- Go to Azure Portal: https://portal.azure.com
- Click "Create a resource"
- Search for "Azure Database for PostgreSQL"
- Select "Azure Database for PostgreSQL flexible server"
- Click "Create"
Configuration:
- Resource Group: Create new →
calendar-integration-rg - Server Name:
calendar-integration-db(must be globally unique) - Region: Choose closest to you (e.g., East US)
- PostgreSQL Version: 14
- Workload Type: Development
- Admin Username:
calendaradmin - Password: Create a strong password (save it!)
- Pricing Tier: Burstable → B1ms (1 vCore, 2GB RAM) - ~$20/month
- Click "Review + Create" → "Create"
- Wait for deployment (takes 5-10 minutes)
-
Go to your database resource
-
Click "Databases" in left menu
-
Click "+ Add"
-
Database Name:
calender_app -
Click "Save"
-
Configure Firewall:
- Go to "Networking" in left menu
- Check "Allow public access from any Azure service within Azure" ✅
- For Development: Add your IP: Click "Add current client IP address"
- For Production: Remove your IP rule (keep only Azure services)
- Click "Save"
⚠️ Security Note:- The "Azure services" rule allows your App Service to connect
- Users access your app through the frontend/backend, NOT directly to database
- Never add 0.0.0.0/0 (all IPs) - this would be insecure
- Go back to Azure Portal home
- Click "Create a resource"
- Search for "Web App"
- Click "Create"
Configuration:
- Resource Group: Select
calendar-integration-rg - Name:
calendar-integration-backend(must be globally unique) - Publish: Code
- Runtime Stack: Node 18 LTS
- Operating System: Linux
- Region: Same as database
- Pricing Plan:
- Click "Create new"
- Name:
calendar-plan - Size: Basic B1 (~$13/month) or Free F1 (limited)
- Click "Review + Create" → "Create"
- Wait for deployment
- Go to your Web App resource
- Click "Configuration" in left menu
- Click "Application settings" tab
- Add these environment variables (click "+ New application setting" for each):
CRITICAL Variables (Required):
Name: DATABASE_URL
Value: postgresql://calendaradmin:YOUR_PASSWORD@calendar-integration-db.postgres.database.azure.com:5432/calender_app?sslmode=require
Name: GOOGLE_CLIENT_ID
Value: YOUR_GOOGLE_CLIENT_ID_HERE
Name: GOOGLE_CLIENT_SECRET
Value: YOUR_GOOGLE_CLIENT_SECRET_HERE
Name: GOOGLE_REDIRECT_URL
Value: https://calendar-integration-backend-eabkffc4gphtenfc.westus-01.azurewebsites.net/api/auth/google/callback
Name: FRONTEND_URL
Value: http://localhost:3000
Name: FRONTEND_CALLBACK_URL
Value: http://localhost:3000/auth/callback
Name: FRONTEND_ERROR_URL
Value: http://localhost:3000
Name: PORT
Value: 8080
(Azure App Service expects apps to listen on port 8080)
Name: SCM_DO_BUILD_DURING_DEPLOYMENT
Value: true
(Tells Azure to automatically build your TypeScript code during deployment)
OPTIONAL Variables:
Name: NODE_ENV
Value: production
(Standard practice but not used in your current code)
- Click "Save" at the top
Option A: Direct GitHub Connection
- In your Web App, click "Deployment Center" in left menu
- Source: Select "GitHub"
- Sign in to GitHub if prompted
- Organization: Select your GitHub username
- Repository: Select
Event-Management - Branch:
main - Build Provider: Select "App Service Build Service"
- Application folder:
/backend(important!) - Click "Save"
Azure will automatically deploy your code!
Option B: Local Git (if GitHub doesn't work)
- In Deployment Center, select "Local Git"
- Click "Save"
- Copy the Git URL provided
- In your local terminal:
cd "e:\My work\Calender-Integration\backend"
git remote add azure [PASTE_GIT_URL_HERE]
git push azure main- In your Web App, go to "Development Tools" → "Console"
- Run these commands:
cd /home/site/wwwroot
npm run migrateOr use "SSH" option:
- Click "SSH" in Development Tools
- Click "Go"
- Navigate to app directory:
cd /home/site/wwwroot - Run migration:
npm run migrate
- Go to "Overview" in your Web App
- Click the URL (e.g., https://calendar-integration-backend-eabkffc4gphtenfc.westus-01.azurewebsites.net)
- You should see: "✅ Calendar Integration API is running!"
- Go to: https://console.cloud.google.com
- APIs & Services → Credentials
- Edit your OAuth 2.0 Client ID
- Add to "Authorized redirect URIs":
https://calendar-integration-backend-eabkffc4gphtenfc.westus-01.azurewebsites.net/api/auth/google/callback - Save
When testing OAuth, Google will show: "Google hasn't verified this app"
This is normal! To continue:
- Click "Advanced"
- Click "Go to [Your App] (unsafe)"
- Complete OAuth flow
For production: Add test users in OAuth consent screen or submit for Google verification.
If GitHub deployment doesn't work:
-
Create deployment package:
- Zip your entire
backendfolder - Name it
backend.zip
- Zip your entire
-
In Azure Portal:
- Go to your Web App
- Advanced Tools → Go (opens Kudu)
- Tools → ZIP Push Deploy
- Drag and drop your
backend.zip - Wait for deployment
-
Run commands in Console:
npm install
npm run build
npm run generate
npm run migrateAfter deployment, your backend will be available at:
https://calendar-integration-backend-eabkffc4gphtenfc.westus-01.azurewebsites.net
Test endpoints:
- Health:
https://calendar-integration-backend-eabkffc4gphtenfc.westus-01.azurewebsites.net/ - Auth:
https://calendar-integration-backend-eabkffc4gphtenfc.westus-01.azurewebsites.net/api/auth/google
- ✅ Backend deployed to Azure
- Update your frontend
.env.local:NEXT_PUBLIC_API_URL=https://calendar-integration-backend-eabkffc4gphtenfc.westus-01.azurewebsites.net/api - Deploy frontend (Vercel/Azure Static Web Apps)
- Update environment variables with frontend URL
- Web App → Monitoring → Log stream
- Or Diagnose and solve problems
- App won't start: Check environment variables
- Database connection: Verify DATABASE_URL and firewall
- OAuth issues: Check Google redirect URLs
- Web App → Overview → Restart
- PostgreSQL B1ms: ~$20/month
- App Service B1: ~$13/month
- Total: ~$33/month
Free Options:
- App Service F1: Free (limited)
- Use Azure free credits!
You're all set! 🚀