A simple Express.js API that connects to Azure SQL using Sequelize ORM.
GET /api/hello: Returns a welcome messagePOST /api/users: Creates a user (name & email)GET /api/users: Retrieves all users
- Node.js
- Express.js
- Sequelize
- Azure SQL
- Clone the repo:
git clone https://github.com/your-username/express-azure-sql-app.git
cd express-azure-sql-app- Install dependencies:
npm install- Create a
.envfile:
PORT=3000
DB_HOST=your-sql-server.database.windows.net
DB_NAME=your-database-name
DB_USER=your-db-username
DB_PASSWORD=your-db-password
DB_DIALECT=mssql
DB_PORT=1433
DB_ENCRYPT=true- Run the app:
npm start- Deploy to Azure:
- Use Azure App Service (Node.js 18+)
- Set environment variables in the Azure App Service configuration
- Enable port binding by using
process.env.PORT
- Make sure your Azure SQL firewall allows the Azure App Service IP range.
- Use
sequelize.sync()for dev; for production, consider migrations.