Deployment Overview
This guide covers deploying the DonaSF API built with ASP.NET Core .NET 10.0 to production environments including Windows Server, Linux servers, and cloud platforms.Pre-Deployment Checklist
Before deploying to production, ensure you have:Database server configured and accessible
SQL scripts executed and database initialized
Production
Conf.txt with secure credentialsStrong JWT key configured (min 32 characters)
Email addresses configured
SSL/TLS certificate ready (for HTTPS)
Firewall rules configured
Backup strategy in place
Build for Production
Clean and Build
Publishing the Application
Self-Contained Deployment
Create a self-contained deployment that includes the .NET runtime:Framework-Dependent Deployment
Smaller deployment that requires .NET 10.0 runtime on the server:Framework-dependent deployments are smaller but require .NET 10.0 runtime installed on the target server
Single File Deployment
Bundle everything into a single executable:Configuration for Production
Create Production Configuration
Createappsettings.Production.json in the publish directory:
appsettings.Production.json
Create Production Conf.txt
Create a secureConf.txt file with production database credentials:
Conf.txt
Environment Variables
Override configuration using environment variables:Deployment Scenarios
Windows Server with IIS
Install Prerequisites
Install required components on Windows Server:
- .NET 10.0 Hosting Bundle (for framework-dependent deployment)
- IIS with ASP.NET Core Module
- URL Rewrite Module (optional)
Create IIS Application
- Open IIS Manager
- Create a new Application Pool:
- Name:
DonaSF-API - .NET CLR Version:
No Managed Code - Managed Pipeline Mode:
Integrated
- Name:
- Create a new Website or Application:
- Physical path:
C:\inetpub\DonaSF-API - Application Pool:
DonaSF-API - Binding: HTTP port 80 or HTTPS port 443
- Physical path:
Deploy Files
Copy published files to IIS directory:Ensure
Conf.txt and appsettings.Production.json are in the root directory.Linux Server with systemd
Install .NET Runtime
Install .NET 10.0 runtime (for framework-dependent) or skip for self-contained:
Create systemd Service
Create Enable and start the service:
/etc/systemd/system/donasf-api.service:donasf-api.service
Docker Container
Database Deployment
SQL Server Deployment Considerations
Database Creation
Database Creation
Execute the database scripts on your production SQL Server:
Connection Security
Connection Security
Best Practices:
- Use SQL Server authentication with strong passwords
- Create dedicated database user with minimal permissions
- Enable encrypted connections (TLS 1.2+)
- Restrict network access with firewall rules
- Regular security audits and updates
Backup Strategy
Backup Strategy
Implement regular database backups:Set up automated backup schedules using SQL Server Agent or Azure Backup.
Performance Tuning
Performance Tuning
Index Optimization:
- Review and create indexes for frequently queried columns
- Monitor index fragmentation and rebuild regularly
- Use execution plans to identify slow queries
Microsoft.Data.SqlClient which automatically enables connection pooling.Monitoring:SSL/TLS Configuration
Enable HTTPS in Production
ModifyProgram.cs to enable HTTPS redirection:
Configure Kestrel for HTTPS
Add toappsettings.Production.json:
Monitoring and Logging
Application Logging
Configure file logging for production:- Add Serilog package:
- Configure in
Program.cs:
Health Checks
Monitor application health:Performance Monitoring
- Use Application Insights for Azure deployments
- Monitor CPU, memory, and disk usage
- Track API response times
- Monitor database connection pool
- Set up alerts for errors and slow responses
Deployment Verification
Test Database Connection
Verify database connectivity by calling an endpoint that queries the database.
Troubleshooting
Application Won't Start
Application Won't Start
Check:
- Conf.txt exists and has correct format
- Database server is accessible
- .NET runtime is installed (for framework-dependent)
- Port is not already in use
- Sufficient permissions on application directory
Database Connection Fails
Database Connection Fails
Verify:
- SQL Server is running and accessible
- Firewall allows connection on port 1433
- Credentials in Conf.txt are correct
- TrustServerCertificate setting is configured
JWT Authentication Errors
JWT Authentication Errors
Common issues:
- JWT Key is less than 32 characters
- Token has expired (check Expires setting)
- Clock skew between client and server
Performance Issues
Performance Issues
Check:
- Database query performance
- Connection pool exhaustion
- Memory leaks
- Disk I/O bottlenecks
Security Hardening
Remove Development Features
- Disable Swagger UI in production
- Remove development exception pages
- Disable detailed error messages
- Remove test accounts
Secure Configuration
- Use environment variables for secrets
- Rotate JWT keys regularly
- Implement rate limiting
- Enable CORS restrictions
Network Security
- Use HTTPS only
- Configure firewall rules
- Restrict database access
- Use VPN for administrative access
Monitoring & Auditing
- Enable security logs
- Monitor failed login attempts
- Track API usage patterns
- Set up security alerts
Next Steps
Setup Guide
Return to development setup
Configuration
Review configuration options
API Reference
Explore API endpoints
Architecture
Learn about the system architecture