
Azure Synapse AnalyticsAuthorCloudBrum editorial teamLast reviewedReading time~12 minLevelBeginner to advanced
Microsoft Azure · Data analytics · Serverless SQL over a data lake
A SQL endpoint over files in your data lake. Synapse bundles several engines, and this page concentrates on the one that matches Amazon Athena: the serverless SQL pool. It reads Parquet, CSV, JSON and Delta files in Azure Data Lake Storage with T-SQL, keeps nothing of its own, and charges by the data it processes. Know the direction of travel before you start. Microsoft now points new analytics projects at Microsoft Fabric, and says existing Synapse workspaces stay supported, so read this page as a guide to running what you have or deciding what to move.
On this page (17 sections)
Mind map: Azure Synapse Analytics at a glance
Free to share. The downloaded image includes the CloudBrum link.
Key features (summary)
- T-SQL over filesEvery Synapse workspace comes with a serverless SQL endpoint. Write a SELECT with OPENROWSET that points at a path in the lake, and it reads the files directly. There’s no cluster to start and nothing to load.
- Pay for data processedThe meter is the data the query processes, at about $5 per terabyte according to the sources we read, rounded up per query with a 10 MB minimum. An idle pool costs nothing.
- Views and external tablesWrap an OPENROWSET query in a view, or create external tables, so analysts and tools such as Power BI see ordinary tables while the files stay in the lake.
- CETAS to write results backCREATE EXTERNAL TABLE AS SELECT runs a query and writes the result as Parquet or CSV to the lake. It’s how you turn raw files into a compact, curated copy.
- Processing limitsSet a daily, weekly and monthly cap, in terabytes, on what the serverless pool may process. Once a cap is used up, new queries are refused until the period rolls over.
- Entra ID and managed identityPeople sign in with Microsoft Entra ID, and the workspace’s managed identity can read the lake through a credential, so no storage keys appear in scripts.
- Beyond serverless SQLThe same workspace can also hold dedicated SQL pools for a classic warehouse, Spark pools for notebooks and data pipelines. They’re billed on their own meters.
- Fabric is the stated directionMicrosoft recommends Microsoft Fabric for new analytics work. Existing Synapse workspaces are supported, and we found no retirement date, but check Microsoft’s lifecycle page for yours.
Basic concepts
- Workspace
- The Synapse resource that groups SQL pools, Spark pools, pipelines and the studio. It’s tied to a default Data Lake Storage Gen2 account and container.
- Serverless SQL pool
- The built-in on-demand SQL endpoint, called Built-in in the studio. It has no provisioned size and bills by data processed.
- Dedicated SQL pool
- A provisioned data warehouse with its own storage, billed per hour for the size you choose. It’s a separate service from the serverless pool.
- OPENROWSET
- A T-SQL function that reads files from storage as if they were a table. You give it a path or wildcard, a format and, if needed, a column list.
- External data source
- A named location in storage, such as a container URL, with the credential used to read it.
- Database scoped credential
- A stored way to authenticate to storage: a managed identity, a shared access signature or the caller’s Entra identity.
- External table
- A table definition over files in the lake. Dropping it doesn’t delete the files.
- CETAS
- CREATE EXTERNAL TABLE AS SELECT. It writes query results to the lake and registers an external table over them.
- filepath() and filename()
- Functions that return parts of the path or the file name of each row, used to prune folders and to find which file a row came from.
- Data processed
- The amount of data a serverless query reads and handles, including any data returned. It’s the billing unit.
- Cost control
- The setting that caps data processed per day, week and month, set in Synapse Studio or with sp_set_data_processed_limit.
- Collation
- The sorting and comparison rules for text. A UTF8 binary collation such as Latin1_General_100_BIN2_UTF8 is recommended for Parquet and gives faster string filtering.
- Delta Lake
- An open table format over Parquet that adds a transaction log. Serverless SQL can read Delta folders.
- Microsoft Fabric
- Microsoft’s unified analytics platform, built on OneLake, that Microsoft recommends for new analytics projects. Its SQL analytics endpoint does a similar job to the serverless pool.
How to create & configure it
Query a data lake with the Azure CLI and T-SQL
- Decide whether Synapse is still the right homeFor a new project, look at Microsoft Fabric first, since that’s where Microsoft is investing. Use Synapse when you already run it, or when a team needs the serverless SQL pool over an existing lake.
- Create the storageMake a storage account with the hierarchical namespace turned on, and a container for the lake. Store data as Parquet under folders such as orders/order_date=2026-10-28/.
- Create the workspaceCreate a Synapse workspace tied to that account and container. Choose Entra-only authentication if your policy allows, and set an Entra administrator.
- Open the network the way you needAdd a firewall rule for your office or build agent, or turn on a managed virtual network and private endpoints if the lake is private.
- Give the workspace access to the lakeGrant the workspace’s managed identity a data role on the storage account: Reader if it only queries, Contributor if it will write with CETAS.
- Create a serverless databaseConnect to the serverless endpoint, create a database with a UTF-8 binary collation, then create the master key, the credential, the data source and the file format.
- Query the filesRun a SELECT with OPENROWSET, using filepath() to filter on the partition folders. Add the columns and types yourself rather than leaving Synapse to infer them.
- Set cost limitsCall sp_set_data_processed_limit for daily, weekly and monthly caps, and check sys.dm_external_data_processed to see usage.
- Materialise what people use mostUse CETAS to write a curated, compressed Parquet copy of the frequently used data, and point views and reports at that.
Tip: synapse serverless works best when the files are Parquet or Delta, partitioned by folder and sized in the hundreds of megabytes. If your lake is mostly CSV, convert it first with CETAS or a Spark job, because every query over CSV pays for every column. See the code references.
Common issues after configuration
| Symptom | Likely cause | What to check / fix |
|---|---|---|
| File cannot be opened because it does not exist or it is used by another process | The path or wildcard is wrong, the caller can’t read the storage, or a writer is still replacing the file | Check the path spelling and the wildcard, confirm the caller or the managed identity has a data role such as Storage Blob Data Reader, and retry after writers finish. |
| Content of directory on path ... cannot be listed | No permission to list the folder, or the firewall of the storage account blocks Synapse | Grant the identity a data role on the account, and allow the workspace through the storage firewall or a private endpoint. |
| Text columns return garbled characters or filters are slow | The database collation isn’t a UTF-8 one, so strings from Parquet are converted | Create the database with COLLATE Latin1_General_100_BIN2_UTF8, or set the collation on the columns in the WITH clause. |
| Bulk load data conversion error for CSV | The delimiter, quote or column count doesn’t match what the query assumes | Set FIELDTERMINATOR, FIELDQUOTE and the header row explicitly, and give the column list in WITH. |
| Queries are slow over many small files | Each file means an extra storage call and planning cost | Compact files into larger Parquet files with CETAS or Spark, and partition on the filter column. |
| A query seems to read the whole lake | The filepath() filter isn’t applied, or the wildcard pattern doesn’t match the folder names | Put a plain comparison on filepath(n) in the WHERE clause, and check data processed in the studio after the run. |
| Query was rejected because the data processed limit was reached | The daily, weekly or monthly cap you set was used up | Check sys.dm_external_data_processed, find the queries that scanned the most, and raise the limit on purpose or wait for the period to roll over. |
| Login failed for a user or an application | The Entra identity has no access to the workspace, or the database user isn’t created | Add the identity as a Synapse role member, create a database user with CREATE USER ... FROM EXTERNAL PROVIDER, and grant permissions. |
| CETAS fails with a permission error on write | The managed identity can read the lake but can’t write to it | Give it Storage Blob Data Contributor on the account or the container, and make sure the target folder doesn’t already contain files. |
| Delta table ... could not be read or old data shows up | The folder isn’t a valid Delta table, or the table has features the serverless engine doesn’t read | Point FORMAT = 'DELTA' at the table’s root folder, and check the Delta protocol version and features used by the writer. |
| Costs are higher than expected | Queries read many columns of CSV or JSON, schema inference reads extra data, or views hide wide scans | Move to Parquet, give column types explicitly, select needed columns only and review the heaviest queries weekly. |
Use cases: when and where to use it
Good fit
- Exploring files in a data lake with plain T-SQL, without running a warehouse
- Giving Power BI and other tools a SQL view over Parquet or Delta files
- Logical data warehouse layers made of views over the lake
- Light transformations that write curated Parquet back with CETAS
- Teams that already live in the Synapse workspace with pipelines, Spark and dedicated pools
- Occasional queries where a per-TB bill is cheaper than keeping a pool running
Consider something else
- New analytics projects on Azure → Microsoft Fabric, which is where Microsoft is building new features
- Many users running fast, repeated queries → a dedicated SQL pool, or a warehouse in Fabric
- Application data and transactions → a database such as Azure SQL Database
- Heavy code-based transformations → Spark in Synapse, Databricks or Fabric notebooks
- The same job on other clouds → compare Amazon Athena and BigQuery
Pros: why consider it?
Why teams choose it
- No cluster, no loading and nothing to pay for while idle
- T-SQL that SQL Server and Power BI teams already know
- Works on open formats in the lake, including Parquet and Delta
- Daily, weekly and monthly processing caps built in
- Views, external tables and CETAS give a logical warehouse layer
- Sits beside Spark pools and pipelines in one workspace
Trade-offs to weigh
- Microsoft recommends Fabric for new work, so Synapse isn’t where new features are headed
- The bill follows data processed, so wide scans over CSV or JSON get expensive
- Limits on concurrency and T-SQL features compared with a full SQL Server
- A cap stops later queries, but it doesn’t stop one that’s already running
- Schema inference and small files can slow and cost more than expected
- Moving to Fabric isn’t automatic, since SQL, Spark and pipelines each need mapping
Common threats, vulnerabilities & risks
| Risk | Severity | Why it matters | Mitigation |
|---|---|---|---|
| A new project built on a service whose strategy has moved | High | You may face a migration sooner than planned, and new features land in Fabric first. | Start new work in Fabric, and keep a plan and an owner for each Synapse workspace you already run. |
| Storage keys or SAS tokens in scripts | High | They leak through repositories and logs, and a SAS token can outlive its purpose. | Use the workspace managed identity and Entra ID, and keep any SAS tokens short-lived. |
| Public workspace and storage endpoints | High | Anyone on the internet can try to sign in, and a misconfigured firewall exposes the lake. | Use a managed virtual network, private endpoints and narrow firewall rules. |
| No processing limits set | Medium | One bad query over a large CSV lake can process many terabytes. | Set daily, weekly and monthly limits and review sys.dm_external_data_processed. |
| Broad data roles for every user | Medium | Everyone who can query can read everything in the lake. | Give access by folder and role, use views as the access surface and grant only what’s needed. |
| Unmanaged CETAS output | Medium | Curated copies pile up with no owner and fall out of date. | Name and tag them, schedule the refresh and delete what nobody uses. |
| Schema inference in production queries | Medium | Types change when the data changes, and extra reads cost money. | Write the column list and types explicitly in WITH. |
| Small files in the lake | Low–Med | Queries slow down and storage calls multiply. | Compact into larger Parquet files regularly. |
| Unclear ownership between Synapse and Fabric | Low–Med | Teams duplicate data and pipelines across the two. | Decide which platform is the source of truth for each dataset and document it. |
Performance optimisation
- Query Parquet or Delta, not CSV. Serverless SQL reads only the columns a query names from columnar files.
- Create the database with a UTF-8 binary collation such as Latin1_General_100_BIN2_UTF8, so string filters can be pushed down.
- Partition by folder and filter with filepath(), so only the matching folders are read.
- Write the column list and types yourself in the WITH clause, and avoid varchar(max) where a short length is enough.
- Keep files large, in the range of hundreds of megabytes, and avoid thousands of tiny ones.
- Create statistics on columns used in joins and filters of heavily used external tables.
- Use CETAS to write a pre-aggregated or filtered copy, and point repeated reports at it.
- Keep the storage account in the same region as the workspace.
Reduce monthly cost
FinOps is the habit of managing cloud spend together with engineering. These are the FinOps checks that matter most for Azure Synapse Analytics.
- Know the meter: data processed, about $5 per TB with a 10 MB minimum per query, rounded up per query.
- Set daily, weekly and monthly limits with sp_set_data_processed_limit, and alarm when usage nears them.
- Convert CSV and JSON to compressed Parquet. It cuts what a query processes by a large factor.
- Select only needed columns, because columns not named in the query aren’t read from Parquet.
- Give explicit schemas so Synapse doesn’t read extra data to infer them.
- Use CETAS for repeated questions, so reports read a small curated copy.
- Don’t forget the other meters in the workspace: dedicated SQL pools, Spark pools, pipeline runs and storage transactions.
- Pause or delete dedicated pools and Spark pools you don’t use.
- Review the top queries by data processed each week with the studio or the DMV.
- Tag the workspace and the storage account by team, and set a budget alert in Cost Management.
The rate here comes from secondary sources as we read them in October 2026, and Microsoft sets prices by region. Check the live pricing page before you plan around them (see Pricing).
Security optimisation
- Sign in with Microsoft Entra ID, prefer Entra-only authentication, and set an Entra group as the workspace administrator.
- Use the workspace managed identity to read the lake, and give it the smallest data role that works.
- Use a managed virtual network and private endpoints, and keep the storage account’s firewall closed to the public internet.
- Grant access to views and schemas rather than raw files, and control row and column access with permissions and security predicates.
- Avoid SAS tokens and account keys, and rotate any you must use.
- Encrypt the workspace and the storage account with Microsoft-managed or customer-managed keys.
- Turn on auditing and send logs to Log Analytics, and alert on failed sign-ins and unusual data processed.
- Use Microsoft Purview to classify and catalogue sensitive columns in the lake.
- Set processing limits so a compromised account can’t run an unlimited bill.
- Review role assignments on the workspace and storage regularly, and use Azure Policy for network and encryption rules.
Governance & compliance
Guardrails
- Tagging rules for workspaces and storage accounts (owner, environment, data class, cost centre) checked at creation
- An Azure Policy that denies workspaces without managed virtual network or with public network access in production
- A shared Bicep or Terraform module for workspaces with Entra-only sign-in, private endpoints and logging already set
- A named owner and a review date for every Synapse workspace, with a plan for each one: keep, move to Fabric or retire
Continuous checks (Azure Policy and Defender for Cloud)
- “Azure Synapse workspaces should use private link”
- “Azure Synapse workspaces should have auditing enabled”
- “Synapse workspaces should use only Microsoft Entra identities for authentication”
- “Storage accounts should restrict network access”
- “Azure Synapse workspaces should use customer-managed keys to encrypt data at rest”
The Azure Activity Log records who created or changed workspaces, SQL auditing records queries and sign-ins, Azure Policy applies the rules above, Defender for Cloud gives recommendations, and Microsoft Purview classifies the data. Microsoft runs the serverless engine and the workspace service, while you own the data in the lake, its layout, the access rules, the processing limits and the plan for the Fabric move.
Reduce carbon footprint
- Process less: Parquet, partitions and selective columns reduce compute for each answer.
- Write curated copies with CETAS so repeated reports don’t re-read raw files.
- Pause dedicated SQL pools and Spark pools when nobody uses them.
- Delete outdated curated copies and scratch folders.
- Compress data, which saves storage and data moved.
- Choose a region with a cleaner grid for batch analysis that isn’t tied to a place, as far as data rules allow.
- The Azure Emissions Impact Dashboard reports a subscription’s footprint. Check how it treats Synapse before you quote a figure.
Pricing
Purchase options
Serverless SQL pool Per TB processed
About $5 per terabyte of data processed according to the sources we read, rounded up per query to the nearest MB, with a 10 MB minimum. Metadata statements are not charged, and nothing is charged while idle.
Dedicated SQL pool Per hour
A provisioned warehouse billed for its size while it runs, plus storage. It’s a separate meter from serverless.
Spark pools and pipelines Per vCore-hour and per activity
Spark pools bill for the cores they use while running, and pipelines bill for orchestration and data movement.
Everything around it Varies
Storage in Data Lake Storage Gen2 and its transactions, private endpoints, Log Analytics and data transfer.
What you actually pay for
- Data processed by every serverless SQL query, rounded up with a 10 MB minimum
- Dedicated SQL pools while they run, and their storage
- Spark pool and pipeline usage in the same workspace
- Data Lake Storage capacity and transactions
- Private endpoints, monitoring and data transfer
Prices differ by region and change over time. The serverless rate above comes from secondary sources, so confirm it. See the official Azure Synapse Analytics pricing page, the Azure pricing calculator and Microsoft's page on cost management for the serverless SQL pool.
Important code references
Order data stored as Parquet in a Data Lake Storage Gen2 container, partitioned by day. The Azure CLI tab creates the storage and the workspace and gives the workspace identity access, then the T-SQL part creates a serverless database, caps data processed, queries the last seven days with OPENROWSET and writes October to a compact table with CETAS. Terraform builds the storage and the workspace. The Python tab runs the query with an Entra token and prints the data processed, and the C# tab runs it with the SQL client. Replace the names, subscription and passwords with your own. A query costs by the data it processes, so start with a single day.
# Placeholders: replace the names, the admin group and the password with your own.
RG=rg-orders-analytics
LOC=centralindia
STORAGE=storordersdlexample
WS=syn-orders-example
ADMIN_GROUP_ID=00000000-0000-0000-0000-000000000000
SQL_ADMIN_PASSWORD='replace-with-a-long-random-password'
az group create --name $RG --location $LOC
# A storage account with the hierarchical namespace (Data Lake Storage Gen2) and one container for the lake.
az storage account create --name $STORAGE --resource-group $RG --location $LOC --sku Standard_LRS --kind StorageV2 \
--enable-hierarchical-namespace true --allow-blob-public-access false --min-tls-version TLS1_2
az storage fs create --name lake --account-name $STORAGE --auth-mode login
# The workspace, tied to that container.
az synapse workspace create --name $WS --resource-group $RG --location $LOC \
--storage-account $STORAGE --file-system lake \
--sql-admin-login-user sqladminuser --sql-admin-login-password "$SQL_ADMIN_PASSWORD"
az synapse workspace firewall-rule create --workspace-name $WS --resource-group $RG --name office --start-ip-address 203.0.113.10 --end-ip-address 203.0.113.10
# Who administers the workspace, and what the workspace identity may do in the lake (read, plus write for CETAS).
az synapse role assignment create --workspace-name $WS --role "Synapse Administrator" --assignee $ADMIN_GROUP_ID
WS_IDENTITY=$(az synapse workspace show --name $WS --resource-group $RG --query identity.principalId -o tsv)
az role assignment create --assignee-object-id $WS_IDENTITY --assignee-principal-type ServicePrincipal \
--role "Storage Blob Data Contributor" --scope $(az storage account show --name $STORAGE --resource-group $RG --query id -o tsv)
# From here on it's T-SQL against the serverless endpoint, with your Entra sign-in (-G).
sqlcmd -S $WS-ondemand.sql.azuresynapse.net -d master -G -b -Q "CREATE DATABASE orders_lake COLLATE Latin1_General_100_BIN2_UTF8"
cat > orders_lake.sql <<'SQL'
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'another-long-random-password';
CREATE DATABASE SCOPED CREDENTIAL lake_identity WITH IDENTITY = 'Managed Identity';
CREATE EXTERNAL DATA SOURCE orders_lake_src WITH (LOCATION = 'https://storordersdlexample.dfs.core.windows.net/lake', CREDENTIAL = lake_identity);
CREATE EXTERNAL FILE FORMAT parquet_ff WITH (FORMAT_TYPE = PARQUET);
GO
-- No more than 1 TB a day, 3 TB a week and 10 TB a month may be processed.
EXEC sp_set_data_processed_limit @type = N'daily', @limit_tb = 1;
EXEC sp_set_data_processed_limit @type = N'weekly', @limit_tb = 3;
EXEC sp_set_data_processed_limit @type = N'monthly', @limit_tb = 10;
GO
-- Revenue per day for the last seven days. filepath(1) is the value of the first * in the path, so only seven folders are read.
SELECT r.filepath(1) AS order_date, COUNT(*) AS orders, ROUND(SUM(r.total), 2) AS revenue
FROM OPENROWSET(BULK 'orders/order_date=*/*.parquet', DATA_SOURCE = 'orders_lake_src', FORMAT = 'PARQUET')
WITH (order_id VARCHAR(40), customer_id VARCHAR(40), total FLOAT, currency CHAR(3), status VARCHAR(20)) AS r
WHERE r.filepath(1) >= CONVERT(VARCHAR(10), DATEADD(day, -7, GETDATE()), 23) AND r.status = 'PAID'
GROUP BY r.filepath(1) ORDER BY r.filepath(1);
GO
-- Compact October into one tidy table.
CREATE SCHEMA curated;
GO
CREATE EXTERNAL TABLE curated.orders_2026_10
WITH (LOCATION = 'curated/orders_2026_10/', DATA_SOURCE = orders_lake_src, FILE_FORMAT = parquet_ff)
AS SELECT r.filepath(1) AS order_date, r.order_id, r.customer_id, r.total, r.status
FROM OPENROWSET(BULK 'orders/order_date=2026-10-*/*.parquet', DATA_SOURCE = 'orders_lake_src', FORMAT = 'PARQUET')
WITH (order_id VARCHAR(40), customer_id VARCHAR(40), total FLOAT, status VARCHAR(20)) AS r;
GO
-- How much has been processed so far this period?
SELECT type, data_processed_mb FROM sys.dm_external_data_processed;
SQL
sqlcmd -S $WS-ondemand.sql.azuresynapse.net -d orders_lake -G -b -i orders_lake.sql
# Placeholders: names are examples, storage account names are global. Pass the admin group in as a variable.
variable "location" {
type = string
default = "centralindia"
}
variable "admin_group_object_id" {
type = string
}
variable "tenant_id" {
type = string
}
resource "azurerm_resource_group" "analytics" {
name = "rg-orders-analytics"
location = var.location
}
resource "azurerm_storage_account" "lake" {
name = "storordersdlexample"
resource_group_name = azurerm_resource_group.analytics.name
location = azurerm_resource_group.analytics.location
account_tier = "Standard"
account_replication_type = "LRS"
account_kind = "StorageV2"
is_hns_enabled = true
min_tls_version = "TLS1_2"
allow_nested_items_to_be_public = false
}
resource "azurerm_storage_data_lake_gen2_filesystem" "lake" {
name = "lake"
storage_account_id = azurerm_storage_account.lake.id
}
resource "azurerm_synapse_workspace" "orders" {
name = "syn-orders-example"
resource_group_name = azurerm_resource_group.analytics.name
location = azurerm_resource_group.analytics.location
storage_data_lake_gen2_filesystem_id = azurerm_storage_data_lake_gen2_filesystem.lake.id
managed_virtual_network_enabled = true
azuread_authentication_only = true
identity {
type = "SystemAssigned"
}
}
resource "azurerm_synapse_workspace_aad_admin" "orders" {
synapse_workspace_id = azurerm_synapse_workspace.orders.id
login = "synapse-admins"
object_id = var.admin_group_object_id
tenant_id = var.tenant_id
}
# The workspace identity reads the lake, and writes to it for CETAS.
resource "azurerm_role_assignment" "workspace_lake" {
scope = azurerm_storage_account.lake.id
role_definition_name = "Storage Blob Data Contributor"
principal_id = azurerm_synapse_workspace.orders.identity[0].principal_id
}
resource "azurerm_synapse_firewall_rule" "office" {
name = "office"
synapse_workspace_id = azurerm_synapse_workspace.orders.id
start_ip_address = "203.0.113.10"
end_ip_address = "203.0.113.10"
}
output "serverless_endpoint" {
value = azurerm_synapse_workspace.orders.connectivity_endpoints["sqlOnDemand"]
}
# Runs a query on the serverless SQL endpoint with an Entra token (no SQL password) and reports data processed.
# pip install pyodbc azure-identity (and the Microsoft ODBC Driver 18 for SQL Server)
import struct
import sys
import pyodbc
from azure.identity import DefaultAzureCredential
ENDPOINT = "syn-orders-example-ondemand.sql.azuresynapse.net"
SQL_COPT_SS_ACCESS_TOKEN = 1256 # the pyodbc attribute that carries an access token
SEVEN_DAYS = """
SELECT r.filepath(1) AS order_date, COUNT(*) AS orders, ROUND(SUM(r.total), 2) AS revenue
FROM OPENROWSET(BULK 'orders/order_date=*/*.parquet', DATA_SOURCE = 'orders_lake_src', FORMAT = 'PARQUET')
WITH (order_id VARCHAR(40), total FLOAT, status VARCHAR(20)) AS r
WHERE r.filepath(1) >= CONVERT(VARCHAR(10), DATEADD(day, -?, GETDATE()), 23) AND r.status = 'PAID'
GROUP BY r.filepath(1) ORDER BY r.filepath(1)
"""
def connect(database="orders_lake"):
token = DefaultAzureCredential().get_token("https://database.windows.net/.default").token.encode("utf-16-le")
packed = struct.pack("=i", len(token)) + token
conn_str = "Driver={ODBC Driver 18 for SQL Server};Server=%s;Database=%s;Encrypt=yes" % (ENDPOINT, database)
return pyodbc.connect(conn_str, attrs_before={SQL_COPT_SS_ACCESS_TOKEN: packed})
def main(days):
with connect() as conn:
cur = conn.cursor()
for order_date, orders, revenue in cur.execute(SEVEN_DAYS, days).fetchall():
print(order_date, orders, revenue)
used = {t: mb for t, mb in cur.execute("SELECT type, data_processed_mb FROM sys.dm_external_data_processed")}
print("processed so far:", ", ".join("%s %s MB" % kv for kv in used.items()))
if __name__ == "__main__":
main(int(sys.argv[1]) if len(sys.argv) > 1 else 7)
// dotnet add package Microsoft.Data.SqlClient
// Runs the seven-day revenue query on the serverless endpoint. "Active Directory Default" uses your Azure CLI,
// Visual Studio or managed identity sign-in, so the connection string holds no password.
using Microsoft.Data.SqlClient;
var connection = new SqlConnectionStringBuilder
{
DataSource = "syn-orders-example-ondemand.sql.azuresynapse.net",
InitialCatalog = "orders_lake",
Authentication = SqlAuthenticationMethod.ActiveDirectoryDefault,
Encrypt = SqlConnectionEncryptOption.Mandatory
}.ConnectionString;
const string sql = @"
SELECT r.filepath(1) AS order_date, COUNT(*) AS orders, ROUND(SUM(r.total), 2) AS revenue
FROM OPENROWSET(BULK 'orders/order_date=*/*.parquet', DATA_SOURCE = 'orders_lake_src', FORMAT = 'PARQUET')
WITH (order_id VARCHAR(40), total FLOAT, status VARCHAR(20)) AS r
WHERE r.filepath(1) >= @since AND r.status = 'PAID'
GROUP BY r.filepath(1) ORDER BY r.filepath(1)";
await using var conn = new SqlConnection(connection);
await conn.OpenAsync();
await using var cmd = new SqlCommand(sql, conn) { CommandTimeout = 120 };
cmd.Parameters.Add("@since", System.Data.SqlDbType.VarChar, 10).Value = DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd");
await using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync())
Console.WriteLine($"{reader.GetString(0)} orders={reader.GetInt32(1),5} revenue={reader.GetDouble(2),12:N2}");
Best videos to explore
Short walkthrough videos for this service are being prepared. They will appear here and load only when you press play. Until then, follow CloudBrum on YouTube for new videos.
Interview questions
BasicWhat is the serverless SQL pool in Azure Synapse?
It’s a built-in, on-demand SQL endpoint in every Synapse workspace. You write T-SQL that reads files such as Parquet, CSV, JSON and Delta from Azure Data Lake Storage with OPENROWSET, and you’re billed for the data the queries process. It has no cluster to size and costs nothing when idle.
BasicHow does serverless SQL pool pricing work?
You pay by the terabyte of data processed, about $5 per TB according to the sources we read, rounded up per query to the nearest MB with a 10 MB minimum. Metadata-only statements aren’t charged. Check Microsoft’s pricing page for your region, and remember storage and other workspace engines are billed separately.
BasicIs Azure Synapse Analytics being retired?
We found no announced retirement date, and Microsoft has said existing workspaces remain supported. Microsoft does recommend Microsoft Fabric for new analytics projects, so new features are landing there. Check Microsoft’s own lifecycle pages for your workspace, and plan the move for estates you intend to keep for years.
IntermediateHow do you stop a serverless SQL query from reading the whole data lake?
Store data as partitioned Parquet or Delta, filter on filepath() with a plain comparison so only matching folders are read, name only the columns you need, and give explicit column types instead of inference. Then set daily, weekly and monthly processing limits with sp_set_data_processed_limit, and check sys.dm_external_data_processed after heavy days.
IntermediateHow does the pool authenticate to storage without keys?
Create a database scoped credential with the identity Managed Identity and use it in an external data source. Then give the workspace’s managed identity a data role such as Storage Blob Data Reader (or Contributor if it writes with CETAS) on the storage account. People sign in with Entra ID, and their own storage rights apply when they use passthrough.
IntermediateWhat does CETAS do and when is it useful?
CREATE EXTERNAL TABLE AS SELECT runs a query and writes the result to the lake as Parquet or CSV, then creates an external table over it. It’s useful for turning raw, wide files into a compact, curated, partitioned copy that reports read instead, which lowers cost and speeds up queries.
AdvancedHow would you cut the bill for a serverless SQL pool that queries a CSV lake?
Convert the CSV to compressed, partitioned Parquet with CETAS or Spark, point views at the new tables, and write column lists with types explicitly. Compact small files, filter on filepath(), set processing limits, and find the heaviest queries from the studio or the DMV every week. Keep reports on curated tables.
AdvancedWhen would you use a dedicated SQL pool instead of serverless?
When many users run fast, repeated queries over modelled data, so you want provisioned compute, distribution and indexing, and a predictable hourly cost. Serverless fits exploration and occasional queries over files. Because Microsoft now recommends Fabric for new warehousing, check whether a Fabric warehouse is the better home for either.
AdvancedHow would you plan a move from Synapse to Microsoft Fabric?
Inventory the workspaces: serverless databases and views, dedicated pools, Spark notebooks, pipelines and the Power BI datasets that depend on them. There’s no automatic path, so map each piece to its Fabric equivalent (lakehouse SQL analytics endpoint, warehouse, notebooks, data pipelines), move the data into OneLake or shortcut to it, run both in parallel and cut over by workload.
AdvancedWhat are the limits of the data processed cap?
The cap blocks new queries once the day, week or month budget is used, but it doesn’t stop a query that is already running, so one huge query can overshoot. It also counts data returned and schema inference reads. Use it as a safety net together with good file layout, query review and alerts, not as the only control.
Similar or alternative services on other clouds
| Capability | AWS | Azure | Google Cloud |
|---|---|---|---|
| Service | Amazon Athena | Azure Synapse Analytics serverless SQL pool, with Microsoft Fabric for new projects | BigQuery, including external tables |
| Where the data lives | Files in Amazon S3 | Files in Data Lake Storage Gen2 or Blob Storage | Native storage, or files in Cloud Storage |
| Query language | Trino-based SQL | T-SQL | GoogleSQL |
| On-demand price | About $5 per TB scanned | About $5 per TB processed | About $6.25 per TiB scanned, first TiB a month free |
| Cost caps | Per-query scan limit in a workgroup | Daily, weekly and monthly data-processed limits | Maximum bytes billed per query |
| Reading files | External tables in the Glue catalog | OPENROWSET, external tables, views | External and BigLake tables |
| Writing results | CTAS and INSERT into Iceberg | CETAS | CREATE TABLE AS SELECT, EXPORT DATA |
| Provisioned option | Provisioned capacity in DPUs | Dedicated SQL pools | Editions with slot reservations |
For a new analytics platform on Azure, look at Microsoft Fabric first. For application data and transactions use a database such as Azure SQL Database. The lake files themselves live in Azure Data Lake Storage, which is built on Azure Blob Storage, and heavy code-based transformations belong in Spark or Databricks.
Did you find this article helpful?
Your answer helps us improve this page for the next reader.
Sources and further reading
CloudBrum wrote this page in its own words, using the provider’s public documentation listed below as the reference. Features, limits, names and prices change, so confirm anything that matters on the provider’s own pages before you decide.
- What is Azure Synapse Analytics?Microsoft
- Serverless SQL pool in Azure Synapse AnalyticsMicrosoft
- Cost management for serverless SQL poolMicrosoft
- Query Parquet files using serverless SQL poolMicrosoft
- Store query results to storage using serverless SQL pool (CETAS)Microsoft
- Control storage account access for serverless SQL poolMicrosoft
- Azure Synapse Analytics pricingMicrosoft
- What is Microsoft Fabric?Microsoft
- Terraform azurerm provider: azurerm_synapse_workspaceHashiCorp
