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.
However, the doc says it is only recommended for testing https://docs.microsoft.com/en-us/azure/private-link/private-endpoint-overview#dns-configuration
- 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.)
It works in both private connection or public connections.
In this method, I will have to use username@servername to connect
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
In https://docs.microsoft.com/en-us/azure/private-link/private-endpoint-overview#dns-configuration, it says we can use private DNS zone or custom DNS server.
-
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)
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.
Updated Jan 15, 2021
Version 5.0Dandan_Zhang
Microsoft
Joined June 17, 2019
Azure Database Support Blog
Follow this blog board to get notified when there's new activity