Let’s create an Azure SQL Database and dedicated SQL Pool DNS (Domain Name System) alias together. This will help you minimize configuration changes anytime you migrate an application or execute a disaster recovery scenario.
Why create Azure SQL Database and dedicated SQL Pool DNS aliases?
To begin, there are a few reasons why I recommend creating a DNS alias for your Azure SQL Database and dedicated SQL Pool:
- In the unlikely scenario of an Azure region outage, having a DNS alias makes it easy to point to a server in another region. It also decreases complexity in your Disaster Recovery scenario (DR).
- In terms of migration: how many times you have been involved in the migration of an application database and had to change connection strings manually? With a DNS alias, you can minimize effort when migration applications.
- In any case where you want to point your application to a different server with minimal changes in configuration.
Surprisingly, most companies (from small to large organizations) don’t create DNS aliases for their servers.
Example Disaster Recovery:
A few things to take into account:
- DNS alias is not available in dedicated SQL Pools created in Synapse Analytics
- DNS alias names are global, same as the Azure SQL logical server.
Create an Azure SQL Database and Dedicated SQL Pool DNS Alias
Next, to create an Azure SQL Database and Synapse SQL Pool DNS alias, you can use PowerShell which takes advantage of Rest APIs. The option to create them in the Azure portal isn’t available. You need to do it programmatically.
The following PowerShell commands are available:
Script to Create Azure SQL Database and Dedicated SQL Pool DNS Alias
I have created the following PowerShell script that allows you to manage your Azure SQL Database and Dedicated SQL pool DNS. With the script you can:
- Create a new DNS alias
- Move an existing DNS alias between servers
- Remove an existing DNS alias
Example Create DNS Alias:
Configure-AzSql-DnsAlias -DnsOperation "Create" -ResourceGroupName "" -ServerName "" -DnsName ""
Example Move DNS Alias:
Configure-AzSql-DnsAlias -DnsOperation "Move" -ResourceGroupName "" -ServerName "" -DnsName "" -SubscriptionName "" -TargetResourceGroupName "" -TargetServerName ""
Example Remove DNS Alias:
Configure-AzSql-DnsAlias -DnsOperation "Remove" -ResourceGroupName "" -ServerName "" -DnsName ""
In summary, I highly recommend creating DNS aliases for your Azure SQL databases and dedicated SQL pools. This provides a lot of great benefits, and the effort is minimal.
You can use the script provided above and prepare your environment for different future scenarios, from database migrations to disaster recovery.
In upcoming blog posts, we’ll continue to explore some of the features within Azure Services.
Please follow Tech Talk Corner on Twitter for blog updates, virtual presentations, and more!
As always, please leave any comments or questions below.