n8n Self-Hosting Setup Guide (Azure)
Same as above tailored for Microsoft Azure.
n8n Self-Hosting Setup Guide (Azure)
This guide walks you through deploying n8n on Azure App Service with persistent storage, SSL, and production-grade configuration. You'll have a working automation platform in 30-45 minutes.
What You Need
- Azure subscription with Contributor access
- Azure CLI 2.50+ installed locally
- Basic familiarity with command-line tools
- A custom domain (optional, for SSL setup)
Architecture Overview
You'll deploy:
- Azure App Service (Linux, Node.js runtime)
- Azure Database for PostgreSQL (Flexible Server)
- Azure Storage Account (for workflow data and credentials)
- Application Insights (for monitoring)
Total monthly cost: $25-75 depending on tier selection.
Step 1: Set Up Azure Resources via CLI
Open your terminal and authenticate:
az login
az account set --subscription "Your-Subscription-Name"
Create a resource group:
az group create \
--name n8n-production \
--location eastus
Create a PostgreSQL database:
az postgres flexible-server create \
--resource-group n8n-production \
--name n8n-db-prod \
--location eastus \
--admin-user n8nadmin \
--admin-password 'YourSecurePassword123!' \
--sku-name Standard_B1ms \
--tier Burstable \
--storage-size 32 \
--version 14
Note the server name output. You'll need it for connection strings.
Create the n8n database:
az postgres flexible-server db create \
--resource-group n8n-production \
--server-name n8n-db-prod \
--database-name n8n
Configure firewall to allow Azure services:
az postgres flexible-server firewall-rule create \
--resource-group n8n-production \
--name n8n-db-prod \
--rule-name AllowAzureServices \
--start-ip-address 0.0.0.0 \
--end-ip-address 0.0.0.0
Step 2: Create Storage Account for Persistent Data
az storage account create \
--name n8nstorageprod \
--resource-group n8n-production \
--location eastus \
--sku Standard_LRS
Get the storage connection string:
az storage account show-connection-string \
--name n8nstorageprod \
--resource-group n8n-production \
--output tsv
Copy this connection string. You'll add it to App Service configuration.
Create a file share for workflow attachments:
az storage share create \
--name n8n-data \
--account-name n8nstorageprod \
--quota 10
Step 3: Deploy App Service with Docker Container
Create an App Service Plan:
az appservice plan create \
--name n8n-plan \
--resource-group n8n-production \
--is-linux \
--sku B2
The B2 tier ($54/month) provides 3.5GB RAM and 2 cores. For lighter workloads, use B1 ($13/month).
Create the App Service:
az webapp create \
--resource-group n8n-production \
--plan n8n-plan \
--name n8n-yourcompany \
--deployment-container-image-name n8nio/n8n:latest
Replace n8n-yourcompany with your unique app name. This becomes n8n-yourcompany.azurewebsites.net.
Step 4: Configure Environment Variables
Set required n8n configuration:
az webapp config appsettings set \
--resource-group n8n-production \
--name n8n-yourcompany \
--settings \
N8N_PROTOCOL=https \
N8N_HOST=n8n-yourcompany.azurewebsites.net \
WEBHOOK_URL=https://n8n-yourcompany.azurewebsites.net/ \
N8N_PORT=8080 \
GENERIC_TIMEZONE=America/New_York \
N8N_ENCRYPTION_KEY='generate-32-char-random-string-here' \
DB_TYPE=postgresdb \
DB_POSTGRESDB_HOST=n8n-db-prod.postgres.database.azure.com \
DB_POSTGRESDB_PORT=5432 \
DB_POSTGRESDB_DATABASE=n8n \
DB_POSTGRESDB_USER=n8nadmin \
DB_POSTGRESDB_PASSWORD='YourSecurePassword123!' \
EXECUTIONS_DATA_SAVE_ON_SUCCESS=all \
EXECUTIONS_DATA_SAVE_ON_ERROR=all \
N8N_METRICS=true
Generate a secure encryption key:
openssl rand -base64 24
Replace generate-32-char-random-string-here with the output.
Step 5: Mount Persistent Storage
Configure the file share mount:
az webapp config storage-account add \
--resource-group n8n-production \
--name n8n-yourcompany \
--custom-id n8ndata \
--storage-type AzureFiles \
--share-name n8n-data \
--account-name n8nstorageprod \
--access-key $(az storage account keys list --resource-group n8n-production --account-name n8nstorageprod --query '[0].value' -o tsv) \
--mount-path /home/node/.n8n
This ensures workflow data persists across container restarts.
Step 6: Enable Authentication
Set up basic authentication as a first layer:
az webapp config appsettings set \
--resource-group n8n-production \
--name n8n-yourcompany \
--settings \
N8N_BASIC_AUTH_ACTIVE=true \
N8N_BASIC_AUTH_USER=admin \
N8N_BASIC_AUTH_PASSWORD='ChangeThisPassword456!'
For production, add Azure AD authentication:
az webapp auth update \
--resource-group n8n-production \
--name n8n-yourcompany \
--enabled true \
--action LoginWithAzureActiveDirectory \
--aad-allowed-token-audiences https://n8n-yourcompany.azurewebsites.net
Step 7: Configure SSL and Custom Domain
Add your custom domain:
az webapp config hostname add \
--resource-group n8n-production \
--webapp-name n8n-yourcompany \
--hostname automation.yourfirm.com
Before running this, add a CNAME record in your DNS:
- Type: CNAME
- Name: automation
- Value: n8n-yourcompany.azurewebsites.net
Enable managed SSL certificate:
az webapp config ssl bind \
--resource-group n8n-production \
--name n8n-yourcompany \
--certificate-thumbprint auto \
--ssl-type SNI
Azure provisions a free SSL certificate automatically.
Update the webhook URL setting:
az webapp config appsettings set \
--resource-group n8n-production \
--name n8n-yourcompany \
--settings \
N8N_HOST=automation.yourfirm.com \
WEBHOOK_URL=https://automation.yourfirm.com/
Step 8: Enable Application Insights
Create an Application Insights resource:
az monitor app-insights component create \
--app n8n-monitoring \
--location eastus \
--resource-group n8n-production \
--application-type web
Get the instrumentation key:
az monitor app-insights component show \
--app n8n-monitoring \
--resource-group n8n-production \
--query instrumentationKey -o tsv
Link it to your App Service:
az webapp config appsettings set \
--resource-group n8n-production \
--name n8n-yourcompany \
--settings \
APPINSIGHTS_INSTRUMENTATIONKEY='your-instrumentation-key-here'
Step 9: Verify Deployment
Restart the App Service to apply all settings:
az webapp restart \
--resource-group n8n-production \
--name n8n-yourcompany
Check deployment status:
az webapp browse \
--resource-group n8n-production \
--name n8n-yourcompany
This opens your n8n instance in a browser. You should see the login screen within 60 seconds.
Log in with the credentials you set in Step 6.
Troubleshooting Common Issues
Container fails to start:
Check logs in real-time:
az webapp log tail \
--resource-group n8n-production \
--name n8n-yourcompany
Look for database connection errors. Verify the PostgreSQL firewall rule allows Azure services.
Workflows don't persist after restart:
Verify storage mount:
az webapp config storage-account list \
--resource-group n8n-production \
--name n8n-yourcompany
The mount path must be /home/node/.n8n.
Webhooks
Check the WEBHOOK_URL setting matches your actual domain:
az webapp config appsettings list \
--resource-group n8n-production \
--name n8n-yourcompany \
--query "[?name=='WEBHOOK_URL'].value" -o tsv
Database connection timeout:
Add your local IP to PostgreSQL firewall for testing:
az postgres flexible-server firewall-rule create \
--resource-group n8n-production \
--name n8n-db-prod \
--rule-name AllowMyIP \
--start-ip-address YOUR.IP.ADDRESS.HERE \
--end-ip-address YOUR.IP.ADDRESS.HERE
Test connection with psql:
psql "host=n8n-db-prod.postgres.database.azure.com port=5432 dbname=n8n user=n8nadmin password=YourSecurePassword123! sslmode=require"
Production Hardening Checklist
Before going live:
- Change all default passwords (database, basic auth, encryption key)
- Enable Azure AD authentication and disable basic auth
- Set up automated backups for PostgreSQL (7-day retention minimum)
- Configure App Service auto-scaling rules (scale out at 70% CPU)
- Set up Azure Monitor alerts for failed executions and high memory usage
- Restrict PostgreSQL firewall to App Service outbound IPs only
- Enable App Service diagnostic logs and send to Log Analytics workspace
Backup Configuration
Enable automated PostgreSQL backups:
az postgres flexible-server update \
--resource-group n8n-production \
--name n8n-db-prod \
--backup-retention 7 \
--geo-redundant-backup Enabled
Export workflow definitions weekly:
Create a workflow in n8n that runs on schedule, exports all workflows via the n8n API, and saves them to Azure Blob Storage. This provides version control for your automation logic.
Cost Optimization
For development environments, use these settings to reduce costs to ~$15/month:
- App Service Plan: B1 tier
- PostgreSQL: Burstable B1ms tier
- Storage: Standard LRS (locally redundant)
- Disable Application Insights or use sampling
For production with high workflow volume:
- App Service Plan: P1V2 or higher
- PostgreSQL: General Purpose D2s_v3
- Enable zone redundancy for both services
Your n8n instance is now production-ready. Test a simple workflow (HTTP Request → Webhook

Reviewed by Revenue Institute
This guide is actively maintained and reviewed by the implementation experts at Revenue Institute. As the creators of The AI Workforce Playbook, we test and deploy these exact frameworks for professional services firms scaling without new headcount.
Revenue Institute
Need help turning this guide into reality? Revenue Institute builds and implements the AI workforce for professional services firms.