This example demonstrates deploying a Next.js app to Azure Functions. The architecture consists of a front-end, Azure Functions as middleware, and a PostgreSQL database (using Docker), forming the back-end. The front-end communicates with the back-end through the middleware, ensuring a detachable front-end.
MIT License
This example demonstrates deploying a Next.js app to Azure Functions. The architecture consists of a front-end, Azure Functions as middleware, and a PostgreSQL database (using Docker), forming the back-end. The front-end communicates with the back-end through the middleware, ensuring a detachable front-end.
Three configuration files are required:
.env
in the project root for Docker.env
in the frontend
folderlocal.settings.json
in the api
folder for Azure FunctionsExamples of these files are provided in the repository.
Clone the repository:
git clone <repository_url>
cd <repository_folder>
Start the PostgreSQL database:
In the project root, run:
docker-compose up
For Linux : Change the permissions of the folder called pg_data_master (docker volume) to 777
sudo chmod 777 pg_data_master
and the user and group of the folder to 1001
sudo chown -R 1001:1001 pg_data_master
Customize the database credentials in the docker-compose.yml
file via .env
or directly.
Set up Azure Functions:
Navigate to the api
folder and install dependencies:
cd api
npm install
For the initial setup, deploy the functions to Azure by following these steps:
Press Fn + F5
to deploy the functions.
Follow the prompts to configure and debug the functions locally.
Set up the front-end:
Navigate to the frontend
folder and install dependencies:
cd ../frontend
npm install
Start the front-end:
npm run dev
Access the application:
Open a browser and navigate to http://localhost:3000
.
http://localhost:3000
to see the default "Hello World" message from the API.This example illustrates deploying a Next.js app with Azure Functions as middleware and a PostgreSQL database back-end. The front-end remains detachable, ensuring a flexible architecture.
This project is licensed under the MIT License. See the LICENSE.md file for details.