Create replica in new resource group and subscription
Published Jun 03 2020 10:50 AM 3,730 Views
Microsoft

Recently, I worked with a customer who wanted to create a read replica server in a different Azure subscription and resource group. They wanted a disaster recovery strategy that utilized separate "production" and "disaster recovery" subscriptions & resource groups. The below article explains how we can achieve this. 

 

Using the Azure CLI to create a replica in a different resource group

 

We can create a read replica server for an Azure Database for PostgreSQL master using the Azure portalAzure CLI, or REST APITo create a read replica in a different resource group, the Azure portal does not give us that option; however, the Azure CLI does.

 

The following command will help us achieve this:

 

az postgres server replica create -n testreplsvr -g testgroup  -s "/subscriptions/<SubID>/resourceGroups/<ResourceGroup>/providers/Microsoft.DBforPostgreSQL/servers/testsvr2"

 

where:

testreplsvr --> New replica server Name

testgroup --> New Resource Group where your replica server is in

 "/subscriptions/<SubID>/resourceGroups/<ResourceGroup>/providers/Microsoft.DBforPostgreSQL/servers/testsvr2" -->Resource URI for the master server

 

But even with this CLI command, the read replica is still created within the same subscription as the master.

 

 

How to move a replica to a different subscription (and group) 

 

A read replica can be moved to another subscription (and resource group). This is a two step process. First, you create the replica. Then you move it to another subscription. These steps are also used to move a replica to a different resource group.

 

Review the move checklist to confirm you can successfully move the replica. 

 

Move, using the Azure CLI

 

First, create a read replica. For example, create the read replica in your "production" subscription and resource group.

 

az postgres server replica create --subscription <SourceSubID> -n testreplsvr  -g <Source RG> -s "/subscriptions/<SourceSubID>/resourceGroups/<ResourceGroup>/providers/Microsoft.DBforPostgreSQL/servers/testsvr2"

 

Now move the read replica to the destination subscription and group. For example, move the new read replica to your "disaster recovery" subscription and resource group.

 

az resource move --destination-group <Des RG> --ids "/subscriptions/<SourceSubID>/resourceGroups/<ResourceGroup>/providers/Microsoft.DBforPostgreSQL/servers/testsvr2" --destination-subscription-id <DesSUBID>  --subscription <SourceSubID>
  

 

 

Move, using the Azure portal

 

You can also do a move from the Azure portal after the read replica has been created by clicking on change in the read replica's Overview blade.

 

2_Overview_pg.jpg

 

Move, using the Azure REST API

Visit the Azure resource move documentation to learn how to use the REST API for moves, and to review their frequently asked questions (FAQ).

 

 

Hope this information helps

 

Sudheesh Narayanaswamy

Version history
Last update:
‎Jun 06 2020 05:36 PM
Updated by: