Blog Post

Azure Database Support Blog
1 MIN READ

Lesson Learned #140: Is it possible to connect from Azure SQL DB to Synapse using External Tables?

Jose_Manuel_Jurado's avatar
Oct 21, 2020

Today, I got a very good question from a customer that they want to connect using Azure SQL DB to several tables of Azure Synapse using External Tables. Following I would like to share what was the lessons learned and how I was able to connect.

 

1) First of all, following I would like to share with you that script that I used to connect to Azure Synapse.

 

 

CREATE DATABASE scoped CREDENTIAL CredentialJM WITH IDENTITY  ='UserNameToConnect'
, SECREt = 'Password'

CREATE EXTERNAL DATA SOURCE [RemoteData] WITH (TYPE = RDBMS, LOCATION = N'servername.database.windows.net', CREDENTIAL = [CredentialJM], DATABASE_NAME = N'databasename')
GO
CREATE EXTERNAL TABLE [dbo].[TableNameSynapse]
([id] [int] NOT NULL)
WITH (DATA_SOURCE = [RemoteData])

 

 

2)  Finally, I was able to run and obtain data from the table TableNameSynapse without issues. 

 

3) Just wanted to comment one thing that it is very important, even if you create a PrivateLink for Synapse server and you specified in the firewall Deny public network access, always the connection will be stablished from the Azure public IP of the machine that is running your Azure SQL Database never with the private IP. Remember that the Private Link is for incoming connection request not outbound connection request. Also, remember that instead opening the Deny public network access you could use Allow Azure services and resources to access this server.

 

Enjoy!

 

Updated Oct 22, 2020
Version 2.0
  • Johannes_Vink's avatar
    Johannes_Vink
    Brass Contributor

    The other way around would be interesting too 😉

     

    Let Azure Synapse SQL-on-demand query Azure SQL DB. So that we can enhance the flat files on blob via SQL-on-demand with some lookup tables stored in Azure SQL DB.