How to setup a FREE SQL database from Azure?

How to setup a FREE SQL database from Azure?

·

4 min read

References

Setup instructions:
Try for free (preview) - Azure SQL Database | Microsoft Learn

Query instructions:
Create a single database - Azure SQL Database | Microsoft Learn

Discussion about vCores free tier and Basic DTU subscription:
Controlling cost Azure SQL Server, why did my free database ran out of vCores on day 4, with very little activity? : AZURE (reddit.com)

To learn more on Auto-Pause and Auto-Resume in vCores tier:
Serverless compute tier - Azure SQL Database | Microsoft Learn

To learn more on vCores vs DTU:
Purchasing models - Azure SQL Database | Microsoft Learn

Check out my article on How to setup FREE .Net Web App:
How to publish and auto-deploy your .NET Web Application (hashnode.dev)

Limitations

Very few things are actually free, and those that are said as such certainly have some limitations. For this database, these are the limits:

  • 100,000 vCore seconds of compute every month

  • 32 GB storage

  • 1 free database per account

Once this limit is reached, you have 2 options:

  • Auto-pause the database until next month (recommended and default)

  • Continue using database for additional charges

There is also Basic DTU tier that would cost a fixed 4.90 USD per month, which can be better compared to paid vCores tier in some cases.

Setup and Create

Access your Azure portal: Home - Microsoft Azure

Click on Create a Resource, click on the SQL Database. Otherwise, just follow this link: Create SQL Database - Microsoft Azure

Click on "Apply offer (Preview)" for the free serverless database.

Select the Subscription and Resource Group:

Database Name: Fill your Database name as you please:

For Server, create new. Select your server name (note, must be unique globally):

For Authentication, if you have Microsoft Entra admin, select "Use both SQL and Microsoft Entra authentication." Otherwise, select "Use SQL authentication."

Enter the admin login and passwords.

Select the Behavior when free offer limit reached: Auto-pause the database until next month.

Click "Next: Networking >"

For now, leave everything default:

  • Connectivity method: No access

  • Connection policy: Default - Uses Redirect policy for all client connections originating inside of Azure (except Private Endpoint connections) and Proxy for all client connections originating outside Azure

  • Minimum TLS version: TLS 1.2

Click "Next : Security >"

For now, leave everything default.

Click "Next : Additional Settings >"

Select "None" for empty Data Source or "Sample" for AdventureWorksLT database. "Sample" will change the Compute + storage to the default (if you make any change to it earlier):

General Purpose - Serverless

Standard-series (Gen5), 2 vCores, 32 GB storage, zone redundant disabled

For now, leave everything default.

Proceed to Create. Wait until your new database is deployed:

Query

Access your created database from Azure portal.

Select "Query editor (preview)"

Enter the Admin password set earlier.

You may want to set the access to Private or Public to first: Overview > Configure Access:

  • Enable the Public network access with "Selected networks"

  • At the Firewall rules, click on "Add your client IPv4 (...)"

  • Press Save

Back to the Query Editor, login either with SQL server authentication or your Microsoft Entra.

Once in, you can try test out the Query:

The following SQL would work with Sample DB:

SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName
FROM SalesLT.ProductCategory pc
JOIN SalesLT.Product p
ON pc.productcategoryid = p.productcategoryid;

For empty DB, this SQL can be used as starter:

DROP TABLE IF EXISTS [_TestTable_];
CREATE TABLE [_TestTable_] ([Number] int, [Name] nvarchar(100));
INSERT INTO [_TestTable_] ([Number], [Name]) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Carol');
SELECT * FROM [_TestTable_];

Once testing completes, close the Query Editor to prevent consumption of service usage.

Monitor

Go to Overview of the database, you should see the remaining seconds:

It looks like the 329 seconds would be consumed upon creation.

Roughly 15 minutes later, 400 seconds are consumed.

At this rate, 1,600 seconds would be consumed for 1 hour, and 1 day would consume 38,400 seconds, which are more than 1/3 of the quota.

However, it is observed that after around 30 minutes of not using, the database will be Paused state, hence should stop the consumption:

Further assessment found that:

  • Auto-pause delay seems fixed and not editable for the Free tier database.

  • For paid vCore tier database, Auto-pause delay can be adjusted for Development database (not Hyperscale). The minimum delay is 1 hour.

  • Access "Performance Overview" would turn the database Online from Pause status.

Access Metrics and select "Free amount consumed" Metric to monitor the consumption of vCores seconds:

Tips on managing vCore seconds:

  • Disconnect querying tools such as Azure Data Studio and SQL Server Management Studio, including the object explorer, when you're done using them. Leaving connections open may continue to consume credits.

  • On the Metrics tab, create an alert ruleat no cost. Use the Free amount remaining metric to send an alert when the amount is less than 10,000 vCore seconds (10% of the monthly limit), so you know when you're running out for the month.