How to use different domain name to connect to Azure SQL Server

This post has been republished via RSS; it originally appeared at: Azure Database Support Blog articles.

There are couple of options available in Azure SQL Server if customer wants to connect with different name. Following option may also apply when customer uses private endpoint. This article applies to SQL DB and not all options works for MI.
 

 1. DNS Alias

Azure SQL DB supports DNS alias as you can see in above doc. However, the created alias will not be the domain format.  It can only be made up of lowercase letters 'a'-'z', the numbers 0-9 and the hyphen. For example, you can only create DNS alias with eeoc instead of eeoc.gov.
When connecting, the alias replaces the first dot-delimited node in the four node server string. For example, we can connect using eeoe.database.windows.net for my original server yxgri1g2pa.database.windows.net
Private endpoint works in this method. I tested with user as username and username@servername and both works for me.
This option will not work for MI.
 

2. Host file

C:\Windows\System32\drivers\etc. Edit Host file using notepad
  • Connection through private endpoint
Update the host file and let it points to the privatelink IP.
Annotation 2020-03-09 111413.png
 
  • Connect through public network
Update the host file and let it points to the SQL Server gateway IP. You can also get the gateway Ip by pinging the server name.
I tested with user as username and username@servername and both works for me.
 

3. Cliconfg

“C:\windows\syswow64\cliconfg.exe” (It has to be the 64bit version if running on 64 bit system. If you are using 32 bit system, you may try with 32 bit version of cliconfg.)
Annotation 2020-03-09 11142.png

It works in both private connection or public connections.
In this method, I will have to use username@servername to connect
 
 

Annotation 2020-03-09 11.png

If I only put the username without the servername, I will get error "Cannot open server "ece.com" requested by the login.  The login failed. (Microsoft SQL Server, Error: 40532)"
 

4. CNAME

Update CNAME record in the DNS server.
 
  • Connect through private endpoint
  • Use a private DNS zone. You can use private DNS zones to override the DNS resolution for a given private endpoint. A private DNS zone can be linked to your virtual network to resolve specific domains.

  • Use your custom DNS server. You can use your own DNS server to override the DNS resolution for a given private link resource. If your DNS server is hosted on a virtual network, you can create a DNS forwarding rule to use a private DNS zone to simplify the configuration for all private link resources. 

With private DNS zone, steps are:
1. Create new private DNS zone.
2. Link VNET that the private endpoint belongs to.
3. Add CNAME record to yxgri1g2pa.privatelink.database.windows.net or yxgri1g2pa.database.windows.net
4. Once this is done, I am able to connect to sql (I have to use username@servername to login. Failed to connect without using @servername)
Annotation 2020-03-09 111415.pngAnnotation 2020-03-09 111417.png
Customer should also be able to use their own DNS server to update the CNAME NAME. But I have not tested this solution.
 
Using DNS server to update CNAME should work for public connections too.

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.