Read data from Azure Synapse Serverless SQL Pools with Azure Data Factory

We have some data we can query using the serverless SQL pools in Azure Synapse Analytics. For this blog post, I’m querying data that is stored in Azure Cosmos DB. Read the blog post How to Store Normalized SQL Server Data into Azure Cosmos DB to learn more about how that data got there.

Suppose I now want to read the data using Azure Data Factory. You can read data from Cosmos DB directly, but let’s pretend I want to do some transformations first using my favorite language: SQL. How can we do this?

First we need to create a database and a view in the serverless SQL pool. In the Synapse workspace, we can create a new database in the Data tab.

Choose the serverless option and give the database a name.

Next, you create a view on top of the SELECT statement you want to run, using CREATE OR ALTER VIEW.

In Azure Data Factory (ADF), we create a linked service to Azure Synapse.

There’s one problem however: ADF expects dedicated pools and doesn’t display our newly created database in the list.

As a work around, you can type it in yourself:

To make sure ADF can actually connect to the database, we need to add it as a login and user to the serverless pool.

CREATE LOGIN [mssqltips-df]
	FROM EXTERNAL PROVIDER;

CREATE USER [mssqltips-df]
   FROM LOGIN [mssqltips-df];

ALTER ROLE db_datareader ADD MEMBER [mssqltips-df];

To access data, we need to create a dataset. Again, we choose Azure Synapse Analytics as the type.

In the dataset properties, specify a name, choose the linked service we just created and either enter the table name or select it from the dropdown:

Since we’re using a credential in the FROM OPENROWSET clause of the view (to connect to Cosmos DB), we need to give the managed identity permissions to use this credentials, otherwise we get the error “credential has not been found or you do not have permissions to access it” when trying to import the schema.

This can be done with the following SQL statement:

GRANT REFERENCES ON CREDENTIAL::[mssqltips-cosmoslink] TO [mssqltips-df];

Note: in this case I used a server credential, but it’s also possible to use database credentials (which changes the SQL statement slightly). Make sure you are connected to the correct database when executing the statement.

If everything is configured successfully, you can preview the data:

The dataset can now be used in a Copy data activity or in a data flow.


------------------------------------------------
Do you like this blog post? You can thank me by buying me a beer 🙂
Koen Verbeeck

Koen Verbeeck is a Microsoft Business Intelligence consultant at AE, helping clients to get insight in their data. Koen has a comprehensive knowledge of the SQL Server BI stack, with a particular love for Integration Services. He's also a speaker at various conferences.

View Comments

Recent Posts

dataMinds Connect 2025 – Slides & Scripts

You can find all the session materials for the presentation "Indexing for Dummies" that was…

4 days ago

Cloud Data Driven User Group 2025 – Slides & Scripts

The slidedeck and the SQL scripts for the session Indexing for Dummies can be found…

2 weeks ago

Retro Data 2025 – Slidedeck

You can find the slides of my session on the €100 DWH in Azure on…

3 weeks ago

Secure Logic Apps with OAuth Authorization

I've used Logic Apps a couple of times over the past years for simple workflows,…

4 weeks ago

Free Online Sessions – Building the €100 DWH and Indexing for Dummies

I'm giving two online sessions soon on virtual events that are free to attend. The…

1 month ago

How to Install SQL Server 2025 RC0 on an Azure VM

I wanted to try out the new JSON index which is for the moment only…

1 month ago