Create Azure SQL Geo-Replication in PowerShell

This article contains some differences from original Microsoft Azure Documentation [link] and describe “How to create Azure SQL Geo-Replication”

First You need connect to Azure Resource Management:

Login-AzureRmAccount

Next You can select correct subscription:

Select-AzureRmSubscription -SubscriptionId 00000000-0000-0000-0000-000000000000

Next scripts create SQL Geo-Replication non-readable database from SourceServerMyDB in SourceReourceGroup (source resource group is case sensitive) to TargetServerMyDB in TargetResourceGroup (can be the same as source).

$db = Get-AzureRmSqlDatabase –DatabaseName “MyDB” -ResourceGroupName “SourceResourceGroup” -ServerName “SourceServer

$secondaryLink = $db | New-AzureRmSqlDatabaseSecondary –PartnerResourceGroupName “TargetResourceGroup“–PartnerServerName “TargetServer” -AllowConnections “no”

You can create Readable replica. Just change -AllowConnection parameter to “yes”.

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.