Azure SQL Database
for WebhookFlow
Connect the WebhookFlow microservice to Azure SQL Database — Microsoft's managed SQL Server in the cloud. Free tier available, runs from Windows, and tables are created automatically by Spring Boot JPA on first startup.
| Option | Persistence | Setup | Production-like | We use |
|---|---|---|---|---|
| H2 in-memory | Lost on restart | Zero setup | No | Never |
| SQL Server on Windows | Persists | Heavy installer (1GB+) | Yes | No |
| Azure SQL Database ✓ | Persists | Azure portal (5 min) | Yes — IS production | Yes |
localhost:1433 becomes yourserver.database.windows.net:1433. Spring Boot and JPA don't care.
Azure Free Account
Go to azure.microsoft.com/free and sign up. You get $200 credit for 30 days and several services free for 12 months. Azure SQL Database (Basic tier, 2 GB) is free for 12 months.
Azure Data Studio — installed on Windows
Download from azure.microsoft.com/products/data-studio. It is the official SQL client for Windows — lighter than SSMS, optimised for Azure SQL. Free download, ~150 MB.
WebhookFlow project open in VS Code
You should already have the webhook project running with H2. We will swap the database without changing any Java code.
Open Azure Portal → Create a resource
Go to portal.azure.com → click Create a resource → search for Azure SQL → select SQL Database.
Fill in the Basics tab
| Field | Value |
|---|---|
| Subscription | Your Azure subscription |
| Resource group | campustoai-rg (create new) |
| Database name | webhookflow |
| Server | Click Create new → see step 3 |
| Compute + storage | Click Configure database → choose Basic (5 DTU, 2 GB, ~$5/month or free tier) |
| Backup redundancy | Locally redundant |
Create the SQL Server (logical server)
| Field | Value |
|---|---|
| Server name | webhookflow-server (must be globally unique — add your initials if needed) |
| Location | Southeast Asia or Central India (closest to students) |
| Authentication method | Use SQL authentication |
| Server admin login | sqladmin |
| Password | Webhook@1234 (share with cohort — change before production) |
Click Review + Create → Create
Deployment takes about 2–3 minutes. Once done, your server is at webhookflow-server.database.windows.net and the database is named webhookflow.
@Entity classes and creates/updates all tables automatically (ddl-auto=update). The database just needs to exist.
Open Azure Portal → your SQL Server → Networking
Go to portal.azure.com → open webhookflow-server → left sidebar → Networking → Firewall rules tab.
Add a rule that allows all IPs
Click Add a firewall rule and fill in:
| Field | Value |
|---|---|
| Rule name | AllowCourseStudents |
| Start IP address | 0.0.0.0 |
| End IP address | 255.255.255.255 |
Click Save. All students can now connect from any home IP without any further firewall changes.
After the batch ends — lock it down
Go back to Networking → delete the AllowCourseStudents rule → add only your own IP. This prevents any access once the course is over.
Open Azure Data Studio → New Connection
Launch Azure Data Studio on Windows → click the plug icon (New Connection) in the top-left.
Enter connection details
| Field | Value |
|---|---|
| Connection type | Microsoft SQL Server |
| Server | webhookflow-server.database.windows.net,1433 |
| Authentication type | SQL Login |
| User name | sqladmin |
| Password | Webhook@1234 |
| Database | webhookflow |
| Encrypt connection | Mandatory |
| Trust server certificate | No |
Click Connect
You should see the webhookflow database in the sidebar. The database is empty for now — Spring Boot will create the tables when you first start the app.
After running the app — verify tables
Right-click webhookflow → New Query → run:
You should see: webhook_event, webhook_subscription, delivery_log, event_source.
Remove the H2 dependency and add the SQL Server JDBC driver:
Replace all H2 configuration with Azure SQL settings. Credentials come from environment variables (see Step 5).
Method A — PowerShell (current session only)
Open PowerShell and run these before mvn spring-boot:run:
Method B — .env file for VS Code (recommended)
Create a .env file in webhook/ (next to pom.xml). VS Code's launch.json reads it automatically when you press F5.
Method C — Windows System Environment Variables (permanent)
Search Environment Variables in Start → Edit the system environment variables → Environment Variables → New under User Variables:
After saving, restart VS Code or PowerShell for the new values to take effect.
Set environment variables (if using Method A) then run
Look for this in the startup log
Call the health endpoint
Expected response: {"status":"UP","totalEvents":0}
Verify tables in Azure Data Studio
Should show 4 tables: webhook_event, webhook_subscription, delivery_log, event_source.
| Error | Cause | Fix |
|---|---|---|
Could not connect to server |
Firewall rule missing or not saved | Azure Portal → webhookflow-server → Networking → confirm the AllowCourseStudents rule exists with Start IP 0.0.0.0 and End IP 255.255.255.255, then Save |
Login failed for user 'sqladmin' |
Wrong password, or SQL authentication disabled | Check AZURE_SQL_PASSWORD env var; verify SQL auth is enabled in portal |
Could not resolve placeholder 'AZURE_SQL_SERVER' |
Environment variable not set in this shell | Run $env:AZURE_SQL_SERVER="webhookflow-server" first, then mvn spring-boot:run in the same PowerShell window |
SSL connection required |
Missing encrypt=true in connection URL |
Ensure the JDBC URL in application.properties includes encrypt=true |
Database 'webhookflow' does not exist |
Database not created in portal | Go to Azure portal → SQL Databases → verify webhookflow database exists on your server |
| Tables not created after startup | ddl-auto not set to update |
Check application.properties has spring.jpa.hibernate.ddl-auto=update |
| Azure Data Studio: certificate error | Trust server certificate off | In Azure Data Studio connection, set Encrypt connection to Mandatory and Trust server certificate to No. Azure SQL uses a valid CA cert. |