Microsoft Azure · Data

Azure SQL Database

Azure SQL Database is SQL Server as a fully managed service: backups, patching and high availability are handled for you.

Intermediate 5 min Lesson 11 of 28
0/28 in Microsoft Azure
On this page · 5 min · Intermediate

Learning objectives#

  • Create a logical server and database
  • Choose serverless or provisioned compute
  • Secure access with firewall rules and Entra ID
  • Connect from an ASP.NET Core app

Explanation#

You create a logical server (a connection endpoint and security boundary) and one or more databases on it.

Purchasing models: DTU (simple bundles) and vCore (choose CPU and memory). The serverless vCore tier auto-pauses when idle — ideal for dev and low-traffic apps.

Networking: by default no one can connect. Add firewall rules for specific IPs, allow Azure services, or use private endpoints for the most secure setup.

Prefer Microsoft Entra authentication (and managed identities for apps) over SQL logins with passwords.

Code example: A serverless dev database#

ShellA serverless dev database Illustrative
az sql server create -n sql-shop-dev -g rg-shop-dev -l centralindia \
  --enable-ad-only-auth --external-admin-principal-type User \
  --external-admin-name asha@example.com --external-admin-sid <object-id>


az sql db create -n shopdb -s sql-shop-dev -g rg-shop-dev \
  --edition GeneralPurpose --family Gen5 --capacity 2 \
  --compute-model Serverless --auto-pause-delay 60


az sql server firewall-rule create -g rg-shop-dev -s sql-shop-dev \
  -n my-laptop --start-ip-address <your-ip> --end-ip-address <your-ip>


# appsettings: Server=tcp:sql-shop-dev.database.windows.net;Database=shopdb;
#              Authentication=Active Directory Default;Encrypt=True;
Expected output
The database is online. With the connection string above, EF Core or SqlClient authenticates with your Azure sign-in locally and with managed identity in App Service.

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. The server uses Entra-only authentication — no SQL passwords exist.
  2. Serverless General Purpose with 2 vCores auto-pauses after 60 minutes idle.
  3. A firewall rule allows only your IP.
  4. “Active Directory Default” in the connection string uses DefaultAzureCredential behind the scenes.

Real-world use case#

The ShopDB from the SQL Server track runs unchanged on Azure SQL; the ASP.NET Core API connects with its managed identity.

Common mistakes#

Allowing 0.0.0.0–255.255.255.255

That opens the database to the whole internet. Allow specific IPs or use private endpoints.

Forgetting auto-pause wake-up time

The first query after a pause takes longer. Use provisioned compute for latency-sensitive production apps.

Best practices#

  • Use Entra-only authentication and managed identity
  • Use private endpoints in production
  • Use serverless for dev/test
  • Test point-in-time restore before you need it

Remember this#

Logical server = endpoint + security boundary. Databases live on it.

Serverless pauses when idle → cheap dev databases.

No passwords: Entra ID + managed identity.

Practice exercise#

Your task: Restore shopdb to how it was one hour ago as a new database called shopdb-restored.

Show solution
Shell Illustrative
az sql db restore -g rg-shop-dev -s sql-shop-dev -n shopdb --dest-name shopdb-restored --time "<UTC time one hour ago, e.g. 2026-10-29T09:00:00Z>"

Mini quiz#

Azure SQL Database quizMultiple choice Question 1 of 1

Which compute model auto-pauses an idle database?

Score so far: 0/0

Want more? Practise all Microsoft Azure MCQs · Microsoft Azure interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.