Move Microsoft.Resources resources to new region

You may need to move an existing resource to a new region. This article shows how to move two resource types - templateSpecs and deploymentScripts - that are in the Microsoft.Resources namespace.

Move template specs to new region

If you have a template spec in one region and want to move it to new region, you can export the template spec and redeploy it.

  1. Use the command to export an existing template spec. For the parameter values, provide the values that match the template spec you want to export.

    For Azure PowerShell, use:

    Export-AzTemplateSpec `
      -ResourceGroupName demoRG `
      -Name demoTemplateSpec `
      -Version 1.0 `
      -OutputFolder c:\export
    

    For Azure CLI, use:

    az template-specs export \
      --resource-group demoRG \
      --name demoTemplateSpec \
      --version 1.0 \
      --output-folder c:\export
    
  2. Use the exported template spec to create a new template spec. The following examples show chinanorth for the new region but you can provide the region you want.

    For Azure PowerShell, use:

    New-AzTemplateSpec `
      -Name movedTemplateSpec `
      -Version 1.0 `
      -ResourceGroupName newRG `
      -Location chinanorth `
      -TemplateJsonFile c:\export\1.0.json
    

    For Azure CLI, use:

    az template-specs create \
      --name movedTemplateSpec \
      --version "1.0" \
      --resource-group newRG \
      --location "chinanorth" \
      --template-file "c:\export\demoTemplateSpec.json"
    

Move deployment scripts to new region

  1. Select the resource group that contains the deployment script you want to move to a new region.

  2. Export the template. When exporting, select the deployment script and any other required resources.

  3. In the exported template, delete the following properties:

    • tenantId
    • principalId
    • clientId
  4. The exported template has a hardcoded value for the region of the deployment script.

    "location": "chinanorth2",
    

    Change the template to allow a parameter for setting the location. For more information, see Set resource location in ARM template

    "location": "[parameters('location')]",
    
  5. Deploy the exported template and specify a new region for the deployment script.

Next steps