az sql db replica

Manage replication between databases.

Commands

az sql db replica create

Create a database as a readable secondary replica of an existing database.

az sql db replica delete-link

Permanently stop data replication between two database replicas.

az sql db replica list-links

List the replicas of a database and their replication status.

az sql db replica set-primary

Set the primary replica database by failing over from the current primary replica database.

az sql db replica create

Create a database as a readable secondary replica of an existing database.

A full list of performance level options can be seen by executing az sql db list-editions -a -o table -l LOCATION. The secondary database must have the same edition as the primary database.

az sql db replica create --name
                         --partner-server
                         --resource-group
                         --server
                         [--auto-pause-delay]
                         [--capacity]
                         [--compute-model {Provisioned, Serverless}]
                         [--elastic-pool]
                         [--family]
                         [--license-type {BasePrice, LicenseIncluded}]
                         [--min-capacity]
                         [--no-wait]
                         [--partner-resource-group]
                         [--read-replicas]
                         [--read-scale {Disabled, Enabled}]
                         [--service-objective]
                         [--subscription]
                         [--tags]
                         [--zone-redundant {false, true}]

Examples

Create a database with performance level S0 as a secondary replica of an existing Standard database.

az sql db replica create -g mygroup -s myserver -n originalDb --partner-server newDb --service-objective S0

Create a database with GeneralPurpose edition, Gen4 hardware, and 1 vcore as a secondary replica of an existing GeneralPurpose database

az sql db replica create -g mygroup -s myserver -n originalDb --partner-server newDb -f Gen4 -c 1

Required Parameters

--name -n

Name of the Azure SQL Database.

--partner-server

Name of the server to create the new replica in.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--server -s

Name of the Azure SQL server. You can configure the default using az configure --defaults sql-server=<name>.

Optional Parameters

--auto-pause-delay

Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled.

--capacity -c

The capacity component of the sku in integer number of DTUs or vcores.

--compute-model

The compute model of the database.

accepted values: Provisioned, Serverless
--elastic-pool

The name or resource id of the elastic pool to create the database in.

--family -f

The compute generation component of the sku (for vcore skus only). Allowed values include: Gen4, Gen5.

--license-type

The license type to apply for this database. LicenseIncluded if you need a license, or BasePrice if you have a license and are eligible for the Azure Hybrid Benefit.

accepted values: BasePrice, LicenseIncluded
--min-capacity

Minimal capacity that database will always have allocated, if not paused.

--no-wait

Do not wait for the long-running operation to finish.

--partner-resource-group

Name of the resource group to create the new replica in. If unspecified, defaults to the origin resource group.

--read-replicas

The number of readonly replicas to provision for the database. Only settable for Hyperscale edition.

--read-scale

If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica. This property is only settable for Premium and Business Critical databases.

accepted values: Disabled, Enabled
--service-objective

The service objective for the new database. For example: Basic, S0, P1, GP_Gen4_1, GP_Gen5_S_8, BC_Gen5_2, HS_Gen5_32.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--tags

Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.

--zone-redundant -z

Specifies whether to enable zone redundancy.

accepted values: false, true

Permanently stop data replication between two database replicas.

az sql db replica delete-link --partner-server
                              [--ids]
                              [--name]
                              [--partner-resource-group]
                              [--resource-group]
                              [--server]
                              [--subscription]
                              [--yes]
--partner-server

Name of the server that the other replica is in.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the Azure SQL Database.

--partner-resource-group

Name of the resource group that the other replica is in. If unspecified, defaults to the first database's resource group.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--server -s

Name of the Azure SQL server. You can configure the default using az configure --defaults sql-server=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--yes -y

Do not prompt for confirmation.

List the replicas of a database and their replication status.

az sql db replica list-links [--ids]
                             [--name]
                             [--resource-group]
                             [--server]
                             [--subscription]

List the replicas of a database and their replication status. (autogenerated)

az sql db replica list-links --name MyAzureSQLDatabase --resource-group MyResourceGroup --server myserver
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the Azure SQL Database.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--server -s

Name of the Azure SQL server. You can configure the default using az configure --defaults sql-server=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az sql db replica set-primary

Set the primary replica database by failing over from the current primary replica database.

az sql db replica set-primary [--allow-data-loss]
                              [--ids]
                              [--name]
                              [--resource-group]
                              [--server]
                              [--subscription]

Examples

Set the primary replica database by failing over from the current primary replica database. (autogenerated)

az sql db replica set-primary --allow-data-loss --name MyDatabase --resource-group MyResourceGroup --server myserver --subscription MySubscription

Optional Parameters

--allow-data-loss

If specified, the failover operation will allow data loss.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the database to fail over.

--resource-group -g

Name of the resource group containing the secondary replica that will become the new primary.

--server -s

Name of the server containing the secondary replica that will become the new primary. You can configure the default using az configure --defaults sql-server=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.