I am trying to find the replication role of Azure SQL DB (Primary or Secondary).
I used : Get-AzureRmSqlDatabase
command but could not find the replication information.
Is there a different powershell command to find replication role ?
I am trying to find the replication role of Azure SQL DB (Primary or Secondary).
I used : Get-AzureRmSqlDatabase
command but could not find the replication information.
Is there a different powershell command to find replication role ?
you need to use the Get-AzureRmSqlDatabaseReplicationLink
cmdlet. Refer to this article:
https://learn.microsoft.com/en-us/azure/sql-database/scripts/sql-database-setup-geodr-and-failover-database-powershell
$database = New-AzureRmSqlDatabase -ResourceGroupName $primaryresourcegroupname `
-ServerName $primaryservername `
-DatabaseName $databasename -RequestedServiceObjectiveName "S0"
# Establish Active Geo-Replication
$database = Get-AzureRmSqlDatabase -DatabaseName $databasename -ResourceGroupName $primaryresourcegroupname -ServerName $primaryservername
$database | New-AzureRmSqlDatabaseSecondary -PartnerResourceGroupName $secondaryresourcegroupname -PartnerServerName $secondaryservername -AllowConnections "All"
# Initiate a planned failover
$database = Get-AzureRmSqlDatabase -DatabaseName $databasename -ResourceGroupName $secondaryresourcegroupname -ServerName $secondaryservername
$database | Set-AzureRmSqlDatabaseSecondary -PartnerResourceGroupName $primaryresourcegroupname -Failover
# Monitor Geo-Replication config and health after failover
$database = Get-AzureRmSqlDatabase -DatabaseName $databasename -ResourceGroupName $secondaryresourcegroupname -ServerName $secondaryservername
$database | Get-AzureRmSqlDatabaseReplicationLink -PartnerResourceGroupName $primaryresourcegroupname -PartnerServerName $primaryservername
Below is the result of the Azure PowerShell cmdlet above which get the replication role of the geo-replicated Azure SQL Databases.
Note:
The partnerResourceGroupName and resourceGroupName can be the same if the geo-replicated databases and server are in the same resource group as the primary.