%3CLINGO-SUB%20id%3D%22lingo-sub-1806863%22%20slang%3D%22en-US%22%3ERe%3A%20Lesson%20Learned%20%23140%3A%20Is%20it%20possible%20to%20connect%20from%20Azure%20SQL%20DB%20to%20Synapse%20using%20External%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1806863%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20other%20way%20around%20would%20be%20interesting%20too%20%3B)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20Azure%20Synapse%20SQL-on-demand%20query%20Azure%20SQL%20DB.%20So%20that%20we%20can%20enhance%20the%20flat%20files%20on%20blob%20via%20SQL-on-demand%20with%20some%20lookup%20tables%20stored%20in%20Azure%20SQL%20DB.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1806320%22%20slang%3D%22en-US%22%3ELesson%20Learned%20%23140%3A%20Is%20it%20possible%20to%20connect%20from%20Azure%20SQL%20DB%20to%20Synapse%20using%20External%20Tables%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1806320%22%20slang%3D%22en-US%22%3E%3CP%3EToday%2C%20I%20got%20a%20very%20good%20question%20from%20a%20customer%20that%20they%20want%20to%20connect%20using%20Azure%20SQL%20DB%20to%20several%20tables%20of%20Azure%20Synapse%20using%20External%20Tables.%20Following%20I%20would%20like%20to%20share%20what%20was%20the%20lessons%20learned%20and%20how%20I%20was%20able%20to%20connect.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1)%20First%20of%20all%2C%20following%20I%20would%20like%20to%20share%20with%20you%20that%20script%20that%20I%20used%20to%20connect%20to%20Azure%20Synapse.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3ECREATE%20DATABASE%20scoped%20CREDENTIAL%20CredentialJM%20WITH%20IDENTITY%20%20%3D'UserNameToConnect'%0A%2C%20SECREt%20%3D%20'Password'%0A%0ACREATE%20EXTERNAL%20DATA%20SOURCE%20%5BRemoteData%5D%20WITH%20(TYPE%20%3D%20RDBMS%2C%20LOCATION%20%3D%20N'servername.database.windows.net'%2C%20CREDENTIAL%20%3D%20%5BCredentialJM%5D%2C%20DATABASE_NAME%20%3D%20N'databasename')%0AGO%0ACREATE%20EXTERNAL%20TABLE%20%5Bdbo%5D.%5BTableNameSynapse%5D%0A(%5Bid%5D%20%5Bint%5D%20NOT%20NULL)%0AWITH%20(DATA_SOURCE%20%3D%20%5BRemoteData%5D)%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2)%26nbsp%3B%20Finally%2C%20I%20was%20able%20to%20run%20and%20obtain%20data%20from%20the%20table%20TableNameSynapse%20without%20issues.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E3)%20Just%20wanted%20to%20comment%20one%20thing%20that%20it%20is%20very%20important%2C%20even%20if%20you%20create%20a%20PrivateLink%20for%20Synapse%20server%20and%20you%20specified%20in%20the%20firewall%20Deny%20public%20network%20access%2C%20always%20the%20connection%20will%20be%20stablished%20from%20the%20Azure%20public%20IP%20of%20the%20machine%20that%20is%20running%20your%20Azure%20SQL%20Database%20never%20with%20the%20private%20IP.%20Remember%20that%20the%20Private%20Link%20is%20for%20incoming%20connection%20request%20not%20outbound%20connection%20request.%20Also%2C%20remember%20that%20instead%20opening%20the%20Deny%20public%20network%20access%20you%20could%20use%20%3CSPAN%3EAllow%20Azure%20services%20and%20resources%20to%20access%20this%20server.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEnjoy!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1806320%22%20slang%3D%22en-US%22%3E%3CP%3EToday%2C%20I%20got%20a%20very%20good%20question%20from%20a%20customer%20that%20they%20want%20to%20connect%20using%20Azure%20SQL%20DB%20to%20several%20tables%20of%20Azure%20Synapse%20using%20External%20Tables.%20Following%20I%20would%20like%20to%20share%20what%20was%20the%20lessons%20learned%20and%20how%20I%20was%20able%20to%20connect.%3C%2FP%3E%3C%2FLINGO-TEASER%3E

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!

 

1 Comment
Senior Member

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.