I found it little bit tricky while configuring virtual network gateway using Microsoft Azure Powershell, As while configuring it I had to associate VNG (Virtual Network Gateway) with already create virtual network and other Azure network services. I will try make it easy to understand.
First command is storing existing virtual network information in powershell variable so I can use it later, Check earlier article PART 3.1, I have already created one.
$VirtualNetwork = Get-AzureRmVirtualNetwork -Name 'vnet-poc-10.100.2.0' -ResourceGroupName 'POC-VPN'
Below command creates Gateway Subnet in virtual network as discussed in PART 3. Subnet must be GatewaySubnet
Add-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix '10.100.2.224/27' -VirtualNetwork $VirtualNetwork
Now I have created new gateway subnet under existing Virtual Network its time to commit the changes by using command.
Set-AzureRmVirtualNetwork -VirtualNetwork $VirtualNetwork
I need to use just created Gateway Subnet information in powershell variable for later use in other cmdlets. Basically I need Id of GatewayNetwork.
$GatewaySubnet = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $VirtualNetwork
Virtual Network Gateway requires one Public IP, I will be creating one component. Even though IP Allocation Method is Dynamic , Gateway IP will never change.
$GatewayPublciIP = New-AzureRmPublicIpAddress -Name POC-VPN-VirtualNetworkGatewayPublicIP -ResourceGroupName POC-VPN -Location "East US 2" -AllocationMethod Dynamic
I am creating azure Gateway IP address configuration storing in variable, Where all the related IP addresses and networks I will be using in last command.
$GatewayIPConfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name GatewayIPconfiguration -SubnetId $GatewaySubnet.id -PublicIpAddressId $GatewayPublciIP.Id
Just to add I was facing issue getting $GatewaySubnet.id value, It was empty, I had waited 1-2 hours to get value. If you want to expedite it, Copy API value from $VirtualNetwork variable manually and use it.
I have configured/created all the network related items to Virtual Network Gateway, Now i just need to fire below cmdlet to initiate new VNG. It might take 10 to 45 mins to deploy new VNG in Azure.
New-AzureRmVirtualNetworkGateway -Name 'POC-VPN_VirtualNetworkGateway' -ResourceGroupName 'POC-VPN' -Location 'East US 2' -IpConfigurations $GatewayIPConfig -GatewayType Vpn -VpnType RouteBased -GatewaySku Standard
Just to recap from my earlier article.
-
The -GatewayType for a Site-to-Site configuration is Vpn, Another option is ExpressRoute.
-
The -VpnType can be RouteBased or PolicyBased.
-
The -GatewaySku can be Basic, Standard, or HighPerformance., It is about the performances.
PART 1 : MICROSOFT AZURE CREATION AND CONFIGURATION OF VPN TUNNEL SERIES
PART 2 : MICROSOFT AZURE CREATING RESOURCE GROUP
PART 3 : MICROSOFT AZURE CREATING AND ADMINISTERING VIRTUAL NETWORK (VNET)
PART 3.1 : MICROSOFT AZURE POWERSHELL CREATING AND ADMINISTERING VIRTUAL NETWORK (VNET)
PART 4 : MICROSOFT AZURE CREATING AND ADMINISTRATING LOCAL NETWORK GATEWAY VPN
PART 4.1 : MICROSOFT AZURE POWERSHELL CREATING AND ADMINISTRATING LOCAL NETWORK GATEWAY
PART 5: VIRTUAL NETWORK GATEWAY DEPLOYMENT ON MICROSOFT AZURE
PART 5.1: VIRTUAL NETWORK GATEWAY DEPLOYMENT USING MICROSOFT AZURE POWERSHELL
PART 6: INSTALLING ROUTING AND REMOTE ACCESS SERVER ROLE (MICROSOFT RRAS)
PART 6.1: CONFIGURING ROUTING AND REMOTE ACCESS SERVER DEMAND-DIAL (MICROSOFT RRAS AZURE VPN)
PART 6.2: CONFIGURING ROUTING AND REMOTE ACCESS SERVER ROUTER (MICROSOFT RRAS AZURE VPN)
PART 7: MICROSOFT AZURE CREATE CONNECTION IN VIRTUAL NETWORK GATEWAY
PART 7.1: MICROSOFT AZURE POWERSHELL VPN CONNECTION IN VIRTUAL NETWORK GATEWAY
PART 8: MICROSOFT AZURE ARM AND POWERSHELL CREATING AND MANAGING STORAGE ACCOUNT
PART 9: CREATING AND MANAGING VIRTUAL MACHINE (VM) USING MICROSOFT AZURE RESOURCE MANAGER PORTAL
Next is the screenshot of verifying and checking on the Microsoft Azure portal, all the details and provided configuration are correct.
Some Useful Links
MICROSOFT AZURE ERROR REGISTERING RESOURCE PROVIDERS CODE AUTHORIZATION FAILED
INSTALLING MICROSOFT AZURE POWERSHELL