Azure Container Apps offers a flexible, scalable, and cost-efficient environment to deploy and manage containers. With the ability to auto-scale based on demand, you’ll only pay for what you use. Plus, it gives you complete control over your infrastructure without having to worry about server management.
N8n, on the other hand, is a game-changing automation tool that integrates seamlessly with hundreds of apps and services, allowing you to build powerful workflows with ease. Combining the flexibility of Azure and the functionality of N8n can give you the ultimate workflow automation setup.
Let’s dive in!
Step-by-Step Guide to Deploying N8n on Azure Container Apps
Step 1: Setting Up the Container App
Navigate to Azure Portal: Go to portal.azure.com and log in to your account.
Create a Container App: In the Azure dashboard, search for Container App and click Create. This will start the container app creation process.
Choose Your Subscription and Resource Group: Select an existing resource group or create a new one to keep your resources organized. Give your container app a name, such as “n8n-container,” and choose the appropriate region.
Select Deployment Source: In the container setup, choose Container Image and select Docker Hub. For the image name, use n8nio/n8n:latest.
Configure CPU and Memory: For the initial setup, I recommend starting with 1 CPU and 2GB of memory, but feel free to adjust based on your needs. You can choose either Consumption (pay as you go) or a Fixed Workload (more predictable costs).
Step 2: Setting Up Environment Variables
Proper configuration of environment variables is crucial for N8n’s security and performance. Here are the key ones to set:
N8N_ENCRYPTION_KEY: Set a strong encryption key to secure sensitive data.
GENERIC_TIMEZONE: Set the appropriate timezone for your workflows.
WEBHOOK_URL: This is where your N8n instance will be accessible. It can be an Azure-provided URL or a custom domain if you prefer.
TRUST_PROXY: Set this to true to ensure proper proxy handling.
N8N_BASIC_AUTH: Set up basic authentication credentials to protect access to your N8n instance.
For connecting to a PostgreSQL database, include the following variables:
DB_TYPE: Set to postgres.
DB_HOST: The hostname or IP address of your Postgres database.
DB_PORT: The port your Postgres database is running on (default is 5432).
DB_DATABASE: The name of your database, usually postgres by default.
DB_USER: Your Postgres username.
DB_PASSWORD: Your Postgres password.
Make sure to also configure N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS to true for added security.
Step 3: Enabling Ingress for Public Access
Enable Ingress: In the Ingress settings, select Enabled and allow traffic from anywhere.
Configure Port and Protocol: Set the port to the default port used by N8N 5678 and enable HTTP transport auto for automatic configuration of your transport settings.
Step 4: Database Configuration (Optional)
If you’re using Postgres on Azure for data storage, follow these steps to allow your N8n instance to connect to your database:
Find Your Container’s IP Address: Navigate to Domain > Custom Domains in your container app settings to find your container’s IP address.
Update Postgres Networking Settings: In the Azure portal, go to your Postgres instance and navigate to Networking. Add the IP address of your container as both the start and end IP range to grant access to the database.
Step 5: Review and Create
Once all configurations are in place, review your settings. If everything looks good, click Create. Azure will take care of the deployment process, and within a few moments, your N8N instance will be live and ready to use.
Feel free to share your experiences and any tips in the comments!
Hello! I followed your guide step by step, using the official n8nio/n8n:latest Docker image on Azure Container Apps. However, when I check the container logs, I see this message:
Error: command start not found
After that, the application doesn’t start at all. I’ve already shared my configuration (JSON) and environment variables, so it seems like I haven’t overridden the default command. Do you have any idea what I might be missing or how to fix this error?
Thanks for sharing this. This helped me set n8n on Azure.
However, there is a challenge I face when I don’t use the platform after a period of time. It forces me to resetup my n8n account. It’s almost like the container shuts down when it’s idle for a period of time. And after it goes back on, it does not remember anything I setup.
I am not a very technical person so forgive my explanation if unclear.
Hey @Victory_Opeolu your welcome. The issue you are having seems related to you database. if you are using SQLite database and it’s stored inside the container without volumes, the data will be lost whenever the container restarts or updates. To persist data, you need to mount an external volume, like Azure Files, or use an external database like postgresql.
I know it is a storage issue. When I tried adding env variables for postgres, it fails to deploy for some weird reason. I have escalated with the Azure team to provide support.
Running n8n on Azure Container Apps can work well, but it’s important to understand the cost implications since n8n needs to run continuously in the background to process jobs. For example, with 1 vCPU and 1 GB memory for 30 days (24/7):
Additionally, n8n requires a Postgres database, which adds to the total cost. While Azure Container Apps are great for HTTP workloads that can scale to zero when idle, workloads like n8n that need to run continuously can get expensive.
To optimize costs, I created a simple shell script to configure n8n on an Azure VM using Docker Compose, with Postgres hosted on the same VM. It includes an option to take continuous backups and store them in Azure Storage. You can check it out here:
I’ve been trying to get it working with a little success.
Initially I tried sqllite DB in Azure share, that failed due to the DB being locked.
Then I switched to Postgres, below are my env vars. I also tried the exact var names described in this artcicle, but the error I am having is the same for both options.
Error in the container logs:
Connecting…
2025-02-25T13:08:40.47301 Connecting to the container ‘n8n’…
2025-02-25T13:08:40.50185 Successfully Connected to container: ‘n8n’ [Revision: ‘ca-xxxxx-poc-ss1–ch2prqe-54497ff645-wr6kq’, Replica: ‘ca-dmitry-poc-ss1–ch2prqe’]
2025-02-25T13:08:24.5725806Z stderr F task: findCommand (mfa:disable)
2025-02-25T13:08:24.5726591Z stderr F plugin: n8n
2025-02-25T13:08:24.5726832Z stderr F root: /usr/local/lib/node_modules/n8n
2025-02-25T13:08:24.5726861Z stderr F message: Cannot read properties of undefined (reading ‘database’)
2025-02-25T13:08:24.5726886Z stderr F See more details with DEBUG=*
2025-02-25T13:08:24.5726908Z stderr F (node:6) Warning: TypeError
2025-02-25T13:08:24.5726929Z stderr F module: @oclif/[email protected]
2025-02-25T13:08:24.5726951Z stderr F task: findCommand (update:workflow) @Hez_Core - could you advice please?
This issue is definitely related to Postgres. Are you running Postgres on Azure Database for PostgreSQL, or is it hosted elsewhere?
If you’re using Postgres, the DB_TYPE should be set to postgresdb. You also need to ensure that:
The username and password match exactly with your Postgres instance credentials.
The host is correctly configured and publicly accessible. If the database is not exposed to the public, your container won’t be able to connect unless you’ve set up a VPN or private networking.
To test, you can temporarily expose the database to the internet and later refine security settings. Alternatively, expose it only to the container’s IP address.
Another critical factor is the database name it must match what’s configured in n8n.
This error specifically means n8n can’t access the database, which is a common issue. If you’re using Azure Database for PostgreSQL, you might also need to enable specific Postgres extensions for n8n to work properly.
Some cloud providers enable these extensions by default, but on Azure, you may need to activate them manually. I might do a video tutorial covering both setting up a Postgres database and troubleshooting connectivity issues with n8n on Azure.
Let me know how your setup is configured, and I can guide you further!
Note: When changing environment variables, you need to create a new revision that’s important else it won’t work.
Thanks @Hez_Core for the quick reply. I am using Azure Database for PostgreSQL flexible server. I was able to connect remotely to the Server with the same creds configured in the n8n app.
I suspect it could be SSL issue, as MS says “Clients connecting to PostgreSQL Flexible servers must install the root CA certificates (public key only”. However, not sure how to do in in the app container.
Also, could you confirm please that DB_TYPE should be postgresdb? The main post says postgres
In addition, I’ve seen var names DB_HOST and DB_POSTGRESDB_HOST in the docs, what are correct key names please?
It’s not recommended due to SQLite’s file based nature. Azure File Share is a network mounted storage solution, which can lead to file locking issues, slow performance, and potential corruption when used with SQLite.