Overview
This guide covers deploying AndanDo to production environments, including configuration, security hardening, and hosting options.Pre-Deployment Checklist
Security Review
Credentials
- Replace default JWT SecretKey
- Use environment variables for secrets
- Update SMTP credentials
- Switch to PayPal live credentials
Configuration
- Disable
DetailedErrorsin production - Set
ASPNETCORE_ENVIRONMENTtoProduction - Enable HSTS and HTTPS redirection
- Configure proper logging levels
Database Preparation
- Use production SQL Server instance
- Create database backups and recovery plan
- Configure connection pooling
- Set up database monitoring
- Apply proper user permissions (principle of least privilege)
Performance Optimization
- Enable response compression
- Configure CDN for static assets
- Optimize image uploads (compression, resizing)
- Set up application monitoring (Application Insights, etc.)
Production Configuration
appsettings.Production.json
Create a production configuration file:Variable Substitution: Replace
${VARIABLE_NAME} placeholders with actual values at deployment time, or use environment variables and a configuration provider.Environment Variables
Store sensitive configuration in environment variables:- Windows Server
- Linux/Docker
- Azure App Service
Build for Production
Publish the Application
Publish Release Build
- Framework-Dependent
- Self-Contained (Windows)
- Self-Contained (Linux)
Optimize Published Output
Enable ReadyToRun (R2R) Compilation
Enable ReadyToRun (R2R) Compilation
Add to
AndanDo.csproj for faster startup:Compress Static Assets
Compress Static Assets
Enable response compression in
Program.cs:Configure Kestrel for Production
Configure Kestrel for Production
Add Kestrel configuration for production in
appsettings.Production.json:Deployment Options
Option 1: Windows Server with IIS
Install Prerequisites
On Windows Server:
- Install IIS via Server Manager
- Install .NET 10.0 Hosting Bundle from dotnet.microsoft.com
- Restart IIS:
net stop was /y && net start w3svc
Create IIS Site
In IIS Manager:
- Create new Application Pool:
- Name:
AndanDoAppPool - .NET CLR version:
No Managed Code - Managed pipeline mode:
Integrated
- Name:
- Create new Website:
- Site name:
AndanDo - Application pool:
AndanDoAppPool - Physical path:
C:\inetpub\andando - Binding: HTTPS on port 443 with SSL certificate
- Site name:
Configure SSL Certificate
In IIS Manager:
- Select the AndanDo site
- Bindings > Add > HTTPS (port 443)
- Select your SSL certificate (e.g., from Let’s Encrypt or commercial CA)
- Save and restart the site
Option 2: Azure App Service
Create App Service
Via Azure Portal:
- Create new Web App
- Runtime: .NET 10
- Operating System: Windows or Linux
- Region: Choose closest to users
- App Service Plan: At least B1 (Basic) for production
Configure Application Settings
In App Service > Configuration:
- Add all environment variables (SQL_PASSWORD, JWT_SECRET_KEY, etc.)
- Set
ASPNETCORE_ENVIRONMENTtoProduction - Configure connection strings
Deploy Application
- Visual Studio
- Azure CLI
- GitHub Actions
- Right-click project > Publish
- Select Azure > Azure App Service
- Choose your App Service
- Click Publish
Azure SQL Database: Consider using Azure SQL Database for managed database hosting with automatic backups, scaling, and monitoring.
Option 3: Docker Container
Option 4: Linux Server (Systemd)
Configure Nginx Reverse Proxy
Create Enable site and reload Nginx:
/etc/nginx/sites-available/andando:Post-Deployment Tasks
Verify Application Health
- Test homepage loads correctly
- Verify database connectivity
- Test user registration and login
- Create test tour and booking
- Verify email delivery
- Test PayPal payment flow
Configure Monitoring
Application Monitoring
- Set up Application Insights or similar APM
- Configure alerts for errors and performance
- Track custom metrics (bookings, revenue)
Infrastructure Monitoring
- Monitor CPU, memory, disk usage
- Set up database performance monitoring
- Configure uptime monitoring
Set Up Backups
Database Backups:File Backups:
- Backup
wwwroot/uploadsdirectory daily - Store backups in separate location or cloud storage
Security Best Practices
Secure Configuration
Secure Configuration
- ✅ Use strong, unique JWT secret key (64+ characters)
- ✅ Store secrets in environment variables or Azure Key Vault
- ✅ Disable detailed errors in production (
DetailedErrors: false) - ✅ Use HTTPS everywhere with valid SSL certificates
- ✅ Enable HSTS (configured in
Program.cs) - ✅ Set
AllowedHoststo specific domains only
Database Security
Database Security
- ✅ Use least-privilege database accounts
- ✅ Enable SQL Server encryption (TDE)
- ✅ Regular security patches and updates
- ✅ Firewall rules: Allow only app server IPs
- ✅ Enable audit logging for sensitive operations
Application Security
Application Security
- ✅ Keep .NET runtime and packages updated
- ✅ Validate and sanitize all user inputs
- ✅ Use parameterized queries (already using stored procedures)
- ✅ Implement rate limiting for API endpoints
- ✅ Enable anti-forgery tokens (configured via
UseAntiforgery())
File Upload Security
File Upload Security
- ✅ Validate file types and sizes
- ✅ Scan uploads for malware
- ✅ Store uploads outside webroot or use CDN
- ✅ Use unique filenames to prevent overwriting
- ✅ Set proper file permissions (read-only for web server)
Performance Tuning
Blazor Server
- Configure SignalR message size limits
- Enable circuit activity tracking
- Set appropriate reconnection settings
- Optimize component rendering
Database
- Index frequently queried columns
- Optimize stored procedures
- Enable query execution plans
- Configure connection pooling
Caching
- Implement response caching for static content
- Use distributed cache for session data
- Cache database query results where appropriate
- Configure CDN for static assets
Resource Limits
- Set Kestrel connection limits
- Configure max request body size
- Set timeout values appropriately
- Monitor and adjust based on load
Troubleshooting Production Issues
Application Won't Start
Application Won't Start
Check:
- Environment variable
ASPNETCORE_ENVIRONMENTis set toProduction - All required dependencies are in publish folder
- .NET runtime is installed (for framework-dependent deployments)
- Ports 80/443 are not blocked by firewall
- Check application logs in Event Viewer (Windows) or journalctl (Linux)
Database Connection Failures
Database Connection Failures
Check:
- Connection string is correct in production config
- SQL Server is running and accessible
- Firewall allows traffic on SQL Server port (1433)
- Database user has proper permissions
- Test connection with
sqlcmdor SQL Server Management Studio
SignalR/WebSocket Issues
SignalR/WebSocket Issues
Check:
- WebSocket support is enabled in IIS/web server
- Load balancer supports WebSocket sticky sessions
- Firewall allows WebSocket connections
- Browser console for connection errors
- SignalR fallback to long polling if WebSocket fails
File Upload Failures
File Upload Failures
Check:
wwwroot/uploadsdirectory exists- Application has write permissions to uploads folder
- Disk space is available
- Max request body size is sufficient
- Request timeout is not too short for large files
Scaling Considerations
Blazor Server maintains persistent connections, requiring careful scaling strategies.
Vertical Scaling
- Increase server CPU and RAM
- Upgrade to higher-tier App Service plan
- Use faster SSD storage
Horizontal Scaling (Multiple Instances)
Requirements:- Sticky Sessions: Configure load balancer for session affinity (ARR Affinity in Azure)
- Shared Storage: Use Azure Blob Storage or network share for
wwwroot/uploads - Distributed Cache: Implement Redis for shared session state
- Database Scaling: Use read replicas or Azure SQL elastic pools
Maintenance and Updates
Regular Updates
- Apply .NET security patches monthly
- Update NuGet packages regularly
- Review dependency vulnerabilities
- Test updates in staging before production
Database Maintenance
- Weekly index maintenance
- Regular statistics updates
- Periodic backup testing
- Monitor database size and growth
Rollback Plan
- Keep Previous Version: Maintain previous deployment in separate directory
- Database Backups: Always backup database before schema changes
- Quick Rollback: Swap deployment folders or restore previous Docker image
- Test Rollback: Periodically test rollback procedures
Need Help?
If you encounter issues during deployment, check the application logs, verify configuration settings, and ensure all prerequisites are met. For development setup questions, refer back to Development Setup.