Azure SQL Serverless Database

You might have a question, i.e., how to stop SQL Azure DB when not in use. It is needed because there is no point in paying for the Azure SQL Database when you are not using it. Now, Azure SQL Database Serverless is the answer to the question of how to stop SQL Azure DB when not in use.

Azure SQL Database Serverless Database

Serverless is essentially a compute tier designed for single databases, allowing you to bill only for the compute used per second. It scales resources based on demand and, most importantly, pauses the database when it’s inactive. You will only be billed for the storage, not the compute, during that time.

The database resumes automatically with the next login or if anyone performs any activity in the database.

Understanding Azure SQL Serverless Architecture

Azure SQL Serverless represents a shift in database models. Unlike traditional provisioned databases, where you pay for constant compute capacity, serverless automatically scales compute resources based on workload demand and bills you only for what you use.

Core Components of Azure SQL Serverless

The serverless architecture consists of several key components that work together to deliver automatic scaling and cost optimization:

  • Auto-scaling Compute: Dynamically adjusts vCores based on workload demands
  • Auto-pause Functionality: Automatically pauses databases during inactive periods
  • Storage Separation: Decouples storage from compute for independent scaling
  • Instant Resume: Quickly resumes paused databases when activity is detected

Key Features Of Serverless Tier

There are a few key features available in the serverless tier. Those are as follows.

Autoscaling Capability

It automatically scales the compute resources based on the workload or demand, which improves the performance.

Best Memory Management

In the case of a serverless database, the memory recovers frequently, which helps to control the cost. Manages memory effectively through cache reclamation and Cache hydration.

Auto-pausing

Auto-pausing is another essential feature of a serverless database. Suppose the system finds the number of sessions to be zero and the CPU usage to be 0 for the user workload running in the user pool. This mainly helps you to control the cost.

Auto-resuming

It resumes the database automatically in a few scenarios, like on the next login, to modify the threat detection settings, to view the auditing records, To add, edit, view sensitivity levels, To add, edit, delete, view data masking rules, To view, modify query store settings, To view or apply performance recommendations, In case of auto-indexing, To export a database, To add the new database tags, etc.

When to Use Azure SQL Serverless

  • Development and Testing Environments
  • Intermittent Workloads
  • Small to Medium Applications
  • Single databases that are not continuous or steady
  • Single database without usage history
  • Single databases that are inactive for a long time, etc.

Scenarios to Avoid

ScenarioReason to AvoidRecommended Alternative
High-frequency OLTPFrequent pause/resume cyclesProvisioned compute
Predictable 24/7 workloadsNo cost benefit from auto-pauseGeneral Purpose tier
Memory-intensive applicationsLimited memory scaling optionsBusiness Critical tier
Applications requiring <1 second responseResume latency considerationsAlways-on provisioned

Setting Up Azure SQL Serverless

Method 1: Azure Portal Configuration

Here’s the complete setup process:

-- Step 1: Create serverless database via T-SQL
CREATE DATABASE [CustomerAnalytics_Dev]
(
    EDITION = 'GeneralPurpose',
    SERVICE_OBJECTIVE = 'GP_S_Gen5_1',
    MAX_SIZE = 100 GB,
    COMPUTE_MODEL = 'Serverless'
);

Portal Configuration Steps:

  1. Navigate to Azure SQL Database creation
  2. Select “Configure database” under Compute + Storage
  3. Choose “Serverless” compute tier
  4. Configure auto-pause settings (1 hour to 7 days)
  5. Set minimum and maximum vCore limits

Check out the screenshots below for your reference.

azure sql serverless database
azure sql serverless

Cost Calculation for a Serverless Database

  1. The first and essential point to note is that when the database is paused, you need to pay for storage, and during that time, you do not need to pay any amount for compute.
  2. In the case of the Serverless Database, the total cost is the addition of the Storage Cost and the Compute Cost.
  3. Remember that the cost calculation for the Compute is based on a few factors. If you have used the compute resources within the minimum and maximum limits, then the cost is based on the vCore and memory you have used. Whereas, if you have used the compute resources below the minimum and more than the maximum, the cost is based on the minimum vCores and minimum memory you have used.
  4. The storage cost, as usual, is based on the storage you use and is payable accordingly.

Cost Optimization Strategies

Understanding Serverless Billing Model

Billing Components:

  • Compute: Billed per second for active usage only
  • Storage: Billed monthly for allocated space
  • Backup: Additional charges for backup storage beyond 100% of the database size

Cost Calculation Formula

-- Serverless cost monitoring query
SELECT 
    start_time,
    end_time,
    avg_cpu_percent,
    avg_data_io_percent,
    avg_log_write_percent,
    max_worker_percent,
    max_session_percent,
    DATEDIFF(second, start_time, end_time) as duration_seconds,
    -- Estimate compute cost (example pricing for East US)
    (DATEDIFF(second, start_time, end_time) / 3600.0) * 0.54 as estimated_hourly_cost
FROM sys.dm_db_resource_stats
WHERE start_time >= DATEADD(hour, -24, GETUTCDATE())
ORDER BY start_time DESC;

Optimization Best Practices

Minimize Cold Starts: Based on my experience with a fintech startup in San Francisco:

-- Keep connections warm with scheduled maintenance
CREATE PROCEDURE sp_KeepServerlessWarm
AS
BEGIN
    -- Lightweight query to prevent auto-pause during business hours
    IF DATEPART(hour, GETDATE()) BETWEEN 8 AND 18
    BEGIN
        SELECT COUNT(*) FROM sys.objects WHERE type = 'U';
        WAITFOR DELAY '00:15:00'; -- 15-minute intervals
    END
END;

Wrapping Up

In this article, we discussed the Azure SQL Database Serverless option. Thanks for reading this article !!

You may also like the following articles.

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!