how to connect azure sql with private link using azure data studion connection string

오혜원 41 Reputation points
2022-11-25T02:28:48.77+00:00

hi i am figuring out how to connect azure sql with private link using azure data studio connection string.
azure sql is connected with private endpoint (ip).
i need help about connection string form using ip address.

Azure SQL Database
Azure Private Link
Azure Private Link
An Azure service that provides private connectivity from a virtual network to Azure platform as a service, customer-owned, or Microsoft partner services.
461 questions
{count} votes

2 answers

Sort by: Most helpful
  1. ShaktiSingh-MSFT 13,271 Reputation points Microsoft Employee
    2022-11-29T05:08:31.05+00:00

    Hi @오혜원 ,

    Please try using connection string from the SQL Database in Azure Data Studio like shown below:

    265081-image.png

    Connection string format can be found as shown below:

    265091-image.png

    Try to connect and let us know if you face any issue.

    If this answers your query, do click Accept Answer and Up-Vote for the same. And, if you have any further query do let us know.


  2. TP 75,646 Reputation points
    2022-11-29T15:36:01.167+00:00

    Hi,

    When using private endpoint with Azure SQL Database, you still use the server's public FQDN to connect, so in this way the connection string you use is the same as you would if the server was publicly available. You do not need to use the private ip address in the connection string to connect.

    The reason you can still use the public FQDN when connecting via private link is you typically link an Azure Private DNS Zone to the virtual network and the necessary DNS records for the private ip will be created automatically.

    For example, say you have an Azure SQL Database server named qa-contoso.database.windows.net with private endpoint in your virtual network, with ip address of 10.1.0.4. You connect using VPN, open command prompt, and run nslookup on qa-contoso.database.windows.net:

    265249-azure-sql-database-private-link-dns.jpg

    You can see from above screenshot that DNS lookup for qa-contoso.database.windows.net is returning the correct private ip address (10.1.0.4) which allows you to use the same FQDN in your connection string to connect via private link.

    If you are unable to connect using the server's FQDN then you need to check the DNS configuration of your virtual network and make necessary changes.

    Azure Private Endpoint DNS configuration

    https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-dns

    Alternatively if you are unable to use DNS you can edit your client PC's hosts file and add an entry for your Azure SQL Database server's private ip address. That way Azure Data Studio will be able to resolve the private ip address.

    On Windows PC, the hosts file is located in C:\Windows\System32\Drivers\Etc. You will need admin privileges to edit the file, so browse to C:\Windows, right-click on Notepad and choose Run as admnistrator, then open the file and edit it. Make sure you select All Files in the Open window because the hosts file doesn't have an extension and thus by default won't be shown when you navigate to the folder.

    Below is screenshot of hosts file for above sample database--replace information with your server's FQDN and private ip address.

    265826-azure-sql-private-link-hosts-file.jpg