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

Published May 18 2020 01:09 PM 1,690 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 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

 

 

 

1 Comment
%3CLINGO-SUB%20id%3D%22lingo-sub-1399174%22%20slang%3D%22en-US%22%3EStep-by-step%3A%20create%20a%20read%20replica%20in%20different%20subscription%20and%20resource%20group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1399174%22%20slang%3D%22en-US%22%3E%3CP%3ERecently%2C%20I%20worked%20with%20a%20customer%20who%20wanted%20to%20create%20a%20read%20replica%20server%20in%20a%20different%20Azure%20subscription%20and%20resource%20group.%20They%20wanted%20a%20disaster%20recovery%20strategy%20by%20utilizing%20separate%20%22production%22%20and%20%22disaster%20recovery%22%20subscriptions%20%26amp%3B%20resource%20groups.%26nbsp%3BThe%20below%20article%20explains%20how%20we%20can%20achieve%20this.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EWe%20can%20create%20a%20read%20replica%20server%20for%20an%20Azure%20Database%20for%20MySQL%20master%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmysql%2Fhowto-read-replicas-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20portal%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmysql%2Fhowto-read-replicas-cli%23azure-cli%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20CLI%3C%2FA%3E%2C%20or%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmysql%2Fhowto-read-replicas-cli%23rest-api%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EREST%20API%3C%2FA%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20creating%20a%20read%20replica%20from%20the%20Azure%20portal%2C%20we%20get%20options%20to%20select%20the%20server%20name%2C%20location%2C%20and%20pricing%20tier.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%221_replcia.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F192552i456CD0847826E27C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%221_replcia.jpg%22%20alt%3D%221_replcia.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%2C%20if%20we%20want%20to%20create%20a%20read%20replica%20in%20a%20%3CSTRONG%3Edifferent%20resource%20group%3C%2FSTRONG%3E%2C%20the%20Azure%20portal%20does%20not%20give%20us%20that%20option%3B%20however%2C%20Azure%20CLI%20does.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20following%20will%20help%20us%20achieve%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eaz%20mysql%20server%20replica%20create%20-n%20testreplsvr%20-g%26nbsp%3Btestgroup%26nbsp%3B%20-s%20%22%2Fsubscriptions%2F%24%7BSubID%7D%2FresourceGroups%2F%24%7BResourceGroup%7D%2Fproviders%2FMicrosoft.DBforMySQL%2Fservers%2Ftestsvr2%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ewhere%3A%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Etestreplsvr%20--%26gt%3B%20%3C%2FSTRONG%3ENew%20replica%20server%20Name%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Etestgroup%26nbsp%3B--%26gt%3B%20%3C%2FSTRONG%3ENew%20Resource%20Group%20where%20your%20replica%20server%20is%20in%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%2Fsubscriptions%2F%24%7BSubID%7D%2FresourceGroups%2F%24%7BResourceGroup%7D%2Fproviders%2FMicrosoft.DBforMySQL%2Fservers%2Ftestsvr2%3C%2FSTRONG%3E%20--%26gt%3BResource%20Uri%20for%20your%20master%20server.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%20even%20in%20this%20command%2C%20the%20read%20replica%20is%20still%20created%20within%20the%20same%20subscription%20as%20the%20master.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHow%20can%20we%20do%20this%20for%20a%20%3CSTRONG%3Edifferent%20subscription%3C%2FSTRONG%3E%3F%20For%20this%20we%20can%20take%20a%20two%20step%20process%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ECreate%20a%20read%20replica%20in%20source%20group%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20create%20the%20read%20replica%20in%20your%20%22production%22%20subscription%20and%20resource%20group.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eaz%20mysql%20server%20replica%20create%20--subscription%20%3CSOURCESUBID%3E%20-n%20testreplsvr%26nbsp%3B%20-g%20%3CSOURCE%20rg%3D%22%22%3E%20-s%20%2Fsubscriptions%2F%3CSOURCESUBID%3E%2FresourceGroups%2F%24%7BResourceGroup%7D%2Fproviders%2FMicrosoft.DBforMySQL%2Fservers%2Ftestsvr2%20%22%3C%2FSOURCESUBID%3E%3C%2FSOURCE%3E%3C%2FSOURCESUBID%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EMove%20the%20read%20replica%20to%20destination%20subscription%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20move%20the%20new%20read%20replica%20to%20your%20%22disaster%20recovery%22%20subscription%20and%20resource%20group.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eaz%20resource%20move%20--destination-group%20%3CDES%20rg%3D%22%22%3E%20--ids%20%22%2Fsubscriptions%2F%3CSOURCESUBID%3E%2FresourceGroups%2F%24%7BResourceGroup%7D%2Fproviders%2FMicrosoft.DBforMySQL%2Fservers%2Ftestsvr2%22%20--destination-subscription-id%20%3CDESSUBID%3E%26nbsp%3B%20--subscription%20%3CSOURCESUBID%3E%3C%2FSOURCESUBID%3E%3C%2FDESSUBID%3E%3C%2FSOURCESUBID%3E%3C%2FDES%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20do%20this%20from%20the%20Azure%20portal%20after%20the%20read%20replica%20has%20been%20created%20by%20clicking%20on%20%3CFONT%20color%3D%22%230000FF%22%3E%3CSTRONG%3Echange%3C%2FSTRONG%3E%20%3C%2FFONT%3Ein%20the%20read%20replica's%20Overview%20blade.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222_Overview.jpg%22%20style%3D%22width%3A%20354px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F192553i89E9DAF28468FE94%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%222_Overview.jpg%22%20alt%3D%222_Overview.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHope%20this%20information%20helps.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESudheesh%26nbsp%3BNarayanaswamy%3C%2FP%3E%0A%3CP%3ETechnical%20Support%20Engineer%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1401093%22%20slang%3D%22en-US%22%3ERe%3A%20Step-by-step%3A%20create%20a%20read%20replica%20in%20different%20subscription%20and%20resource%20group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1401093%22%20slang%3D%22en-US%22%3E%3CP%3EPlease%20note%20that%20you%20need%20to%20keep%20in%20mind%20you%20take%20care%20of%20the%20checklist%20as%20mentioned%20in%20the%20article%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-resource-manager%2Fmanagement%2Fmove-resource-group-and-subscription%23checklist-before-moving-resources%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-resource-manager%2Fmanagement%2Fmove-resource-group-and-subscription%23checklist-before-moving-resources%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Version history
Last update:
‎May 18 2020 01:09 PM
Updated by: