Step-by-step: create a read replica in different subscription and resource group

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

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 by utilizing separate "production" and "disaster recovery" subscriptions & resource groups. The below article explains how we can achieve this. 

 

We can create a read replica server for an Azure Database for MySQL master using the Azure portal, Azure CLI, or REST API.

 

When creating a read replica from the Azure portal, we get options to select the server name, location, and pricing tier. 

1_replcia.jpg

 

Now, if we want to create a read replica in a different resource group, the Azure portal does not give us that option; however, Azure CLI does.

 

The following will help us achieve this.

 

 

 

 

az mysql server replica create -n testreplsvr -g testgroup  -s "/subscriptions/${SubID}/resourceGroups/${ResourceGroup}/providers/Microsoft.DBforMySQL/servers/testsvr2"

 

 

 

 

where:

testreplsvr --> New replica server Name

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

/subscriptions/${SubID}/resourceGroups/${ResourceGroup}/providers/Microsoft.DBforMySQL/servers/testsvr2 -->Resource Uri for your master server.

 

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

 

How can we do this for a different subscription? For this we can take a two step process

 

Create a read replica in source group

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

 

 

 

az mysql server replica create --subscription <SourceSubID> -n testreplsvr  -g <Source RG> -s /subscriptions/<SourceSubID>/resourceGroups/${ResourceGroup}/providers/Microsoft.DBforMySQL/servers/testsvr2 "

 

 

 

 

Move the read replica to destination subscription

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.DBforMySQL/servers/testsvr2" --destination-subscription-id <DesSUBID>  --subscription <SourceSubID>

 

 

 

 

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

2_Overview.jpg

 

Hope this information helps.

 

Sudheesh Narayanaswamy

Technical Support Engineer

 

 

 

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.