Blog Post

Azure Synapse Analytics Blog
8 MIN READ

Synapse Connectivity Series Part #1 - Inbound SQL DW connections on Public Endpoints

FonsecaSergio's avatar
FonsecaSergio
Icon for Microsoft rankMicrosoft
Oct 25, 2022

I will do a series of posts regarding Synapse connectivity. As there are a lot of topics to cover like inbound, outbound, public and private endpoints, managed VNET, managed private endpoints etc., it will be easier to break these into smaller dedicated posts.

 

Find below link for second part of this series

In this first article I would like to explore the SQL DW / Dedicated pool public endpoint connectivity

 

When troubleshooting connection issues, you need to think about what the source is and what is the destination and lot of things in between:

 

 

  • What is the source and what is the destination that you want to reach?
  • Source
    • Are you accessing it from your machine or from Spark notebook running on Synapse Spark pool or from ADF Integration runtime machine (Azure Integration Runtime or Self Hosted IR)?
    • Is your client/VM running OnPrem or Inside Azure (Azure VM / PBI Service / PBI Data gateway)?
    • Do you have a Corp Firewall?
      • What Outbound Ports will be needed?
      • Internet Proxy in the middle?
  • Destination
    • Do you want to use public endpoint or private endpoint?
    • What endpoint you want to reach (Synapse Serverless / Synapse Dedicated Pool / former SQL DW)?
      • SERVERNAME.database.windows.net (Azure SQL DB / Former SQL DW)
      • SERVERNAME.sql.azuresynapse.net (Synapse SQL Dedicated Pool)
      • SERVERNAME-ondemand.sql.azuresynapse.net (Synapse SQL Serverless)

 

Connect to SQL PUBLIC endpoints (Dedicated Pool / Serverless / Former SQL DW)

For this sample we will consider only public endpoints. In a future post, I will speak more about Private endpoints.

 

Reg ports needs it will change depending on the client (Synapse Studio vs SSMS)

 

Find below more details for the 2 processes (Proxy vs Redirect mode)


If you are you coming from Outside Azure (Proxy mode)

 

  • You are going to use Proxy mode by default
    • That means there is a gateway between you and the cluster that is hosting your database
  • You are going to reach a region load balancer using one of the Gateways public IPs on port 1433.
    • These public gateways IPs are documented at https://docs.microsoft.com/en-us/azure/azure-sql/database/connectivity-architecture#gateway-ip-addresses
      • Samples (CR means Control Ring):
        • Name: cr4.westeurope1-a.control.database.windows.net
          Address: 104.40.168.105
        • Name: cr4.westus2-a.control.database.windows.net
          Address: 40.78.240.8
    • You need to make sure you open your corporate firewall to your server region gateways on port 1433
    • These gateways are shared infrastructure and this gateway will communicate with your specific customer DW depending on the connection string + user + password used

 


Are you coming from Inside Azure (Redirect)

 

  • You are going to use Redirect Mode by default
    • Redirect mode is recommended as it's faster when you are connecting directly from the client to the server that is hosting your DW
  • First you reach the one of the Gateways public IPs on port 1433.
  • Then you are redirected to one of the multiple possible Tenant Rings on port 11000-11999 range. Tenant rings are clusters where your DW server lives.

REF: https://docs.microsoft.com/en-us/azure/virtual-network/service-tags-overview

 

 


* If for some reason you cannot use Service Tags, like using 3rd party firewall, the workaround would be to use PowerShell to list all possible IP ranges and then create a process to update your firewall from time-to-time

 

 

 

 

 

$serviceTags = Get-AzNetworkServiceTag -Location westeurope
$SQLserviceTag = $serviceTags.Values | Where-Object Name -Contains "SQL"
$SQLserviceTag.Properties.AddressPrefixes

----------------

$serviceTags = Get-AzNetworkServiceTag -Location westeurope
$SQLserviceTag = $serviceTags.Values | Where-Object Name -Contains "SQL.WestEurope"
$SQLserviceTag.Properties.AddressPrefixes

 

 

 

 

 

You can also get list from Json file at Azure IP Ranges and Service Tags – Public Cloud

 

 

TROUBLESHOOTING

When dealing with connectivity issues the first step is to understand if NAME RESOLUTION is working and PORT is open

 

You can use a Powershell script that does all test and even some additional advanced ones. It can run directly from web, from linux or can be downloaded to run offline

SQL Connectivity Checker Script

This script created by a colleague from Microsoft ( VitorTomaz ). You just need to follow instructions on this GitHub page below and it will validate gateways, ports, test real connection, etc.

https://github.com/Azure/SQL-Connectivity-Checker

 

 

