Architecture Overview
Component Diagram
graph TB
Users([Users]) -->|HTTPS 443| AppService
subgraph Azure Subscription
subgraph Resource Group
subgraph VNet["Virtual Network (10.101.0.0/24)"]
subgraph AppSnet["app-service-snet (10.101.0.0/26)"]
ASP["App Service Plan (B1 Basic)<br/>1 core, 1.75 GB RAM"]
AppService["App Service (Web App)<br/>Container: vaultwarden<br/>Port: 80<br/>Managed Identity<br/>VNet Integration"]
end
subgraph PgSnet["postgresql-snet (10.101.0.64/26)<br/>Delegated to PostgreSQL Flexible Server"]
PostgreSQL["Azure Database for PostgreSQL<br/>Flexible Server<br/>Burstable B1MS (1 vCore, 2 GB)<br/>SSL enforced<br/>VNet integrated (private access)<br/>35-day GRS automated backups<br/>Optional CanNotDelete lock"]
end
subgraph PESnet["private-endpoints-snet (10.101.0.128/26)<br/>privateEndpointNetworkPolicies: Disabled"]
KVPE[Key Vault Private Endpoint]
StoragePE[Storage Account Private Endpoint]
end
end
PrivateDNS["Private DNS Zones (linked to VNet)<br/>privatelink.postgres.database.azure.com<br/>privatelink.vaultcore.azure.net<br/>privatelink.file.‹storage-suffix›"]
KeyVault["Azure Key Vault<br/>Admin token + Database URL secrets<br/>publicNetworkAccess: Disabled<br/>RBAC enabled<br/>System-assigned identity access"]
StorageAccount["Azure Storage Account<br/>Azure Files share mounted at /data<br/>publicNetworkAccess: Disabled<br/>Geo-redundant storage (GRS)"]
LogAnalytics["Log Analytics Workspace<br/>App Service logs<br/>Metrics & Performance data"]
end
end
AppService -->|DB connection| PostgreSQL
AppService -->|Managed Identity – retrieves DATABASE_URL| KVPE
KVPE --> KeyVault
AppService --> StoragePE
StoragePE --> StorageAccount
AppService -->|Logs & Metrics| LogAnalytics
PrivateDNS -.->|Resolves private IPs| PostgreSQL
PrivateDNS -.->|Resolves private IPs| KeyVault
PrivateDNS -.->|Resolves private IPs| StorageAccount
Resource Flow
- User Access: Users access Vaultwarden via HTTPS through the App Service’s public endpoint
- App Service: Runs the Vaultwarden container with automatic HTTPS termination
- Secrets Management: App Service uses its system-assigned managed identity to retrieve admin token and database URL from Key Vault
- Data Storage: App Service connects to Azure Database for PostgreSQL Flexible Server via VNet integration → delegated PostgreSQL subnet
- DNS Resolution: Private DNS Zone (
privatelink.postgres.database.azure.com) resolves PostgreSQL server to its private IP within the VNet - Backup Protection: PostgreSQL Flexible Server built-in backup with 35-day retention and geo-redundant replication to the Azure paired region; point-in-time restore
- Monitoring: All logs and metrics are sent to Log Analytics Workspace
- Networking: App Service is integrated with Virtual Network; PostgreSQL Flexible Server is accessible only via VNet integration (no public access)
Security Features
Network Security
- Virtual Network isolation with VNet integration
- App Service subnet (
app-service-snet) with service delegation (10.101.0.0/26) - PostgreSQL subnet (
postgresql-snet) with service delegation for Flexible Server (10.101.0.64/26) - Private endpoints subnet (
private-endpoints-snet, 10.101.0.128/26) hosting the Key Vault and Storage Account file private endpoints, withprivateEndpointNetworkPolicies: 'Disabled' - PostgreSQL Flexible Server accessible only via VNet integration (no public access)
- Key Vault and Storage Account have
publicNetworkAccess: 'Disabled'and are reached over the VNet through private endpoints - Private DNS Zones linked to the VNet resolve each service (
privatelink.postgres.database.azure.com,privatelink.vaultcore.azure.net,privatelink.file.<storage-suffix>) to its private IP - HTTPS-only access with Azure-managed certificates
- App Service inbound private endpoints (for private access to the web app) require Premium tiers; connecting to PostgreSQL Flexible Server via VNet integration is supported from Basic (B1) and above
Data Security
- Azure Database for PostgreSQL Flexible Server with:
- SSL/TLS enforced for all connections
- VNet integration (private access only, no public endpoint)
- Encrypted data at rest (Azure-managed encryption)
- Encrypted data in transit (TLS 1.2+)
- Optional CanNotDelete resource lock to prevent accidental deletion (requires
Microsoft.Authorization/locks/writepermission)
- Built-in automated backups with 35-day retention and geo-redundant replication to the Azure paired region
- Point-in-time restore capability
Application Security
- Admin panel disabled by default
- User signups disabled by default
- Secrets stored in Azure Key Vault (not in configuration)
- App Service uses managed identity for Key Vault access
- System-assigned managed identity for Azure resource access
- RBAC-based access control for Key Vault
Scaling and High Availability
Scaling Configuration
- App Service Plan: B1 (1 core, 1.75 GB RAM) - Default for cost-effectiveness with VNet integration support
- Manual Scaling: Scale up to higher SKUs (B2, B3, S1, S2, S3, P1v3, P2v3, P3v3) for more resources
- Auto-scaling: Available on Standard (S1+) and Premium tiers - configure based on CPU, memory, or HTTP queue metrics
- Scale Out: B1 supports up to 3 instances; Standard tier supports up to 10 instances
High Availability
- Deployment slots for zero-downtime deployments (staging, production) (Standard/Premium tiers only)
- Automatic health checks and container restart
- Data persistence ensures no data loss during restarts
- Zone redundancy available with Premium SKUs (P1v2+)
- Traffic manager integration for multi-region deployments
Performance Optimizations
- PostgreSQL Flexible Server for reliable, scalable database performance
- Optional: external PostgreSQL connection pooling (for example, PgBouncer) can improve resource utilization, but it is not configured by this repo
- VNet integration for optimal network performance
- B1 SKU: 1 core, 1.75 GB RAM (suitable for small to medium deployments, 5-50 users)
- Upgrade to Standard (S1+) or Premium tiers for auto-scaling and higher capacity
- Always On enabled to prevent cold starts
- Supports deployment slots for testing before production rollout (Standard and Premium tiers)
Cost Breakdown
Monthly Cost Estimates (North Europe)
| Resource | Configuration | Estimated Cost |
|---|---|---|
| App Service Plan (B1) | 1 core, 1.75 GB RAM, Linux | $13-15 |
| PostgreSQL Flexible Server | Burstable B1MS, 1 vCore, 2 GB RAM, 32 GB storage, 35-day GRS backup | $15-25 |
| Storage Account | Standard_GRS Hot Files, 250 GB share quota (billed on actual usage) | $2-15 |
| Private Endpoints | Key Vault + Storage Account Files (×2) | ~$15 |
| Log Analytics | Pay-as-you-go ingestion (~10 GB/month) | $2-10 |
| Virtual Network | Three subnets (app service, PostgreSQL, private endpoints), NSGs included | Free |
| Private DNS Zones | privatelink for PostgreSQL, Key Vault, and Storage Files (×3) | ~$1.50 |
| Key Vault | Operations-based pricing | < $1 |
| Total | $50-80/month |
B1 Features (Default):
- ✅ Full VNet integration support
- ✅ Custom domain with SSL included
- ✅ 1 core, 1.75 GB RAM (sufficient for 5-50 users)
- ✅ Manual scaling up to 3 instances
- ✅ Production-ready with SLA
- ❌ No auto-scaling (available on S1+)
- ❌ No deployment slots (available on S1+)
Upgrade Options:
- Standard (S1, S2, S3): Adds auto-scaling, deployment slots, up to 10 instances (~$70-140/month for S1-S3)
- Premium (P1v3, P2v3, P3v3): Enhanced performance, up to 30 instances, more cores and memory (~$100-400/month)
Backup & Protection Features:
- ✅ PostgreSQL built-in backup with 35-day retention (the service maximum)
- ✅ Geo-redundant backup replicated to the Azure paired region (set at server creation, immutable)
- ✅ Point-in-time restore for data protection
- ✅ Optional PostgreSQL server lock prevents accidental deletion (enable via
enablePostgresqlLockparameter) - ✅ Compliance-ready backup solution
Note: B1 provides excellent value for small to medium deployments (5-50 users). For larger deployments or auto-scaling needs, upgrade to Standard (S1+) or Premium tiers.
Cost Optimization Tips
- B1 tier is ideal for small to medium deployments (5-50 users) with excellent cost savings
- Upgrade to Standard (S1+) tier for auto-scaling and deployment slots if needed
- Configure auto-scaling (on S1+) to scale down during low-traffic periods
- Use lifecycle policies for Log Analytics to manage log retention
- Use shared Log Analytics workspace across multiple projects
- Reserved instances available for 1-3 year commitments (30-55% savings)
- Adjust PostgreSQL backup retention period (1-35 days) based on compliance requirements; the default is the maximum 35 days
Deployment Process
Pre-Deployment
- Azure CLI and Bicep installed
- Appropriate Azure subscription permissions
- Optional: Custom domain DNS configured
Deployment Steps
- Resource Group Creation: Subscription-scoped deployment creates resource group
- Network Setup: Virtual Network with three subnets (
app-service-snet,postgresql-snet,private-endpoints-snet) provisioned - Private DNS Zones:
privatelink.postgres.database.azure.com,privatelink.vaultcore.azure.net, andprivatelink.file.<storage-suffix>created and linked to the VNet - Database Provisioning: Azure Database for PostgreSQL Flexible Server deployed in the delegated subnet with VNet integration
- Monitoring Setup: Log Analytics Workspace deployed
- App Service Plan: B1 Basic Linux plan created (can be upgraded to Standard/Premium for auto-scaling)
- Key Vault: Deployed for secrets management (admin token + database URL) with
publicNetworkAccess: 'Disabled'and avaultprivate endpoint inprivate-endpoints-snet, wired to the Key Vault private DNS zone - Storage Account: StorageV2 account with an Azure Files share is provisioned with geo-redundant storage (GRS) for cross-region data replication.
publicNetworkAccessisDisabled; the App Service reaches the file share over the VNet through afileprivate endpoint inprivate-endpoints-snet, with name resolution via the linkedprivatelink.file.<storage-suffix>private DNS zone. The share is mounted into the container at/dataso thatATTACHMENTS_FOLDER(/data/attachments),SENDS_FOLDER(/data/sends),ICON_CACHE_FOLDER(/data/icon_cache), andRSA_KEY_FILENAME(/data/rsa_key, used by Vaultwarden as the prefix for the.pem/.pub.pemJWT signing keypair) are persisted to durable storage — offloading the favicon cache and the generated RSA keys from the ephemeral container disk so client sessions survive restarts.TEMPLATES_FOLDERis intentionally left on the local container disk because upstream Vaultwarden requires it to be a local path.USER_ATTACHMENT_LIMIT(1000 MiB per user),ORG_ATTACHMENT_LIMIT(250 GiB per org), andUSER_SEND_LIMIT(100 MiB per user) cap storage sizes. Diagnostic metrics are forwarded to Log Analytics. - Application Deployment: Vaultwarden container deployed on App Service with VNet integration and DATABASE_URL configured
Post-Deployment
- Verify App Service health status
- Test application access via provided URL
- Configure custom domain (if required)
- Set up backup procedures
- Configure monitoring alerts
Monitoring and Operations
Key Metrics to Monitor
- App Service CPU and memory usage
- HTTP request count and response times
- Storage usage and IOPS
- PostgreSQL connections and query performance
- App Service restart count
- Failed authentication attempts
Log Queries (KQL)
Recent App Service Logs
AppServiceConsoleLogs
| where ResourceId contains "vaultwarden-dev-app"
| order by TimeGenerated desc
| take 100
Error Logs
AppServiceConsoleLogs
| where ResourceId contains "vaultwarden-dev-app"
| where ResultDescription contains "ERROR" or ResultDescription contains "error"
| order by TimeGenerated desc
HTTP Request Stats
AppServiceHTTPLogs
| where ResourceId contains "vaultwarden-dev-app"
| summarize count() by ScStatus
Backup and Disaster Recovery
Backup Strategy
- PostgreSQL Built-in Backup: Azure Database for PostgreSQL Flexible Server provides automated backups
- Schedule: Continuous automated backups (snapshots + transaction logs)
- Retention: 35 days (the service maximum), configured at deployment
- Geo-redundancy: Enabled — backups are replicated to the Azure paired region (set at server creation, immutable)
- Point-in-Time Restore: Restore to any second within the retention period
- Setup: Automatically enabled on PostgreSQL Flexible Server at deployment
- Operation: Fully automatic with no manual intervention required
- Manual Backups: Alternative option using
pg_dumpvia Azure CLI or direct connection for logical backups - Database Protection: Optional CanNotDelete lock prevents accidental PostgreSQL server deletion (enable via
enablePostgresqlLockparameter)
Recovery Procedures
Point-in-Time Restore
- Access Azure Portal or use Azure CLI to initiate a point-in-time restore
- Select the restore point (any second within the retention period)
- A new PostgreSQL Flexible Server instance is created with the restored data
- Update the App Service DATABASE_URL to point to the new server (or swap DNS)
- Restart App Service if needed
- Verify data integrity
Manual Restore Process
- Stop the App Service to prevent new writes
- Restore the PostgreSQL database using point-in-time restore via Azure Portal or CLI
- Update connection settings if the restored server has a different endpoint
- Restart the App Service
- Verify data integrity and application functionality
Business Continuity
- RTO (Recovery Time Objective): < 1 hour with point-in-time restore
- RPO (Recovery Point Objective): Near-zero data loss (continuous backup with transaction log archiving)
- Data Protection: Optional resource lock prevents accidental deletion of PostgreSQL server
- Geo-redundant PostgreSQL Backup: Enabled by default — backups replicated to the Azure paired region for cross-region recovery
- Geo-redundant Storage: Attachment, Send, favicon-cache, and JWT-signing-key data in Azure Files is replicated to the paired region (Standard_GRS)
- Backup Retention: 35 days (the service maximum)
Backup Monitoring
- Monitor PostgreSQL server health and backup status through Azure Portal
- Set up alerts for backup failures or storage issues in Azure Monitor
- Review backup configuration and retention policies periodically
- Validate backup integrity through periodic point-in-time restore tests
Troubleshooting Guide
Common Issues
Container Won’t Start
Symptoms: Container keeps restarting Causes:
- Invalid environment variables
- Database connectivity issues
- Image pull failures
Resolution:
# Check App Service logs
az webapp log tail --name <app-name> --resource-group <rg-name>
# Check App Service status
az webapp show --name <app-name> --resource-group <rg-name>
Cannot Access Application
Symptoms: URL not responding Causes:
- Container not ready
- Ingress misconfiguration
- DNS issues
Resolution:
# Check ingress configuration
az webapp show --name <app-name> --resource-group <rg-name> --query "httpsOnly,hostNames"
# Verify container is running
az webapp log tail --name <app-name> --resource-group <rg-name>
PostgreSQL Connectivity Issues
Symptoms: Application errors related to database connection failures Causes:
- PostgreSQL server not running or unreachable
- VNet integration misconfigured
- Private DNS Zone not resolving correctly
- SSL certificate issues
- Incorrect DATABASE_URL in Key Vault
Resolution:
- Verify PostgreSQL server status in Azure Portal
- Check VNet integration and subnet delegation settings
- Verify Private DNS Zone is linked to the VNet and resolving correctly
- Test connectivity from App Service using Kudu console
```bash
Check PostgreSQL server status
az postgres flexible-server show –name
--resource-group
Verify DNS resolution from within the VNet
az webapp ssh –name
Then from the SSH session: nslookup .postgres.database.azure.com
```
Security Hardening
Production Checklist
- Enable admin token with strong password
- Disable signups or use invite-only mode
- Configure custom domain with valid SSL certificate
- Set up Azure Monitor alerts
- Configure backup automation (PostgreSQL built-in geo-redundant backup with 35-day retention)
- Enable PostgreSQL server lock to prevent accidental deletion (set
enablePostgresqlLock=true; requiresMicrosoft.Authorization/locks/writepermission) - Enable VNet integration for PostgreSQL Flexible Server (no public access)
- Review and restrict network access
- Enable deployment slots for zero-downtime updates
- Configure auto-scaling rules based on load
- Set up Application Insights for detailed monitoring
- Implement IP restrictions if needed
- Set up log retention policies
- Configure SMTP for email notifications
- Review and update Vaultwarden regularly
- Consider zone redundancy (upgrade to Premium if needed)
- Test backup restore procedures periodically
Compliance Considerations
- Data residency: Resources deployed in specified Azure region
- Encryption: Data encrypted at rest and in transit
- Audit logs: Available through Log Analytics
- Access control: Azure RBAC for resource management
- Network isolation: VNET integration available
- Backup and recovery: Continuous automated backups with 35-day geo-redundant retention
- Data protection: Optional resource locks prevent accidental resource deletion
Updates and Maintenance
Update Procedures
- Test updates in dev environment first
- Backup data before updating
- Update image tag in parameters file
- Redeploy template
- Verify application functionality
- Monitor for issues
Maintenance Windows
- Recommended: Off-peak hours
- Duration: 5-10 minutes typical
- Zero-downtime updates possible with deployment slots (staging → production swap)
Additional Resources
Official Documentation
Community Resources
Support Channels
- Vaultwarden Issues: GitHub Issues
- Azure Support: Azure Portal
- Community: Reddit r/Vaultwarden