将 Azure Point-To-Site VPN 配置为在 ResourceGroup 中创建的虚拟网络

Configure Azure Point-To-Site VPN to Virtual Network created in a ResourceGroup

我正在使用新的资源管理器界面来创建我的虚拟网络。而且我不知道如何配置点到站点 VPN 并通过 Powershell API.

获取 VPN 客户端

我的脚本:

$accountName = "a@a.com"
$subscriptionId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
$vnetname = "VNet1"
$rgname = "MyRG"
$sharedKey = -join(97..122|%{[char]$_}|Get-Random -C 20)

Get-AzureAccount -Name $accountName
Set-AzureSubscription -SubscriptionId $subscriptionId
New-AzureResourceGroup -Name "MyRG" -Location "Central US" -Force

$subnet  = New-AzureVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix '10.192.0.0/24'

New-AzureVirtualNetwork -Name $vnetname -ResourceGroupName $rgname -Location "Central US" -AddressPrefix '10.0.0.0/8' -Subnet $subnet -Force

我进入新门户,只有 DNS 选项可供创建,无法创建 VPN 网关。我尝试编写脚本,但无法弄清楚站点部分的意义。有什么建议吗?

网关脚本:

$gwip = New-AzurePublicIpAddress -Name ($vnetname + "gwip") -ResourceGroupName $rgname -Location $location -AllocationMethod Dynamic
$vnet = Get-AzureVirtualNetwork -Name $vnetname -ResourceGroupName $rgname
$subnet = Get-AzureVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $vnet
$gwipconfig = New-AzureVirtualNetworkGatewayIpConfig -Name ($vnetname + "gwipconfig") -SubnetId $subnet.Id -PublicIpAddressId $gwip.Id
$gw = New-AzureVirtualNetworkGateway -Name ($vnetname + "gw1") -ResourceGroupName $rgname -Location "Central US" -IpConfigurations $gwipconfig -GatewayType Vpn -VpnType RouteBased
$localGw = New-AzureLocalNetworkGateway -Name ($vnetname + "gw1-local") -ResourceGroupName $rgname -Location "Central US" -GatewayIpAddress $gwipconfig -AddressPrefix '172.16.0.0/24'

New-AzureVirtualNetworkGatewayConnection -Name ($vnetname + "gw1-conn") -ResourceGroupName $rgname -Location "Central US" -VirtualNetworkGateway1 $gw -LocalNetworkGateway2 $localGw -ConnectionType IPsec -RoutingWeight 10 -SharedKey $sharedKey 

MS Azure 文档中有一个一周前的 Document 说在资源管理器模型下(还)不可能。

This article applies to point-to-site connections for virtual networks created using the classic deployment model (Service Management). At this time, point-to-site connections to a virtual network created using the Azure Resource Manager deployment model are not supported.

这是 2016 年 1 月 19 日添加的,有关如何在资源管理器网络中创建点到站点 VPN 的 Powershell

https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-howto-point-to-site-rm-ps/