Edit

Share via


New-AzSqlDatabaseSecondary

Creates a secondary database for an existing database and starts data replication.

Syntax

DtuBasedDatabase (Default)

New-AzSqlDatabaseSecondary
    [-DatabaseName] <String>
    [-ServerName] <String>
    [-ResourceGroupName] <String>
    -PartnerResourceGroupName <String>
    -PartnerServerName <String>
    [-SecondaryServiceObjectiveName <String>]
    [-SecondaryElasticPoolName <String>]
    [-Tags <Hashtable>]
    [-PartnerDatabaseName <String>]
    [-AllowConnections <AllowConnections>]
    [-AsJob]
    [-LicenseType <String>]
    [-BackupStorageRedundancy <String>]
    [-SecondaryType <String>]
    [-HighAvailabilityReplicaCount <Int32>]
    [-ZoneRedundant]
    [-AssignIdentity]
    [-EncryptionProtector <String>]
    [-UserAssignedIdentityId <String[]>]
    [-KeyList <String[]>]
    [-FederatedClientId <Guid>]
    [-EncryptionProtectorAutoRotation]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

VcoreBasedDatabase

New-AzSqlDatabaseSecondary
    [-DatabaseName] <String>
    [-ServerName] <String>
    [-ResourceGroupName] <String>
    -PartnerResourceGroupName <String>
    -PartnerServerName <String>
    -SecondaryComputeGeneration <String>
    -SecondaryVCore <Int32>
    [-Tags <Hashtable>]
    [-PartnerDatabaseName <String>]
    [-AllowConnections <AllowConnections>]
    [-AsJob]
    [-SecondaryComputeModel <String>]
    [-LicenseType <String>]
    [-AutoPauseDelayInMinutes <Int32>]
    [-MinimumCapacity <Double>]
    [-BackupStorageRedundancy <String>]
    [-SecondaryType <String>]
    [-HighAvailabilityReplicaCount <Int32>]
    [-ZoneRedundant]
    [-AssignIdentity]
    [-EncryptionProtector <String>]
    [-UserAssignedIdentityId <String[]>]
    [-KeyList <String[]>]
    [-FederatedClientId <Guid>]
    [-EncryptionProtectorAutoRotation]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The New-AzSqlDatabaseSecondary cmdlet replaces the Start-AzSqlDatabaseCopy cmdlet when used for setting up geo-replication for a database. It returns the geo-replication link object from the primary to the secondary database.

Examples

Example 1: Establish Active Geo-Replication

$database = Get-AzSqlDatabase -DatabaseName $databasename -ResourceGroupName $primaryresourcegroupname -ServerName $primaryservername
$database | New-AzSqlDatabaseSecondary -PartnerResourceGroupName $secondaryresourcegroupname -PartnerServerName $secondaryservername -AllowConnections "All"

Example 2: Establish Active Geo-Replication and specify the partner database name to be different than the source database name

$database = Get-AzSqlDatabase -DatabaseName $databasename -ResourceGroupName $primaryresourcegroupname -ServerName $primaryservername
$database | New-AzSqlDatabaseSecondary -PartnerResourceGroupName $secondaryresourcegroupname -PartnerServerName $secondaryservername -PartnerDatabaseName $secondarydatabasename -AllowConnections "All"

Parameters

-AllowConnections

Specifies the read intent of the secondary Azure SQL Database. The acceptable values for this parameter are:

  • No
  • All

Parameter properties

Type:AllowConnections
Default value:None
Accepted values:No, All
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AsJob

Run cmdlet in the background

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AssignIdentity

Generate and assign a Microsoft Entra identity for this database for use with key management services like Azure KeyVault.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AutoPauseDelayInMinutes

The auto pause delay in minutes for database(serverless only), -1 to opt out

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-BackupStorageRedundancy

The Backup storage redundancy used to store backups for the SQL Database. Options are: Local, Zone and Geo.

Parameter properties

Type:String
Default value:None
Accepted values:Local, Zone, Geo, GeoZone
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DatabaseName

Specifies the name of the database to act as primary.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-EncryptionProtector

The encryption protector key for SQL Database copy.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-EncryptionProtectorAutoRotation

The AKV Key Auto Rotation status

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-FederatedClientId

The federated client id for the SQL Database. It is used for cross tenant CMK scenario.

Parameter properties

Type:

Nullable<T>[Guid]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-HighAvailabilityReplicaCount

The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed. This property is only settable for Hyperscale edition databases.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-KeyList

The list of AKV keys for the SQL Database copy.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-LicenseType

The license type for the Azure Sql database.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MinimumCapacity

The Minimal capacity that the secondary database will always have allocated, if not paused. For serverless Azure Sql databases only.

Parameter properties

Type:Double
Default value:None
Supports wildcards:False
DontShow:False
Aliases:MinVCore, MinCapacity

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PartnerDatabaseName

The name of the secondary database to create.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PartnerResourceGroupName

Specifies the name of the Azure Resource Group to which this cmdlet assigns the secondary database.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PartnerServerName

Specifies the name of the Azure SQL database server to act as secondary.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PartnerSubscriptionId

Specifies the subscription of the Azure SQL database server if it is different from the source.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

Specifies the name of the Azure Resource Group to which this cmdlet assigns the primary database.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-SecondaryComputeGeneration

The compute generation of the Azure Sql Database secondary.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Family

Parameter sets

VcoreBasedDatabase
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SecondaryComputeModel

The compute model for Azure Sql database secondary. Serverless or Provisioned

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

VcoreBasedDatabase
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SecondaryElasticPoolName

Specifies the name of the elastic pool in which to put the secondary database.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

DtuBasedDatabase
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SecondaryServiceObjectiveName

Specifies the name of the service objective to assign to the secondary database.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

DtuBasedDatabase
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SecondaryType

The secondary type of the database if it is a secondary. Valid values are Geo, Named and Standby.

Parameter properties

Type:String
Default value:None
Accepted values:Named, Geo, Standby
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SecondaryVCore

The Vcore numbers of the Azure Sql Database secondary.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Capacity

Parameter sets

VcoreBasedDatabase
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ServerName

Specifies the name of the SQL Server of the primary SQL Database.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Tags

Specifies the Key-value pairs in the form of a hash table to associate with the SQL Database replication link. For example: @{key0="value0";key1=$null;key2="value2"}

Parameter properties

Type:Hashtable
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Tag

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-UserAssignedIdentityId

The list of user assigned identity for the SQL Database copy.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ZoneRedundant

The zone redundancy to associate with the Azure Sql Database. This property is only settable for Hyperscale edition databases.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

Outputs

AzureReplicationLinkModel