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.

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]
[--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.

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.

--service-objective

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

--subscription

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

--tags

Space-separated tags in 'key[=value]' format. 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]

Required Parameters

--partner-server

Name of the server that the other replica is in.

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--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]

Examples

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

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

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--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). If provided, no other 'Resource Id' arguments should be specified.

--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.