If you cannot run powershell script above because of company policy or just want to check manually there are some commands you can run to test

 

TEST NAME

First you need to know if your client can resolve the name like samples below:

 

  • NSLOOKUP SERVERNAME.database.windows.net
  • NSLOOKUP SERVERNAME.sql.azuresynapse.net
  • NSLOOKUP SERVERNAME-ondemand.sql.azuresynapse.net

*NSLOOKUP command works fine on Windows / MAC / Linux

Sample

 

Server:  dns.google
Address:  8.8.8.8 (What is DNS used? Public / Custom / Azure DNS)
Non-authoritative answer:
Name:    cr4.westeurope1-a.control.database.windows.net (CR4 = Control Ring number 4 from West Eu region)
Address:  104.40.168.105 (Can be found at https://docs.microsoft.com/en-us/azure/azure-sql/database/connectivity-architecture#gateway-ip-addresses)
Aliases:  SERVERNAME.sql.azuresynapse.net
          SERVERNAME.privatelink.sql.azuresynapse.net
          SERVERNAME.database.windows.net
          synapsedataslice1.westeurope.database.windows.net

 

Take a note of what was the DNS used to resolve. Was it Azure DNScompany DNS, or ISP / local dns? Might need to involve your network team to help troubleshoot any issues here if not resolving correctly.

 

Check for all configured DNS servers using something like "IPCONFIG /All". Maybe, one of them is resolving correctly other is not. You can force NSLOOKUP to specific DNS server using

 

 

 

 

 

NSLOOKUP endpoint dnsserver
NSLOOKUP SERVERNAME.sql.azuresynapse.net 8.8.8.8
NSLOOKUP SERVERNAME.sql.azuresynapse.net 8.8.4.4

 

 

 

 

 

Check what is the IP resolved? In this case we want to reach public endpoint, so you can verify if this is one of the documented gateways

 

TEST PORT

You need to have open outbound ports needed to access synapse as documented at https://docs.microsoft.com/en-us/azure/synapse-analytics/security/synapse-workspace-ip-firewall#connect-to-azure-synapse-from-your-own-network

The port will depend on client. Most of them use 1433 (Like SSMS / Power BI) and 11xxx mentioned above (Proxy vs Redirect).

From Synapse Studio as we are using Web APIs requests, so we need ports 443 or 1443

 

You can test port using as sample Powershell command "Test-NetConnection"

  • FORMER SQL DW (Dedicated Pool)
    • Test-NetConnection -Port 1433 -ComputerName SERVERNAME.database.windows.net
    • Test-NetConnection -Port 443 -ComputerName SERVERNAME.database.windows.net
    • Test-NetConnection -Port 1443 -ComputerName SERVERNAME.database.windows.net
  • SYNAPSE WORKSPACE (Dedicated Pool)
    • Test-NetConnection -Port 1433 -ComputerName SERVERNAME.sql.azuresynapse.net
    • Test-NetConnection -Port 443 -ComputerName SERVERNAME.sql.azuresynapse.net
    • Test-NetConnection -Port 1443 -ComputerName SERVERNAME.sql.azuresynapse.net
  • SYNAPSE SERVERLESS
    • Test-NetConnection -Port 1433 -ComputerName SERVERNAME-ondemand.sql.azuresynapse.net
    • Test-NetConnection -Port 443 -ComputerName SERVERNAME-ondemand.sql.azuresynapse.net
    • Test-NetConnection -Port 1443 -ComputerName SERVERNAME-ondemand.sql.azuresynapse.net

Sample results

ComputerName : SERVERNAME.sql.azuresynapse.net
RemoteAddress : 104.40.168.105
RemotePort : 1433
InterfaceAlias : MSFT
SourceAddress : 100.x.x.x
TcpTestSucceeded : True

 

Check

  • TcpTestSucceeded = True?
  • RemoteAddress = 104.40.168.105 = Same IP you got from NSLookup command above? If not equal you might have fixed entry in HOSTs file (C:\Windows\System32\drivers\etc\hosts)

 

*You can also use telnet that works fine in other platforms

 

TROUBLESHOOTING

  • #1 Transient connection

Transient failures are a normal occurrence and should be expected from time to time. They can occur for many reasons such as balance and deployments in the region your server is in, network issues. A transient failure can takes some seconds or minutes, when this takes more time we can look to see if there was a larger underlying reason.

 

You should have a retry logic as a best practice when working with Azure SQL DB / Synapse. Here are more information on the connection recommendations:

 

Troubleshoot transient connection errors in SQL Database and SQL Managed Instance

https://docs.microsoft.com/en-us/azure/azure-sql/database/troubleshoot-common-connectivity-issues

Application development overview - SQL Database & SQL Managed Instance

https://docs.microsoft.com/en-us/azure/azure-sql/database/develop-overview

Troubleshooting connectivity issues and other errors with Azure SQL Database and Azure SQL Managed Instance

https://docs.microsoft.com/en-us/azure/azure-sql/database/troubleshoot-common-errors-issues

 

 

  • #2 A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

 

  • #3 Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=5895; handshake=29;
    • In this scenario you reached the gateway, but could not complete the connection in time
    • Option 1: Client VM CPU is high
    • Option 2: Some appliance in the middle could be with problems slowing down communication
    • Option 3: Need network trace to understand what can be happening at network level (Will speak about this in some other post)

 

  • #4 A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
    • This is usually some issue on client side that caused disconnection
    • Try to check if CPU is not hitting 100%
    • Capture a network trace to check for connection issues (I plan to add later an artile about it)

 

  • #5 Cannot connect to SQL Database: 'tcp:asyp-coyote-dataengineering-dev-ondemand.sql.azuresynapse.net,1433', Database: 'Master', User: 'sqladminuser'. Check the linked service configuration is correct, and make sure the SQL Database firewall allows the integration runtime to access. Login failed for user 'sqladminuser'., SqlErrorNumber=18456,Class=14,State=1,
    • Check if database name is correct
    • Check if user + password is correct
    • Try to connect with SQL Admin to check if problem is your user or something else

 

 

Updated Feb 09, 2024
Version 5.0

6 Comments

  • sajjadali414's avatar
    sajjadali414
    Copper Contributor

    FonsecaSergio  Thank you for the quick response, its still not celar which protocol is used for 1443.

     

    we know that https uses 443 but the question is that which protocol uses 1443?

     

    Thanks

  • sajjadali414's avatar
    sajjadali414
    Copper Contributor

    FonsecaSergio Thank you for the well explained Synapse connectivity series.

     

    I have one question, why are you using port 1443 and what protocol (application layer) is used for 1443?

    as per https://learn.microsoft.com/en-us/azure/synapse-analytics/security/synapse-workspace-ip-firewall#connect-to-azure-synapse-from-your-own-network

     

    Thanks

  • DavidB333 In this case I would say is better to continue investigation because as said transient issues can happen, but not something that is happening every day, every hour

     

    For time, imagine scenario where host that is serving your DW face health issues, high CPU, disk issues, storage throttling, etc... Synapse is build on top of Service Fabric, if it detects that your service is not healthy it will try to self-mitigate issues on machine or in some scenario failover the DW to other healthy host. This can take some minutes. So server downtime is just some minutes, after some retries client will be able to connect again.

     

    If it keeps going down might be some bigger problem and you need to open a support case so we can investigate further

  • DavidB333's avatar
    DavidB333
    Copper Contributor

    FonsecaSergio  You mentioned that transient failures can last minutes.  I'm guessing you are speaking in the context of inbound SQL DW.  Otherwise it seems to me that a connection problem lasting minutes is extreme (unless a VM resource is being cold-started, or is hosted in China or Africa).  There needs to be a reasonable threshold to distinguish between a bug and acceptable transient failures.  

     

    The reason this caught my attention is because I have an open ticket about DNS failures in spark pools.  I don't know if I would call it a "transient" issue, because it is highly reproducible and DNS regularly becomes unavailable for thirty or sixty seconds at a time while a batch job is running.  This seems like a lifetime, for such a fundamental and simple protocol as DNS.  I'm pretty sure there is a bug in the DNS resolver of the underlying ubunto VM's, but we haven't isolated it yet...  In any case, depending on the definition of "transient", and the willingness of Synapse customer's to write code as workaround, this underlying DNS issue might never be fixed!

  • DavidB333's avatar
    DavidB333
    Copper Contributor

    FonsecaSergio Thanks for the blog.

     

    Hopefully you will do more of these connectivity blogs.  We need one that discusses outbound HTTPS from spark-pool-executors to private resources (REST API).  This is virtually an impossible task today, since it involves a very wide assortment of expensive components (load balancer, NAT VM, private link service, etc).  Given how common REST API's are these days, it seems like it should be a priority to allow our Spark pools to reach an API on the private VNET.   Our Spark pools run inside of a "managed vnet", but my understanding is that the configuration is very normal.

     

    I suspect Microsoft has a technology that is supposed to make this easier some day (called "Azure Application Gateway Private Link").  But it is in preview, and I'm told it can take many, many months for the Synapse Analytics workspaces to introduce a compatible MPE, so that we are able to reach out to a new type of private link.