1
votes

I created an Azure SQL Database and configured geo-replication to a second server in a different region. In the Azure Portal, I can click on either of the databases, and see details about the regions being replicated to:

Azure Portal Screenshot

I want to use PowerShell to find this same information, but cannot find a cmdlet or property that exposes this information:

# Get database object
$database = Get-AzSqlDatabase -ResourceGroupName test-rg -ServerName testsql-eastus -DatabaseName TestDB

# Find if geo-replication is enabled?

The goal is to be able to pull all SQL databases in a subscription, and take different action on them depending if they have geo-replication enabled.

1
Hi @MaddHatter, If my answer is helpful for you, hope you can accept it as answer. This can be beneficial to other community members. Thank you.Leon Yue
do you have any other concerns?Leon Yue

1 Answers

0
votes

Please ref these document Get-AzSqlDatabaseFailoverGroup:

  • Gets a specific Azure SQL Database Failover Group or lists the Failover Groups on a server. Either server in the Failover Group may be used to execute the command. The returned values will reflect the state of the specified server with respect to the Failover Group.

Example: enter image description here

You can run Get-AzSqlDatabaseFailoverGroup -ResourceGroupName 'rg' -ServerName 'servername' to see if the databases in the Azure SQL server has configured geo-replication. If no failovergroup name return, then the database didn't enable the geo-replication.