Applies to:
Azure SQL Database
This article provides samples to configure and manage an Azure SQL Database Hyperscale named replica.
Create a Hyperscale named replica
The following sample scenarios guide you to create a named replica WideWorldImporters_NamedReplica
for database WideWorldImporters
, using the Azure portal, T-SQL, PowerShell, or Azure CLI.
The following example creates a named replica WideWorldImporters_NamedReplica
for database WideWorldImporters
using T-SQL. The primary replica uses service level objective HS_Gen5_4, while the named replica uses HS_Gen5_2. Both use the same logical server named contosoeast
.
In the Azure portal, browse to the database for which you want to create the named replica.
On the SQL Database page, select your database, scroll to Data management, select Replicas, and then select Create replica.
Choose Named replica under Replica configuration. Select an existing server or create a new server for the named replica. Enter named replica database name and configure the Compute + storage options if necessary.
Optionally, configure a zone redundant Hyperscale named replica. For more information, see Zone redundancy in Azure SQL Database Hyperscale named replicas.
- In the Configure database page, select Yes for Would you like to make this database zone redundant?
- Add at least one High-Availability Secondary Replica to your configuration.
- Select Apply.
Select Review + create, review the information, and then select Create.
The named replica deployment process begins.
When the deployment is complete, the named replica displays its status.
Return to the primary database page, and then select Replicas. Your named replica is listed under Named replicas.
The following example creates a named replica WideWorldImporters_NamedReplica
for database WideWorldImporters
using T-SQL. The primary replica uses service level objective HS_Gen5_4, while the named replica uses HS_Gen5_2. Both use the same logical server named contosoeast
.
ALTER DATABASE [WideWorldImporters]
ADD SECONDARY ON SERVER [contosoeast]
WITH (SERVICE_OBJECTIVE = 'HS_Gen5_2', SECONDARY_TYPE = Named, DATABASE_NAME = [WideWorldImporters_NamedReplica]);
The following example creates a named replica WideWorldImporters_NamedReplica
for database WideWorldImporters
using the PowerShell cmdlet New-AzSqlDatabaseSecondary. The primary replica uses service level objective HS_Gen5_4, while the named replica uses HS_Gen5_2. Both use the same logical server named contosoeast
.
New-AzSqlDatabaseSecondary -ResourceGroupName "MyResourceGroup" -ServerName "contosoeast" -DatabaseName "WideWorldImporters" -PartnerResourceGroupName "MyResourceGroup" -PartnerServerName "contosoeast" -PartnerDatabaseName "WideWorldImporters_NamedReplica" -SecondaryType Named -SecondaryServiceObjectiveName HS_Gen5_2
To configure a zone redundant Hyperscale named replica, you must specify both the -ZoneRedundant
and -HighAvailabilityReplicaCount
input parameters for New-AzSqlDatabaseSecondary
.
New-AzSqlDatabaseSecondary -ResourceGroupName "MyResourceGroup" -ServerName "contosoeast" -DatabaseName "WideWorldImporters" -PartnerResourceGroupName "MyResourceGroup" -PartnerServerName "contosoeast" -PartnerDatabaseName "WideWorldImporters_NamedReplica" -SecondaryType Named -SecondaryServiceObjectiveName HS_Gen5_2 -HighAvailabilityReplicaCount 1 -ZoneRedundant
To validate if named replica is created, use Get-AzSqlDatabase:
Get-AzSqlDatabase -DatabaseName "WideWorldImporters_NamedReplica" -ResourceGroupName "MyResourceGroup" -ServerName "contosoeast"
The following example creates a named replica WideWorldImporters_NamedReplica
for database WideWorldImporters
using the Azure CLI command az sql db replica create. The primary replica uses service level objective HS_Gen5_4, while the named replica uses HS_Gen5_2. Both use the same logical server named contosoeast
.
az sql db replica create -g MyResourceGroup -n WideWorldImporters -s contosoeast --secondary-type named --partner-database WideWorldImporters_NamedReplica --partner-server contosoeast --service-objective HS_Gen5_2
To configure a zone redundant Hyperscale named replica, you must specify both the -zone-redundant
and ha-replicas
input parameters for az sql db replica create
.
az sql db replica create -g MyResourceGroup -n WideWorldImporters -s contosoeast --secondary-type named --partner-database WideWorldImporters_NamedReplica --partner-server contosoeast --service-objective HS_Gen5_2 --ha-replicas 1 -zone-redundant
To validate if a named replica is being created:
az sql db show -g MyResourceGroup -n WideWorldImporters -s contosoeast
As there is no data movement involved, in most cases a named replica will be created in about a minute. Once the named replica is available, it will be visible from the Azure portal or any command-line tool like AZ CLI or PowerShell. A named replica is usable as a regular read-only database.
Connect to a Hyperscale named replica
To connect to a Hyperscale named replica, you must use the connection string for that named replica, referencing its server and database names. There is no need to specify the option ApplicationIntent=ReadOnly
as named replicas are always read-only.
Just like for HA replicas, even though the primary, HA, and named replicas share the same data on the same set of page servers, data caches on each named replica are kept in sync with the primary. The sync is maintained by the transaction log service, which forwards log records from the primary to named replicas. As the result, depending on the workload being processed by a named replica, application of the log records might happen at different speeds, and thus different replicas could have different data latency relative to the primary replica.
Modify a Hyperscale named replica
You can define the service level objective of a named replica when you create it, via the ALTER DATABASE
command or in any other supported way (Portal, AZ CLI, PowerShell). If you need to change the service level objective after the named replica has been created, you can do it using the ALTER DATABASE ... MODIFY
command on the named replica itself.
In the following example, WideWorldImporters_NamedReplica
is the named replica of WideWorldImporters
database.
Open named replica database page, and then select Compute + storage. Update the vCores.
ALTER DATABASE [WideWorldImporters_NamedReplica] MODIFY (SERVICE_OBJECTIVE = 'HS_Gen5_4')
Set-AzSqlDatabase -ResourceGroup "MyResourceGroup" -ServerName "contosoeast" -DatabaseName "WideWorldImporters_NamedReplica" -RequestedServiceObjectiveName "HS_Gen5_4"
az sql db update -g MyResourceGroup -s contosoeast -n WideWorldImporters_NamedReplica --service-objective HS_Gen5_4
Remove a Hyperscale named replica
To remove a Hyperscale named replica, you drop it just like you would a regular database.
Open named replica database page, and choose Delete
option.
Make sure you are connected to the master
database of the server with the named replica you want to drop, and then use the following command:
This command drops a database named WideWorldImporters_NamedReplica
.
DROP DATABASE [WideWorldImporters_NamedReplica];
This command drops a database named WideWorldImporters_NamedReplica
from the logical server contosoeast
.
Remove-AzSqlDatabase -ResourceGroupName "MyResourceGroup" -ServerName "contosoeast" -DatabaseName "WideWorldImporters_NamedReplica"
This command drops a database named WideWorldImporters_NamedReplica
from the logical server contosoeast
.
az sql db delete -g MyResourceGroup -s contosoeast -n WideWorldImporters_NamedReplica
Important
Named replicas will be automatically removed when the primary replica from which they have been created is deleted.