π n8n on Azure: Because Workflows Shouldn't Be a Pain in the Cloud
Deploy n8n like a boss on Azure! This repo helps you set up n8n faster than you can say "automation" (okay, maybe not that fast, but pretty close).
What's in the Box? π
- π³ Docker-powered goodness
- π Auto-HTTPS (because security is cool)
- πΎ PostgreSQL that actually remembers stuff
- π€ n8n ready to automate your life
- π§ Scripts that do the heavy lifting
Why This? π€
Because manually setting up n8n on Azure is about as fun as debugging production at 3 AM. This template does all the boring stuff for you, so you can focus on building awesome workflows instead.
Cost? π°
About $15/month - cheaper than your coffee addiction! β
Perfect for: People who love automation but hate complicated setups. Not perfect for: People who enjoy spending weekends configuring servers (you know who you are).
Ready to make your life easier? Check out the docs below! π
n8n Azure VM Deployment
This repository contains templates and scripts to deploy n8n workflow automation platform on Azure Virtual Machine. This deployment uses Docker and Docker Compose for running n8n and PostgreSQL, with Caddy as a reverse proxy for automatic HTTPS.
Overview
The deployment consists of:
- Azure B1ms VM (1 vCPU, 2GB RAM)
- Ubuntu 22.04 LTS
- Docker & Docker Compose
- n8n Community Edition
- PostgreSQL database
- Caddy web server (for HTTPS)
- Automatic backups
- Basic monitoring
Prerequisites
-
Azure CLI installed
curl -sL https://aka.ms/InstallAzureCLI | bash -
Azure subscription
az login -
A domain name pointed to Azure VM's IP (will be obtained during deployment)
Repository Structure
.
βββ n8n-vm-template.json # Azure ARM template for VM
βββ deploy.sh # Deployment script
βββ setup.sh # VM setup script
βββ docker-compose.yml # Docker composition for n8n
βββ backup.sh # Backup script
βββ README.md # This file
Deployment Steps
1. Clone the Repository
git clone https://github.com/jawand/n8n-azure-vm-starter
cd n8n-azure-vm-starter
2. Configure Deployment
Edit deploy.sh and set your preferred values:
RESOURCE_GROUP="n8n-rg"
LOCATION="eastus"
VM_NAME="n8n-vm"
ADMIN_USERNAME="n8nadmin"
3. Deploy the VM
chmod +x deploy.sh
./deploy.sh
The script will:
- Create a resource group
- Generate SSH keys if needed
- Deploy the VM using ARM template
- Output connection information
- The VM public IP is Dynamic, so you need to use Azure DNS record to point to your domain.
4. Configure DNS
Point your domain to the VM's DNS Name (shown in deployment output). We cannot use IP address because it is dynamic and will change when the VM is restarted. Additionally, we are using Caddy as a reverse proxy to automatically handle HTTPS.
Make sure to create CNAME record for n8n.example.com to point to the VM's DNS Name (found in deployment output) on your Domain Registrar.
We need the DNS configured before we setup n8n server because Caddy will use the DNS to get the SSL certificate from Let's Encrypt and if its not ready then SSL will not generate & will throw an error, because Caddy will not be able to get the SSL certificate since it will not find the DNS record. I will recommend to wait for 10-15 minutes after you have pointed your subdomain to Azure VM DNS Name, before we setup n8n server.
5. Setup n8n
-
SSH into the VM:
ssh -i ~/.ssh/id_rsa_n8n n8nadmin@<VM_IP> -
Open new Terminal and Copy setup files:
# From your local machine scp -i ~/.ssh/id_rsa_n8n setup.sh docker-compose.yml backup.sh n8nadmin@<VM_IP>:~/
- It will copy all the files to the VM.
- Run setup:
chmod +x setup.sh ./setup.sh
It will ask for domain name, Please provide your domain name. I prefer to use subdomain like n8n.yourdomain.com.
7. Navigate to n8n folder and start containers
cd n8n
docker-compose up -d
- we are using volume to persist n8n data to make sure data is not lost when containers are restarted.
8. Access n8n
Once deployment is complete, you can access n8n at:
https://n8n.your-domain.com
Set your own credentials at the first login.
Configuration Files
docker-compose.yml
Contains service definitions for:
- n8n
- PostgreSQL
Key configurations:
services:
n8n:
image: docker.io/n8nio/n8n:latest
ports:
- "5678:5678"
environment:
- N8N_HOST=${N8N_HOST}
- WEBHOOK_URL=https://${N8N_HOST}
- NODE_ENV=production
- N8N_PROTOCOL=https
- N8N_SSL_CERT=/etc/caddy/certificates/${N8N_HOST}.crt
- N8N_PORT=5678
- GENERIC_TIMEZONE=UTC
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- postgres
postgres:
image: postgres:14-alpine
environment:
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=password
- POSTGRES_DB=n8n
volumes:
- postgres_data:/var/lib/postgresql/data
Backup Configuration
The backup.sh script performs:
- PostgreSQL database dumps
- n8n data volume backup
- Optional upload to Azure Storage
To enable automatic backups:
(crontab -l 2>/dev/null; echo "0 0 * * * /home/n8nadmin/backup.sh") | crontab -
Maintenance
Updates
Update n8n and PostgreSQL:
docker-compose pull
docker-compose up -d
Monitoring
-
Check container status:
docker-compose ps -
View logs:
docker-compose logs -f -
Monitor system resources:
htop
Backups
Manual backup:
./backup.sh
Security Considerations
-
Firewall rules are configured to allow only:
- SSH (22) Please make sure to disable SSH port 22 in Azure portal.
- HTTPS (443)
-
SSH access:
- SSH Key-based authentication only and is stored at
~/.ssh/id_rsa_n8non your local machine. - Password authentication disabled
- SSH Key-based authentication only and is stored at
-
n8n security:
- HTTPS enforced
- Regular security updates
Troubleshooting
-
Cannot connect to n8n:
- Check VM status in Azure portal
- Verify domain DNS settings
- Check docker containers:
docker-compose ps
-
Database connection issues:
- Check PostgreSQL logs:
docker-compose logs postgres - Verify environment variables in docker-compose.yml
- Check PostgreSQL logs:
-
SSL/HTTPS issues:
- Check Caddy logs:
sudo journalctl -u caddy - Verify domain points to correct IP
- Check Caddy logs:
Cost Estimation
Monthly cost breakdown:
- VM (B1ms): ~$13.14
- Storage (OS Disk): ~$2.40
- Total: ~$15.54/month
Support
For issues:
- Check the n8n documentation
- Open an issue in this repository
- Check n8n community forums
License
This deployment template is MIT licensed. n8n is licensed under its own terms.