Migrate to an availability zone-enabled ExpressRoute virtual network gateway using PowerShell

When you create an ExpressRoute virtual network gateway, you need to choose the gateway SKU. If you choose a higher-level SKU, more CPUs and network bandwidth are allocated to the gateway. As a result, the gateway can support higher network throughput and more dependable network connections to the virtual network.

The following SKUs are available for ExpressRoute virtual network gateways:

  • Standard
  • HighPerformance
  • UltraPerformance
  • ErGw1Az
  • ErGw2Az
  • ErGw3Az
  • ErGwScale (Preview)

Prerequisites

Working with Azure PowerShell

The steps and examples in this article use Azure PowerShell Az modules. To install the Az modules locally on your computer, see Install Azure PowerShell. To learn more about the new Az module, see Introducing the new Azure PowerShell Az module. PowerShell cmdlets are updated frequently. If you are not running the latest version, the values specified in the instructions may fail. To find the installed versions of PowerShell on your system, use the Get-Module -ListAvailable Az cmdlet.

You can use Azure Cloud Shell to run most PowerShell cmdlets and CLI commands, instead of installing Azure PowerShell or CLI locally. Azure Cloud Shell is a free interactive shell that has common Azure tools preinstalled and is configured to use with your account. To run any code contained in this article on Azure Cloud Shell, open a Cloud Shell session, use the Copy button on a code block to copy the code, and paste it into the Cloud Shell session with Ctrl+Shift+V on Windows and Linux, or Cmd+Shift+V on macOS. Pasted text is not automatically executed, press Enter to run code.

There are a few ways to launch the Cloud Shell:

Option Link
Click Try It in the upper right corner of a code block. Cloud Shell in this article
Open Cloud Shell in your browser. https://shell.azure.com/powershell
Click the Cloud Shell button on the menu in the upper right of the Azure portal. Cloud Shell in the portal

Migrate to a new gateway in using PowerShell

Here are the steps to migrate to a new gateway using PowerShell.

Clone the script

  1. Clone the setup script from GitHub.

    git clone https://github.com/Azure-Samples/azure-docs-powershell-samples/ 
    
  2. Change to the directory where the script is located.

    CD azure-docs-powershell-samples/expressroute-gateway/
    

Prepare the migration

This script creates a new ExpressRoute virtual network gateway on the same gateway subnet and connects it to your existing ExpressRoute circuits.

  1. Identify the resource ID of the gateway that will be migrated.

    $resourceId = Get-AzResource -Name {virtual network gateway name}
    $resourceId.Id
    
  2. Run the PrepareMigration.ps1 script to prepare the migration.

    gateway-migration/preparemigration.ps1
    
  3. Enter the resource ID of your gateway.

  4. The gateway subnet needs two or more address prefixes for the migration. If you have only one prefix, you're prompted to enter an additional prefix.

  5. Choose a name for your new resources, the new resource name will be added to the existing name. For example: existingresourcename_newname.

  6. Enter an availability zone for your new gateway.

Run the migration

This script transfers the configuration from the old gateway to the new one.

  1. Identify the resource ID of your new post-migration gateway. Use the resource name you given for this gateway in the previous step.

    $resourceId = Get-AzResource -Name {virtual network gateway name}
    $resourceId.Id
    
  2. Run the Migration.ps1 script to perform the migration.

    gateway-migration/migration.ps1
    
  3. Enter the resource ID of your premigration gateway.

  4. Enter the resource ID of your post-migration gateway.

Commit the migration

This script deletes the old gateway and its connections.

  1. Run the CommitMigration.ps1 script to complete the migration.

    gateway-migration/commitmigration.ps1
    
  2. Enter the resource ID of the premigration gateway.

    Important

    • Before running this step, verify that the new virtual network gateway has a working ExpressRoute connection.
    • When migrating your gateway, you can expect possible interruption for a maximum of 30 seconds.

Next steps