Deployment Guide
Complete deployment instructions for Windows, Linux, Docker & Cloud
Prerequisites
System Requirements
| Component | Minimum | Recommended |
|---|---|---|
| Operating System | Windows Server 2019+ / Ubuntu 20.04+ | Windows Server 2022 / Ubuntu 22.04 |
| CPU | 2 cores | 4+ cores |
| RAM | 4GB | 8GB+ |
| Storage | 20GB | 50GB+ SSD |
| .NET Runtime | .NET 9.0 | .NET 9.0 (latest) |
| Database | SQL Server 2019 / PostgreSQL 13 | SQL Server 2022 / PostgreSQL 15 |
Software Requirements
- .NET 9.0 SDK (for development) or Runtime (for production)
- SQL Server 2019+, PostgreSQL 13+, or MySQL 8.0+
- Redis 6.0+ (for distributed caching)
- Git (for source control)
- Docker Desktop (for containerized deployment - optional)
Development Setup
Step 1: Clone Repository
# Clone the repository
git clone https://github.com/shirinzad/backend.git
cd backend
# Or if already cloned
cd C:\Users\Mohammad\Desktop\project\Shirinzad\BackEnd
Step 2: Restore Dependencies
# Restore NuGet packages
dotnet restore
# Build solution
dotnet build
Step 3: Configure Database Connection
Edit src/Shirinzad.Shop.DbMigrator/appsettings.json:
{
"ConnectionStrings": {
"Default": "Server=localhost;Database=ShirinzadShop;User Id=sa;Password=YourPassword123!;TrustServerCertificate=True"
},
"Redis": {
"Configuration": "localhost:6379",
"InstanceName": "Shirinzad:"
}
}
Step 4: Run Database Migrations
# Navigate to DbMigrator project
cd src/Shirinzad.Shop.DbMigrator
# Run migrations
dotnet run
# Output will show:
# - Creating database (if not exists)
# - Running 18 migrations
# - Seeding initial data
# - Creating admin user
# - Seeding sample products, categories, etc.
Database Migrations: The DbMigrator creates the complete database schema with 18 migrations, covering all 23 modules and 55+ entities.
Step 5: Run Application
# Navigate to Web project
cd ../Shirinzad.Shop.Web
# Run application
dotnet run
# Application will start on:
# - HTTPS: https://localhost:5001
# - HTTP: http://localhost:5000
Access Points:
- Web UI: https://localhost:5001
- Swagger API: https://localhost:5001/swagger
- Health Check: https://localhost:5001/health
Default Credentials:
Username: admin
Password: 1q2w3E*
Security Warning: Change the default admin password immediately after first login in production!
Windows Server (IIS) Deployment
Step 1: Install Prerequisites
# PowerShell - Run as Administrator
# Install IIS with required features
Install-WindowsFeature -name Web-Server -IncludeManagementTools
Install-WindowsFeature -name Web-Asp-Net45
Install-WindowsFeature -name Web-WebSockets
# Download and install .NET 9.0 Hosting Bundle
# URL: https://dotnet.microsoft.com/download/dotnet/9.0
# Download: dotnet-hosting-9.0.x-win.exe
# Install the downloaded file
# Restart IIS after installation
iisreset
Step 2: Build and Publish Application
# Navigate to solution directory
cd C:\Users\Mohammad\Desktop\project\Shirinzad\BackEnd
# Publish for production
dotnet publish src/Shirinzad.Shop.Web/Shirinzad.Shop.Web.csproj `
-c Release `
-o C:\inetpub\shirinzad `
--self-contained false
# Files will be published to C:\inetpub\shirinzad\
Step 3: Configure IIS Application Pool
- Open IIS Manager
- Navigate to Application Pools
- Click Add Application Pool
- Configure:
- Name:
ShirinzadAppPool - .NET CLR Version:
No Managed Code - Managed Pipeline Mode:
Integrated - Start Application Pool immediately:
Yes
- Name:
- Click Advanced Settings:
- Identity:
ApplicationPoolIdentity - Idle Timeout:
20 minutes - Regular Time Interval:
1740 minutes
- Identity:
Step 4: Create IIS Website
- In IIS Manager, right-click Sites > Add Website
- Configure:
- Site Name:
Shirinzad - Application Pool:
ShirinzadAppPool - Physical Path:
C:\inetpub\shirinzad - Binding Type:
https - IP Address:
All Unassigned - Port:
443 - Host Name:
shop.shirinzad.ir(or your domain) - SSL Certificate: Select your certificate
- Site Name:
- Also add HTTP binding on port 80 (for redirect)
SSL Certificate: You can obtain a free SSL certificate from Let's Encrypt or purchase one from a certificate authority.
Step 5: Configure Production Settings
Edit C:\inetpub\shirinzad\appsettings.Production.json:
{
"ConnectionStrings": {
"Default": "Server=your-sql-server;Database=ShirinzadShop;User Id=shirinzad_user;Password=SecurePassword123!;TrustServerCertificate=True;MultipleActiveResultSets=True"
},
"Redis": {
"Configuration": "your-redis-server:6379",
"InstanceName": "Shirinzad:"
},
"App": {
"SelfUrl": "https://shop.shirinzad.ir",
"CorsOrigins": "https://shop.shirinzad.ir,https://admin.shirinzad.ir"
},
"Serilog": {
"MinimumLevel": {
"Default": "Information"
}
}
}
Step 6: Set Folder Permissions
# PowerShell
# Grant IIS_IUSRS read/execute permissions
icacls "C:\inetpub\shirinzad" /grant "IIS_IUSRS:(OI)(CI)(RX)"
# Grant write permissions for uploads folder
icacls "C:\inetpub\shirinzad\wwwroot\uploads" /grant "IIS_IUSRS:(OI)(CI)(M)"
Step 7: Configure web.config (Auto-generated)
The publish process creates a web.config file. Verify it contains:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet"
arguments=".\Shirinzad.Shop.Web.dll"
stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Step 8: Start Website & Test
- In IIS Manager, select the Shirinzad site
- Click Start in the Actions pane
- Browse to
https://shop.shirinzad.ir - Check
C:\inetpub\shirinzad\logs\for any errors
Troubleshooting:
# View application logs
Get-Content "C:\inetpub\shirinzad\logs\stdout_*.log" -Tail 50
# Restart IIS
iisreset
# Restart application pool
Restart-WebAppPool -Name "ShirinzadAppPool"
Linux Server (Ubuntu) Deployment
Step 1: Install Prerequisites
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install .NET 9.0 Runtime
wget https://dot.net/v1/dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh --channel 9.0 --runtime aspnetcore
./dotnet-install.sh --channel 9.0 --runtime dotnet
# Add .NET to PATH
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc
echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.bashrc
source ~/.bashrc
# Verify installation
dotnet --version
# Install Nginx
sudo apt install nginx -y
# Install PostgreSQL (or use SQL Server)
sudo apt install postgresql postgresql-contrib -y
Step 2: Create Database
# Switch to postgres user
sudo -u postgres psql
# In PostgreSQL shell
CREATE DATABASE shirinzad_shop;
CREATE USER shirinzad_user WITH ENCRYPTED PASSWORD 'SecurePassword123!';
GRANT ALL PRIVILEGES ON DATABASE shirinzad_shop TO shirinzad_user;
\q
# For SQL Server on Linux (alternative)
# Follow Microsoft documentation to install SQL Server on Ubuntu
Step 3: Deploy Application
# Create deployment directory
sudo mkdir -p /var/www/shirinzad
sudo chown -R $USER:$USER /var/www/shirinzad
# Build and publish application (on development machine or CI/CD)
dotnet publish src/Shirinzad.Shop.Web/Shirinzad.Shop.Web.csproj \
-c Release \
-o /var/www/shirinzad \
--self-contained false
# Or copy published files from Windows
scp -r C:\inetpub\shirinzad/* user@server:/var/www/shirinzad/
# Set permissions
sudo chown -R www-data:www-data /var/www/shirinzad
sudo chmod -R 755 /var/www/shirinzad
sudo chmod -R 777 /var/www/shirinzad/wwwroot/uploads
Step 4: Configure Production Settings
# Edit appsettings.Production.json
sudo nano /var/www/shirinzad/appsettings.Production.json
# Content:
{
"ConnectionStrings": {
"Default": "Host=localhost;Port=5432;Database=shirinzad_shop;Username=shirinzad_user;Password=SecurePassword123!;Pooling=true"
},
"Redis": {
"Configuration": "localhost:6379",
"InstanceName": "Shirinzad:"
},
"App": {
"SelfUrl": "https://shop.shirinzad.ir"
}
}
Step 5: Create Systemd Service
# Create service file
sudo nano /etc/systemd/system/shirinzad.service
# Content:
[Unit]
Description=Shirinzad E-Commerce Platform
After=network.target
[Service]
Type=notify
WorkingDirectory=/var/www/shirinzad
ExecStart=/home/user/.dotnet/dotnet /var/www/shirinzad/Shirinzad.Shop.Web.dll
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=shirinzad
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
Environment=ASPNETCORE_URLS=http://localhost:5000
[Install]
WantedBy=multi-user.target
Step 6: Enable and Start Service
# Reload systemd
sudo systemctl daemon-reload
# Enable service to start on boot
sudo systemctl enable shirinzad
# Start service
sudo systemctl start shirinzad
# Check status
sudo systemctl status shirinzad
# View logs
sudo journalctl -u shirinzad -n 50 -f
Step 7: Configure Nginx Reverse Proxy
# Create Nginx configuration
sudo nano /etc/nginx/sites-available/shirinzad
# Content:
server {
listen 80;
server_name shop.shirinzad.ir;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name shop.shirinzad.ir;
ssl_certificate /etc/ssl/certs/shirinzad.crt;
ssl_certificate_key /etc/ssl/private/shirinzad.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header X-XSS-Protection "1; mode=block" always;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
client_max_body_size 20M;
}
location /uploads {
alias /var/www/shirinzad/wwwroot/uploads;
expires 1y;
add_header Cache-Control "public, immutable";
}
location /health {
proxy_pass http://localhost:5000/health;
access_log off;
}
}
# Enable site
sudo ln -s /etc/nginx/sites-available/shirinzad /etc/nginx/sites-enabled/
# Test configuration
sudo nginx -t
# Restart Nginx
sudo systemctl restart nginx
Step 8: SSL Certificate Setup (Let's Encrypt)
# Install Certbot
sudo apt install certbot python3-certbot-nginx -y
# Obtain certificate
sudo certbot --nginx -d shop.shirinzad.ir
# Certbot will automatically:
# - Obtain SSL certificate
# - Update Nginx configuration
# - Set up auto-renewal
# Test auto-renewal
sudo certbot renew --dry-run
# Auto-renewal is configured via cron
# Certificate renews automatically before expiration
Docker Deployment
Dockerfile
Create Dockerfile in project root:
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
# Copy project files
COPY ["src/Shirinzad.Shop.Web/Shirinzad.Shop.Web.csproj", "src/Shirinzad.Shop.Web/"]
COPY ["src/Shirinzad.Shop.Application/Shirinzad.Shop.Application.csproj", "src/Shirinzad.Shop.Application/"]
COPY ["src/Shirinzad.Shop.Application.Contracts/Shirinzad.Shop.Application.Contracts.csproj", "src/Shirinzad.Shop.Application.Contracts/"]
COPY ["src/Shirinzad.Shop.Domain/Shirinzad.Shop.Domain.csproj", "src/Shirinzad.Shop.Domain/"]
COPY ["src/Shirinzad.Shop.Domain.Shared/Shirinzad.Shop.Domain.Shared.csproj", "src/Shirinzad.Shop.Domain.Shared/"]
COPY ["src/Shirinzad.Shop.EntityFrameworkCore/Shirinzad.Shop.EntityFrameworkCore.csproj", "src/Shirinzad.Shop.EntityFrameworkCore/"]
COPY ["src/Shirinzad.Shop.HttpApi/Shirinzad.Shop.HttpApi.csproj", "src/Shirinzad.Shop.HttpApi/"]
COPY ["src/Shirinzad.Shop.HttpApi.Client/Shirinzad.Shop.HttpApi.Client.csproj", "src/Shirinzad.Shop.HttpApi.Client/"]
# Restore dependencies
RUN dotnet restore "src/Shirinzad.Shop.Web/Shirinzad.Shop.Web.csproj"
# Copy source code
COPY . .
# Build
WORKDIR "/src/src/Shirinzad.Shop.Web"
RUN dotnet build "Shirinzad.Shop.Web.csproj" -c Release -o /app/build
# Publish
FROM build AS publish
RUN dotnet publish "Shirinzad.Shop.Web.csproj" -c Release -o /app/publish
# Final stage
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# Create uploads directory
RUN mkdir -p /app/wwwroot/uploads && chmod 777 /app/wwwroot/uploads
ENTRYPOINT ["dotnet", "Shirinzad.Shop.Web.dll"]
Docker Compose Configuration
Create docker-compose.yml:
version: '3.8'
services:
db:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: shirinzad-db
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=YourStrong!Password123
- MSSQL_PID=Express
ports:
- "1433:1433"
volumes:
- shirinzad-db-data:/var/opt/mssql
networks:
- shirinzad-network
healthcheck:
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P YourStrong!Password123 -Q "SELECT 1"
interval: 10s
timeout: 3s
retries: 5
redis:
image: redis:7-alpine
container_name: shirinzad-redis
ports:
- "6379:6379"
volumes:
- shirinzad-redis-data:/data
networks:
- shirinzad-network
command: redis-server --appendonly yes
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
web:
build:
context: .
dockerfile: Dockerfile
container_name: shirinzad-web
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=https://+:443;http://+:80
- ASPNETCORE_Kestrel__Certificates__Default__Password=YourCertPassword
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/certificate.pfx
- ConnectionStrings__Default=Server=db;Database=ShirinzadShop;User Id=sa;Password=YourStrong!Password123;TrustServerCertificate=True
- Redis__Configuration=redis:6379
- Redis__InstanceName=Shirinzad:
ports:
- "80:80"
- "443:443"
volumes:
- ./certs:/https:ro
- ./wwwroot/uploads:/app/wwwroot/uploads
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
networks:
- shirinzad-network
restart: unless-stopped
volumes:
shirinzad-db-data:
shirinzad-redis-data:
networks:
shirinzad-network:
driver: bridge
Docker Commands
# Build and start containers
docker-compose up -d
# View logs
docker-compose logs -f web
# View all container logs
docker-compose logs -f
# Stop containers
docker-compose stop
# Start containers
docker-compose start
# Restart containers
docker-compose restart
# Stop and remove containers
docker-compose down
# Stop and remove containers with volumes
docker-compose down -v
# Rebuild and restart
docker-compose up -d --build
# Execute command in container
docker exec -it shirinzad-web bash
# Run migrations (first time only)
docker exec shirinzad-web dotnet Shirinzad.Shop.DbMigrator.dll
Production Docker Deployment
- Generate SSL certificate and place in
./certs/folder - Update environment variables in
docker-compose.yml - Build and start:
docker-compose up -d - Run migrations:
docker exec shirinzad-web dotnet Shirinzad.Shop.DbMigrator.dll - Access application at
https://localhost
Cloud Deployment
Azure App Service
Prerequisites:
- Azure subscription
- Azure CLI installed
Deployment Steps:
# Login to Azure
az login
# Create resource group
az group create --name shirinzad-rg --location eastus
# Create App Service plan
az appservice plan create \
--name shirinzad-plan \
--resource-group shirinzad-rg \
--sku B2 \
--is-linux
# Create web app
az webapp create \
--name shirinzad-shop \
--resource-group shirinzad-rg \
--plan shirinzad-plan \
--runtime "DOTNET|9.0"
# Configure connection string
az webapp config connection-string set \
--name shirinzad-shop \
--resource-group shirinzad-rg \
--connection-string-type SQLAzure \
--settings Default="Server=..."
# Deploy application
dotnet publish -c Release
cd src/Shirinzad.Shop.Web/bin/Release/net9.0/publish
zip -r ../publish.zip .
az webapp deployment source config-zip \
--name shirinzad-shop \
--resource-group shirinzad-rg \
--src ../publish.zip
Azure Services Setup:
- Azure SQL Database: For database
- Azure Cache for Redis: For caching
- Azure Blob Storage: For file uploads
- Azure Application Insights: For monitoring
AWS Elastic Beanstalk
Prerequisites:
- AWS account
- AWS CLI and EB CLI installed
Deployment Steps:
# Initialize Elastic Beanstalk
eb init -p "64bit Amazon Linux 2 v2.6.5 running .NET Core" \
--region us-east-1 shirinzad-shop
# Create environment
eb create shirinzad-production \
--instance-type t3.medium \
--database.engine postgres \
--database.username shirinzad \
--envvars ASPNETCORE_ENVIRONMENT=Production
# Deploy application
dotnet publish -c Release -o ./publish
cd publish
zip -r ../deploy.zip .
eb deploy
# Set environment variables
eb setenv \
ConnectionStrings__Default="Host=..." \
Redis__Configuration="..."
AWS Services Setup:
- RDS PostgreSQL: For database
- ElastiCache Redis: For caching
- S3: For file storage
- CloudWatch: For logging/monitoring
Environment Variables Configuration
Required Environment Variables
| Variable | Description | Example |
|---|---|---|
| ASPNETCORE_ENVIRONMENT | Environment name | Production |
| ConnectionStrings__Default | Database connection string | Server=...;Database=...;User Id=... |
| Redis__Configuration | Redis connection string | localhost:6379 |
| Redis__InstanceName | Redis key prefix | Shirinzad: |
| App__SelfUrl | Application URL | https://shop.shirinzad.ir |
| App__CorsOrigins | Allowed CORS origins | https://shop.shirinzad.ir |
Health Checks & Monitoring
Built-in Health Checks
The application includes comprehensive health checks for monitoring.
Health Check Endpoints:
# Overall health status
GET /health
# Response:
{
"status": "Healthy",
"totalDuration": "00:00:00.0123456",
"entries": {
"Database": {
"status": "Healthy",
"duration": "00:00:00.0100000"
},
"Redis": {
"status": "Healthy",
"duration": "00:00:00.0020000"
}
}
}
Integration with Monitoring Tools:
- Azure Application Insights: Real-time monitoring and analytics
- Seq: Structured logging and search
- Prometheus + Grafana: Metrics and dashboards
- ELK Stack: Log aggregation and analysis
Backup & Disaster Recovery
Database Backup
SQL Server Backup:
# Full backup
BACKUP DATABASE ShirinzadShop
TO DISK = 'C:\Backup\shirinzad_full_20250107.bak'
WITH FORMAT, COMPRESSION;
# Differential backup
BACKUP DATABASE ShirinzadShop
TO DISK = 'C:\Backup\shirinzad_diff_20250107.bak'
WITH DIFFERENTIAL, COMPRESSION;
# PowerShell automation script
$date = Get-Date -Format "yyyyMMdd_HHmmss"
$backupFile = "C:\Backup\shirinzad_$date.bak"
Invoke-Sqlcmd -Query "BACKUP DATABASE ShirinzadShop TO DISK = '$backupFile' WITH COMPRESSION"
PostgreSQL Backup:
# Full backup
pg_dump -U shirinzad_user -h localhost shirinzad_shop > backup_$(date +%Y%m%d).sql
# Compressed backup
pg_dump -U shirinzad_user -h localhost shirinzad_shop | gzip > backup_$(date +%Y%m%d).sql.gz
# Restore from backup
psql -U shirinzad_user -h localhost shirinzad_shop < backup_20250107.sql
File Storage Backup
# Windows - PowerShell
$date = Get-Date -Format "yyyyMMdd"
Compress-Archive -Path "C:\inetpub\shirinzad\wwwroot\uploads" -DestinationPath "C:\Backup\uploads_$date.zip"
# Linux - Bash
tar -czf /backup/uploads_$(date +%Y%m%d).tar.gz /var/www/shirinzad/wwwroot/uploads
Automated Backup Script (Linux)
#!/bin/bash
# /usr/local/bin/backup-shirinzad.sh
BACKUP_DIR="/backup/shirinzad"
DATE=$(date +%Y%m%d_%H%M%S)
# Create backup directory
mkdir -p $BACKUP_DIR
# Backup database
pg_dump -U shirinzad_user shirinzad_shop | gzip > $BACKUP_DIR/db_$DATE.sql.gz
# Backup files
tar -czf $BACKUP_DIR/files_$DATE.tar.gz /var/www/shirinzad/wwwroot/uploads
# Keep only last 30 days of backups
find $BACKUP_DIR -type f -mtime +30 -delete
echo "Backup completed: $DATE"
Schedule with Cron:
# Edit crontab
crontab -e
# Add daily backup at 2 AM
0 2 * * * /usr/local/bin/backup-shirinzad.sh >> /var/log/backup-shirinzad.log 2>&1
Disaster Recovery Plan
- Regular Backups: Daily database backups, weekly full backups
- Backup Storage: Store backups in separate location (cloud storage)
- Backup Testing: Monthly restore tests to verify backup integrity
- RTO (Recovery Time Objective): 4 hours
- RPO (Recovery Point Objective): 24 hours
- Documentation: Maintain recovery procedures documentation
Troubleshooting
Application Won't Start
Check Logs:
# Windows
Get-Content "C:\inetpub\shirinzad\logs\stdout_*.log" -Tail 50
# Linux
sudo journalctl -u shirinzad -n 50 -f
Common Issues:
- Missing .NET Runtime: Install .NET 9.0 Runtime
- Port Conflict: Check if port 5000/5001 is in use
- Permission Issues: Grant read/write permissions
- Database Connection: Verify connection string
Database Connection Issues
# Test connection
dotnet ef database update --verbose
# Check connection string
# Windows
notepad appsettings.Production.json
# Linux
cat /var/www/shirinzad/appsettings.Production.json
Common Issues:
- Wrong Credentials: Verify username/password
- Firewall Blocking: Open database port
- SQL Server Not Running: Start SQL Server service
- Network Issues: Check connectivity
High Memory Usage
# Monitor resources
# Windows
Get-Process | Where-Object {$_.ProcessName -like "*dotnet*"}
# Linux
htop
ps aux | grep dotnet
Solutions:
- Enable response compression
- Configure Redis caching
- Optimize database queries
- Increase server memory
- Implement pagination
Slow Performance
Diagnostic Steps:
- Check database indexes
- Review slow query logs
- Monitor Redis cache hit rate
- Check network latency
- Review application logs for errors
Optimizations:
- Enable Redis distributed caching
- Add database indexes
- Use CDN for static files
- Enable response compression
- Optimize images (WebP format)
Production Deployment Checklist
Pre-Deployment
- Build application in Release mode
- Run all unit and integration tests
- Update database schema (migrations)
- Configure production connection strings
- Set up Redis cache
- Obtain SSL certificate
- Configure CORS origins
- Set up error logging (Serilog/Seq)
Security
- Change default admin password
- Enable HTTPS/TLS
- Configure rate limiting
- Set up firewall rules
- Disable debug mode
- Remove development certificates
- Configure security headers
- Enable audit logging
Performance
- Enable response compression
- Configure Redis caching
- Set up CDN for static files
- Optimize database indexes
- Configure connection pooling
- Enable HTTP/2
Monitoring
- Set up health checks
- Configure application monitoring
- Set up log aggregation
- Configure alerts for errors
- Set up uptime monitoring
Backup
- Configure automated database backups
- Set up file storage backups
- Test restore procedures
- Document recovery process
Post-Deployment
- Verify application is running
- Test critical user journeys
- Check health endpoint
- Verify database connectivity
- Test Redis caching
- Monitor error logs
- Verify SSL certificate
- Test API endpoints
Support & Maintenance
Update Application
# Windows (IIS)
# 1. Build new version
dotnet publish -c Release -o C:\inetpub\shirinzad-new
# 2. Stop IIS site
Stop-WebSite -Name "Shirinzad"
# 3. Backup current version
Rename-Item C:\inetpub\shirinzad C:\inetpub\shirinzad-backup-$(Get-Date -Format "yyyyMMdd")
# 4. Deploy new version
Rename-Item C:\inetpub\shirinzad-new C:\inetpub\shirinzad
# 5. Start IIS site
Start-WebSite -Name "Shirinzad"
# Linux (systemd)
# 1. Stop service
sudo systemctl stop shirinzad
# 2. Backup and deploy
sudo mv /var/www/shirinzad /var/www/shirinzad-backup-$(date +%Y%m%d)
sudo cp -r /path/to/new/publish /var/www/shirinzad
# 3. Start service
sudo systemctl start shirinzad
View Logs
# Windows
Get-Content "C:\inetpub\shirinzad\logs\*.log" -Tail 100 -Wait
# Linux
sudo journalctl -u shirinzad -f
# Nginx logs
sudo tail -f /var/log/nginx/error.log
sudo tail -f /var/log/nginx/access.log
Contact
For deployment support and questions:
- Email: [email protected]
- Documentation: https://docs.shirinzad.ir