
You create your first Azure SQL database, copy the connection string into your tool, press connect, and get this:
Cannot open server 'myserver' requested by the login.
Client with IP address '203.0.113.10' is not allowed to access the server.
Nothing is wrong with your password. You have just met the first of several ways Azure SQL Database differs from the SQL Server you may have run on your own machine: it sits behind a firewall that denies everyone until you say otherwise.
Azure SQL Database is the SQL Server engine, run for you by Microsoft. The engine is familiar. The things around it (how you connect, how you pay, what is missing, what is automatic) are new, and they are what this guide is about.
What Azure SQL Database is
Azure SQL Database is a managed relational database. Microsoft runs the servers, applies patches, takes backups and keeps a standby ready. You get a database endpoint and T-SQL, the SQL Server dialect.
"Azure SQL" is a family of three products, and people mix them up:
| Product | What you get | Choose it when |
|---|---|---|
| Azure SQL Database | A single database (or a pool of them), fully managed | You are building a new cloud application |
| Azure SQL Managed Instance | A whole managed SQL Server instance, with SQL Agent and cross-database queries | You are moving an existing SQL Server estate with few changes |
| SQL Server on Azure VMs | A virtual machine you manage yourself | You need full control of the operating system or an old version |
This guide is about the first one.
Each database belongs to a logical server, a name such as myserver.database.windows.net. It is not a machine. It is a management point that holds logins, firewall rules and a group of databases.
Why teams choose it
- The SQL Server engine without the upkeep. Patching, backups and high availability are handled for you.
- It is always on the current engine. There are no version upgrades to plan.
- Backups with point-in-time restore. You can restore to any moment within the retention period, seven days by default and up to 35.
- It tunes itself, if you let it. Query Store records how every query performs, and automatic tuning can fix plan regressions and manage indexes.
- It fits the Microsoft stack. .NET, Power BI, Microsoft Entra ID (the new name for Azure Active Directory) and the rest of Azure connect with little effort.
- Flexible sizing. You can scale a database up or down with one statement, or let a serverless database scale and pause on its own.
Where it fits, and where it does not
A strong choice for:
- New line-of-business and web applications on Azure
- Teams with SQL Server skills and .NET code
- Software-as-a-service products with one database per customer (elastic pools were made for this)
- Development and test databases that are idle most of the day (serverless)
Look elsewhere when:
- You are lifting an existing SQL Server with SQL Agent jobs, linked servers and cross-database queries. Managed Instance supports those; SQL Database does not.
- Your stack is open source or on another cloud. PostgreSQL or MySQL, managed by your own cloud provider, avoids licence cost and cross-cloud traffic.
- You need a warehouse for very large analytics. Look at a column store such as Snowflake, BigQuery or Microsoft's own analytics services.
- You need writes accepted in several regions at once. Azure SQL has one writable primary. A distributed SQL database such as CockroachDB is built for that.
What is different from SQL Server
- You connect to one database.
USE otherdb;does not switch databases. Open a new connection instead. - No SQL Server Agent. Schedule work with elastic jobs, Azure Automation or your application.
- No
BACKUPandRESTOREstatements. Backups are automatic, and restores are done from the portal or the command line. - Queries across databases need extra setup. Three-part names such as
otherdb.dbo.ordersdo not work out of the box. - Snapshot-based reads are on by default. Readers do not block writers, unlike a default SQL Server installation.
- Connections are always encrypted.
Using it the right way
Open the firewall narrowly
Add a rule for the address you connect from, and nothing wider:
az sql server firewall-rule create \
--resource-group shop-rg --server myserver \
--name office \
--start-ip-address 203.0.113.10 --end-ip-address 203.0.113.10
Be careful with the setting called "Allow Azure services and resources to access this server". It admits traffic from any Azure customer's resources, not only yours. For applications inside Azure, a private endpoint or a virtual network rule is tighter.
Create users inside the database
Do not hand the server admin login to an application. Create a contained user, one that lives in the database itself, and connect to that database directly:
CREATE USER shop_app WITH PASSWORD = 'use-a-long-random-one';
ALTER ROLE db_datareader ADD MEMBER shop_app;
ALTER ROLE db_datawriter ADD MEMBER shop_app;
For people, and for applications running in Azure, prefer Microsoft Entra identities, which carry no password in a config file:
CREATE USER [reporting-team] FROM EXTERNAL PROVIDER;
ALTER ROLE db_datareader ADD MEMBER [reporting-team];
Use a correct connection string, and retry
Server=tcp:myserver.database.windows.net,1433;Initial Catalog=shop;User ID=shop_app;Password=...;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
Keep TrustServerCertificate=False so the client checks the server's certificate.
A managed database moves between machines during maintenance and scaling. For a few seconds, connections drop or are refused. These are called transient faults, and every application must retry them with a short, growing delay. Modern Microsoft drivers and Entity Framework have this built in, but you often have to switch it on.
Watch resource use
A database has a ceiling set by its size. This view shows how close you are, in 15-second samples for about the last hour:
SELECT TOP 20 end_time, avg_cpu_percent, avg_data_io_percent,
avg_log_write_percent, avg_memory_usage_percent
FROM sys.dm_db_resource_stats
ORDER BY end_time DESC;
If one of these sits near 100, queries are being throttled. Before you pay for a bigger size, find out which query is responsible.
Let Query Store name the culprit
Query Store is on by default and keeps a history of every query's cost:
SELECT TOP 10
qt.query_sql_text,
SUM(rs.count_executions) AS executions,
SUM(rs.avg_duration * rs.count_executions) / 1000.0 AS total_ms
FROM sys.query_store_query_text AS qt
JOIN sys.query_store_query AS q ON q.query_text_id = qt.query_text_id
JOIN sys.query_store_plan AS p ON p.query_id = q.query_id
JOIN sys.query_store_runtime_stats AS rs ON rs.plan_id = p.plan_id
GROUP BY qt.query_sql_text
ORDER BY total_ms DESC;
One missing index is often the whole difference between "we need the next tier" and "we are fine". You can also let the database correct plan regressions on its own:
ALTER DATABASE CURRENT
SET AUTOMATIC_TUNING (FORCE_LAST_GOOD_PLAN = ON);
Scale with a statement
SELECT DATABASEPROPERTYEX(DB_NAME(), 'ServiceObjective') AS current_size;
ALTER DATABASE [shop] MODIFY (SERVICE_OBJECTIVE = 'S2');
The change happens online, with a brief disconnect at the end, which your retry logic absorbs.
Practise a restore
az sql db restore \
--resource-group shop-rg --server myserver --name shop \
--dest-name shop_restored --time "2026-03-01T09:00:00Z"
A point-in-time restore always creates a new database beside the original. You then copy back what you need or switch the application over. Do it once before you need it.
How the pricing shapes your choices
There are two purchasing models.
DTU bundles CPU, memory and I/O into one number, in Basic, Standard and Premium tiers. It is simple and suits small, steady databases.
vCore lets you choose cores and storage separately, in General Purpose, Business Critical and Hyperscale tiers. It costs more thought, offers more control, and lets you apply SQL Server licences you already own.
Within vCore, compute is either provisioned (a fixed size, billed for every hour whether used or not) or serverless. A serverless database scales between a minimum and maximum you set and is billed for the compute it actually uses. After a period with no activity it can pause, and while paused you pay only for storage.
What follows from this:
- Idle databases belong on serverless. Development, test and internal tools pay for the hours they work. The catch is that the first connection after a pause takes a while and may fail once, so retries matter even more.
- Busy databases belong on provisioned. A database that never sleeps costs more on serverless, and a reserved commitment lowers a provisioned bill.
- Many small databases belong in an elastic pool. The pool shares one set of resources, so you pay for the combined peak, not for each database's peak.
- Storage, backup storage beyond the included amount and long-term retention are billed separately.
- Tune before you scale. A larger tier is the most expensive index you can buy.
Common mistakes
- Opening the firewall to
0.0.0.0through255.255.255.255. The database is then one leaked password away from the whole internet. - Using the server admin login in the application. Create a contained user with only the roles it needs.
- No retry logic. Brief disconnects during maintenance become user-facing errors.
- A production API on serverless with auto-pause. The first request after a quiet night waits for the database to wake.
- Scaling up to hide a bad query. Check Query Store first.
- Expecting SQL Agent,
USEor cross-database queries. Those belong to Managed Instance. - Never testing a restore. Automatic backups only help if you know the steps.
- Keeping every database in one region. For a regional outage you need geo-replication or a failover group.
Quick reference
| Task | Command |
|---|---|
| Engine and edition | SELECT @@VERSION; |
| Current service objective | SELECT DATABASEPROPERTYEX(DB_NAME(), 'ServiceObjective'); |
| Recent resource use | SELECT * FROM sys.dm_db_resource_stats; |
| Running requests | SELECT session_id, status, command, wait_type, total_elapsed_time FROM sys.dm_exec_requests; |
| End a session | KILL 72; |
| Database firewall rules | SELECT * FROM sys.database_firewall_rules; |
| Add a database firewall rule | EXECUTE sp_set_database_firewall_rule N'office', '203.0.113.10', '203.0.113.10'; |
| Users and roles | SELECT name, type_desc FROM sys.database_principals; |
| Space used | EXEC sp_spaceused; |
| Allow monitoring views | GRANT VIEW DATABASE STATE TO shop_app; |
Azure SQL Database takes the server chores away and leaves you three jobs: guard the door, pick the pricing shape that matches your traffic, and keep an eye on the queries.
Exploring Azure SQL with CreamDB
SQL Server Management Studio runs only on Windows. CreamDB opens an Azure SQL database from a browser tab on any device.
- Connect with the server name, port 1433, a database user and password, and the database name. The connection is always encrypted and the server's certificate is checked. Sign-in is by SQL username and password; Microsoft Entra sign-in is not offered.
- Browse schemas, tables, views, procedures and functions in a tree, with columns, indexes, triggers and definitions. Open a table in a grid where paging, sorting and filtering run in the database.
- Write T-SQL in an editor with autocomplete, formatting and history, and export results to CSV, JSON or Excel.
- Watch sessions in the Status panel (the user needs
VIEW DATABASE STATE) and read users and roles on a read-only page. - Ask in plain English and get the SQL, a result table and a chart. The assistant only reads on its own, and any change waits for your approval.
CreamDB is hosted, so the server's firewall must allow public connections; a database reachable only through a private endpoint cannot be opened. It is free to start.
About the author
- CreamDB is a web-based database explorer with an AI assistant. Connect your databases, ask questions in plain English and get answers, tables and charts from any browser. Product news and tips here.
Comments
Join the discussionNo comments yet. Be the first to comment.




