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.

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