你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

New-AzVpnConnection

创建一个 IPSec 连接,该连接将 VpnGateway 连接到以 VPNSite 表示的远程客户分支。

语法

New-AzVpnConnection
   -ResourceGroupName <String>
   -ParentResourceName <String>
   -Name <String>
   -VpnSite <PSVpnSite>
   [-SharedKey <SecureString>]
   [-ConnectionBandwidthInMbps <UInt32>]
   [-IpSecPolicy <PSIpsecPolicy>]
   [-TrafficSelectorPolicy <PSTrafficSelectorPolicy[]>]
   [-VpnConnectionProtocolType <String>]
   [-EnableBgp]
   [-UseLocalAzureIpAddress]
   [-UsePolicyBasedTrafficSelectors]
   [-VpnSiteLinkConnection <PSVpnSiteLinkConnection[]>]
   [-EnableInternetSecurity]
   [-RoutingConfiguration <PSRoutingConfiguration>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzVpnConnection
   -ResourceGroupName <String>
   -ParentResourceName <String>
   -Name <String>
   -VpnSiteId <String>
   [-SharedKey <SecureString>]
   [-ConnectionBandwidthInMbps <UInt32>]
   [-IpSecPolicy <PSIpsecPolicy>]
   [-TrafficSelectorPolicy <PSTrafficSelectorPolicy[]>]
   [-VpnConnectionProtocolType <String>]
   [-EnableBgp]
   [-UseLocalAzureIpAddress]
   [-UsePolicyBasedTrafficSelectors]
   [-VpnSiteLinkConnection <PSVpnSiteLinkConnection[]>]
   [-EnableInternetSecurity]
   [-RoutingConfiguration <PSRoutingConfiguration>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzVpnConnection
   -ParentObject <PSVpnGateway>
   -Name <String>
   -VpnSite <PSVpnSite>
   [-SharedKey <SecureString>]
   [-ConnectionBandwidthInMbps <UInt32>]
   [-IpSecPolicy <PSIpsecPolicy>]
   [-TrafficSelectorPolicy <PSTrafficSelectorPolicy[]>]
   [-VpnConnectionProtocolType <String>]
   [-EnableBgp]
   [-UseLocalAzureIpAddress]
   [-UsePolicyBasedTrafficSelectors]
   [-VpnSiteLinkConnection <PSVpnSiteLinkConnection[]>]
   [-EnableInternetSecurity]
   [-RoutingConfiguration <PSRoutingConfiguration>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzVpnConnection
   -ParentObject <PSVpnGateway>
   -Name <String>
   -VpnSiteId <String>
   [-SharedKey <SecureString>]
   [-ConnectionBandwidthInMbps <UInt32>]
   [-IpSecPolicy <PSIpsecPolicy>]
   [-TrafficSelectorPolicy <PSTrafficSelectorPolicy[]>]
   [-VpnConnectionProtocolType <String>]
   [-EnableBgp]
   [-UseLocalAzureIpAddress]
   [-UsePolicyBasedTrafficSelectors]
   [-VpnSiteLinkConnection <PSVpnSiteLinkConnection[]>]
   [-EnableInternetSecurity]
   [-RoutingConfiguration <PSRoutingConfiguration>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzVpnConnection
   -ParentResourceId <String>
   -Name <String>
   -VpnSite <PSVpnSite>
   [-SharedKey <SecureString>]
   [-ConnectionBandwidthInMbps <UInt32>]
   [-IpSecPolicy <PSIpsecPolicy>]
   [-TrafficSelectorPolicy <PSTrafficSelectorPolicy[]>]
   [-VpnConnectionProtocolType <String>]
   [-EnableBgp]
   [-UseLocalAzureIpAddress]
   [-UsePolicyBasedTrafficSelectors]
   [-VpnSiteLinkConnection <PSVpnSiteLinkConnection[]>]
   [-EnableInternetSecurity]
   [-RoutingConfiguration <PSRoutingConfiguration>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzVpnConnection
   -ParentResourceId <String>
   -Name <String>
   -VpnSiteId <String>
   [-SharedKey <SecureString>]
   [-ConnectionBandwidthInMbps <UInt32>]
   [-IpSecPolicy <PSIpsecPolicy>]
   [-TrafficSelectorPolicy <PSTrafficSelectorPolicy[]>]
   [-VpnConnectionProtocolType <String>]
   [-EnableBgp]
   [-UseLocalAzureIpAddress]
   [-UsePolicyBasedTrafficSelectors]
   [-VpnSiteLinkConnection <PSVpnSiteLinkConnection[]>]
   [-EnableInternetSecurity]
   [-RoutingConfiguration <PSRoutingConfiguration>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

说明

创建一个 IPSec 连接,该连接将 VpnGateway 连接到以 VPNSite 表示的远程客户分支。

示例

示例 1

New-AzResourceGroup -Location "West US" -Name "testRG"
$virtualWan = New-AzVirtualWan -ResourceGroupName testRG -Name myVirtualWAN -Location "West US"
$virtualHub = New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.0.1/24"
New-AzVpnGateway -ResourceGroupName "testRG" -Name "testvpngw" -VirtualHubId $virtualHub.Id -VpnGatewayScaleUnit 2
$vpnGateway = Get-AzVpnGateway -ResourceGroupName "testRG" -Name "testvpngw"
$vpnSiteAddressSpaces = New-Object string[] 2
$vpnSiteAddressSpaces[0] = "192.168.2.0/24"
$vpnSiteAddressSpaces[1] = "192.168.3.0/24"
$vpnSite = New-AzVpnSite -ResourceGroupName "testRG" -Name "testVpnSite" -Location "West US" -VirtualWan $virtualWan -IpAddress "1.2.3.4" -AddressSpace $vpnSiteAddressSpaces -DeviceModel "SomeDevice" -DeviceVendor "SomeDeviceVendor" -LinkSpeedInMbps "10"

New-AzVpnConnection -ResourceGroupName $vpnGateway.ResourceGroupName -ParentResourceName $vpnGateway.Name -Name "testConnection" -VpnSite $vpnSite -ConnectionBandwidthInMbps 20

RemoteVpnSite             : Microsoft.Azure.Commands.Network.Models.PSResourceId
SharedKey                 :
VpnConnectionProtocolType : IKEv2
ConnectionStatus          :
EgressBytesTransferred    : 0
IngressBytesTransferred   : 0
IpsecPolicies             : {}
ConnectionBandwidth       : 20
EnableBgp                 : False
UseLocalAzureIpAddress    : False
ProvisioningState         : testConnection
Name                      : ps9709
Etag                      : W/"4580a2e2-2fab-4cff-88eb-92013a76b5a8"
Id                        : /subscriptions/{subscriptionId}/resourceGroups/testRg/providers/Microsoft.Network/vpnGateways/testvpngw/vpnConnections/testConnection
RoutingConfiguration      : {
                                "AssociatedRouteTable": {
                                    "Id": "/subscriptions/{subscriptionId}/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/westushub/hubRouteTables/defaultRouteTable"
                                }
                                "PropagatedRouteTables": {
                                    "Labels": [],
                                    "Ids": [
                                    {
                                    "Id": "/subscriptions/{subscriptionId}/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/westushub/hubRouteTables/defaultRouteTable"
                                    }
                                ]
                                },
                                "VnetRoutes": {
                                    "StaticRoutes": []
                                }
                            }

上述内容将在 Azure 中的“testRG”资源组中创建资源组、虚拟 WAN、虚拟网络、虚拟中心和美国西部的 VpnSite。 VPN 网关将在虚拟中心创建 2 个缩放单元。

创建网关后,它将使用 New-AzVpnConnection 命令连接到 VpnSite。

示例 2

New-AzResourceGroup -Location "West US" -Name "testRG"
$virtualWan = New-AzVirtualWan -ResourceGroupName testRG -Name myVirtualWAN -Location "West US"
$virtualHub = New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.0.1/24"
New-AzVpnGateway -ResourceGroupName "testRG" -Name "testvpngw" -VirtualHubId $virtualHub.Id -VpnGatewayScaleUnit 2
$vpnGateway = Get-AzVpnGateway -ResourceGroupName "testRG" -Name "testvpngw"

$vpnSiteAddressSpaces = New-Object string[] 2
$vpnSiteAddressSpaces[0] = "192.168.2.0/24"
$vpnSiteAddressSpaces[1] = "192.168.3.0/24"

$vpnSiteLink1 = New-AzVpnSiteLink -Name "testVpnSiteLink1" -IpAddress "15.25.35.45" -LinkProviderName "SomeTelecomProvider" -LinkSpeedInMbps "10"
$vpnSiteLink2 = New-AzVpnSiteLink -Name "testVpnSiteLink2" -IpAddress "15.25.35.55" -LinkProviderName "SomeTelecomProvider2" -LinkSpeedInMbps "100"
$vpnSite = New-AzVpnSite -ResourceGroupName "testRG" -Name "testVpnSite" -Location "West US" -VirtualWan $virtualWan -AddressSpace $vpnSiteAddressSpaces -DeviceModel "SomeDevice" -DeviceVendor "SomeDeviceVendor" -VpnSiteLink @($vpnSiteLink1, $vpnSiteLink2)


$vpnSiteLinkConnection1 = New-AzVpnSiteLinkConnection -Name "testLinkConnection1" -VpnSiteLink $vpnSite.VpnSiteLinks[0] -ConnectionBandwidth 100
$vpnSiteLinkConnection2 = New-AzVpnSiteLinkConnection -Name "testLinkConnection2" -VpnSiteLink $vpnSite.VpnSiteLinks[1] -ConnectionBandwidth 10

New-AzVpnConnection -ResourceGroupName $vpnGateway.ResourceGroupName -ParentResourceName $vpnGateway.Name -Name "testConnection" -VpnSite $vpnSite -VpnSiteLinkConnection @($vpnSiteLinkConnection1, $vpnSiteLinkConnection2)

上述内容将在 Azure 中的“testRG”资源组中创建资源组、虚拟 WAN、虚拟网络、虚拟中心和具有 1 个 VpnSiteLinks 的 VpnSite。 在虚拟中心之后,将创建 VPN 网关。 创建网关后,它将使用具有 1 个 VpnSiteLinkConnections 的 New-AzVpnConnection 命令连接到 VpnSite,并将其连接到 VpnSite 的 VpnSiteLink。

参数

-AsJob

在后台运行 cmdlet

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

提示你在运行 cmdlet 之前进行确认。

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ConnectionBandwidthInMbps

此连接需要以 mbps 为单位处理的带宽。

Type:UInt32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-EnableBgp

为此连接启用 BGP

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-EnableInternetSecurity

为此连接启用 Internet 安全性

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-IpSecPolicy

此连接需要以 mbps 为单位处理的带宽。

Type:PSIpsecPolicy
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Name

资源名称。

Type:String
Aliases:ResourceName, VpnConnectionName
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ParentObject

此连接的父 VpnGateway。

Type:PSVpnGateway
Aliases:ParentVpnGateway, VpnGateway
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-ParentResourceId

此连接的父 VpnGateway 的资源 ID。

Type:String
Aliases:ParentVpnGatewayId, VpnGatewayId
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-ParentResourceName

资源组名称。

Type:String
Aliases:ParentVpnGatewayName, VpnGatewayName
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

资源组名称。

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-RoutingConfiguration

此连接的路由配置

Type:PSRoutingConfiguration
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-SharedKey

设置此连接的共享密钥。

Type:SecureString
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-TrafficSelectorPolicy

流量选择器策略的列表。

Type:PSTrafficSelectorPolicy[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-UseLocalAzureIpAddress

在启动连接时,使用本地 Azure IP 地址作为源地址。

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-UsePolicyBasedTrafficSelectors

为此连接使用基于策略的流量选择器。

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-VpnConnectionProtocolType

网关连接协议:IKEv1/IKEv2

Type:String
Accepted values:IKEv1, IKEv2
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-VpnSite

连接到此中心虚拟网络连接的远程 VPN 站点。

Type:PSVpnSite
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-VpnSiteId

连接到此中心虚拟网络连接的远程 VPN 站点。

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-VpnSiteLinkConnection

此 VpnConnection 具有的 VpnSiteLinkConnection 列表。

Type:PSVpnSiteLinkConnection[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

显示在此 cmdlet 运行的情况下将会发生什么。 此 cmdlet 未运行。

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

输入

PSVpnGateway

String

输出

PSVpnConnection