3

I have created a relatively complex IaaS environment in one of my resource groups. The environment is working very well. Now I need to re-build the same environment in another RG for testing and validation.

What would be the easiest way to re-create the same environment in another Resource Group in the same subscription? I tried to export the resource group and downloaded it. The problem is that the file “parameters.json” includes hard coded references to the original resource group name. Is there an easy way to copy all contents of a RG to another RG in the same environment? Thank you,

Allan Xu
  • 7,998
  • 11
  • 51
  • 122
  • Are you able to give a more specific or concrete example of your problem? – juvchan Jul 04 '16 at 06:12
  • 1
    @juvchan: The scenario is when you spend hours (or days) to create a working IaaS environment that includes many VMs and complex VNET. You need to create your second (or third) dev environment and don't want to spend so much time to re-do everything. – Allan Xu Jul 04 '16 at 14:03

1 Answers1

0

Two approaches can be used here. You can remove the resource group reference from the template and parameter files and then simply specify the resource group when you deploy from the template using PowerShell, the portal, Azure CLI, etc.

To deploy using this method in PowerShell

New-AzureRmResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName ExampleResourceGroup -TemplateFile <PathToTemplate> -TemplateParameterFile <PathToParameterFile>

Or

You can change the resource group to the new resource group in the parameters file and deploy.

You can read more about deploying using templates here.

Edit:

Just a note but you don't have to use a separate file for parameters. You can easily include the parameters in the template file as well.

Casey
  • 805
  • 4
  • 10
  • Thank you for help. If I change the resource group name in the template to another name, would the import process creates the RG with the new name? – Allan Xu Jul 04 '16 at 13:59
  • I believe you'll need to make sure the new resource group has already been created. In all honesty I would recommend just removing the resource group because it'll make the template more re-usable. – Casey Jul 04 '16 at 14:09
  • I think the answer is "it depends" - on the make up of the resourceId and whether it's defined in the exported template. If you can give a snippet of the json in question, that might help give a better answer... If everything is in the same resourceGroup then as Casey suggested, refactor the template to remove the name (it's not needed even though Export added it (export isn't perfect yet)) – bmoore-msft Jul 05 '16 at 16:59