Introduction
If we have an existing Virtual Network Gateway for VPN, and when we are trying to create an additional Gateway for ExpressRoute, we will get an error called “in use,” so we can not create another Virtual Network Gateway in the Azure portal. In this article, we will learn how to resolve this issue using Azure PowerShell.
Why are we getting this kind of error?
If our Gateway Subnet address space is like /28, we will get this kind of error.
Step 1
In the Article Resource Group currently, we have a Virtual Network Gateway for VPN, now we will create an additional Virtual Network Gateway for ExpressRoute, so click Create.
Step 2
In the Create Virtual Network Gateway page, we have to select the below details
- Subscription
- Region – Select our Resource group region
- Gateway type - ExpressRoute
- Gateway SKU – Standard
- Virtual Network – Select an existing Network
Now we got the error.
Step 3
Download this script and modify it as your requirement.
- Connect-AzAccount – to connect the Azure account
- Select-AzSubscription "Enter your Subscription Name"
- $RG = "Resource group name"
- $Location = "Resource group location"
- $GWName = "Virtual Network Gateway name"
- $GWIPName = "Virtual Network Gateway Public IP address name"
- $GWIPconfName = "Virtual Network Gateway IP configure name"
- $VNetName = "Virtual Network name"
- $gwsubprefix = "GatewaySubnet address”
Step 4
Open the PowerShell ISE and run the script.
Step 5
The additional Virtual network gateway is created under the Resource group.