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

New-AzVpnConnection

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

语法

ByVpnGatewayNameByVpnSiteObject (默认值)

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

ByVpnGatewayNameByVpnSiteResourceId

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

ByVpnGatewayObjectByVpnSiteObject

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

ByVpnGatewayObjectByVpnSiteResourceId

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

ByVpnGatewayResourceIdByVpnSiteObject

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

ByVpnGatewayResourceIdByVpnSiteResourceId

New-AzVpnConnection
    -ParentResourceId <String>
    -Name <String>
    -VpnSiteId <String>
    [-SharedKey <SecureString>]
    [-ConnectionBandwidthInMbps <UInt32>]
    [-IpSecPolicy <PSIpsecPolicy>]
    [-VpnConnectionProtocolType <String>]
    [-EnableBgp]
    [-UseLocalAzureIpAddress]
    [-UsePolicyBasedTrafficSelectors]
    [-VpnSiteLinkConnection <PSVpnSiteLinkConnection[]>]
    [-EnableInternetSecurity]
    [-RoutingConfiguration <PSRoutingConfiguration>]
    [-TrafficSelectorPolicy <PSTrafficSelectorPolicy[]>]
    [-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。 此后,将在虚拟中心创建具有 2 个缩放单元的 VPN 网关。

创建网关后,它将使用 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

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Confirm

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

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ConnectionBandwidthInMbps

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

参数属性

类型:UInt32
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DefaultProfile

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

参数属性

类型:IAzureContextContainer
默认值:None
支持通配符:False
不显示:False
别名:AzContext, AzureRmContext, AzureCredential

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-EnableBgp

为此连接启用 BGP

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-EnableInternetSecurity

为此连接启用 Internet 安全性

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-IpSecPolicy

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

参数属性

类型:PSIpsecPolicy
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Name

资源名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:资源名称, VpnConnectionName

参数集

(All)
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ParentObject

此连接的父 VpnGateway。

参数属性

类型:PSVpnGateway
默认值:None
支持通配符:False
不显示:False
别名:ParentVpnGateway, VpnGateway

参数集

ByVpnGatewayObjectByVpnSiteObject
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False
ByVpnGatewayObjectByVpnSiteResourceId
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ParentResourceId

此连接的父 VpnGateway 的资源 ID。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:ParentVpnGatewayId, VpnGatewayId

参数集

ByVpnGatewayResourceIdByVpnSiteObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByVpnGatewayResourceIdByVpnSiteResourceId
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ParentResourceName

资源组名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:ParentVpnGatewayName, VpnGatewayName

参数集

ByVpnGatewayNameByVpnSiteObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ByVpnGatewayNameByVpnSiteResourceId
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ResourceGroupName

资源组名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ByVpnGatewayNameByVpnSiteObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ByVpnGatewayNameByVpnSiteResourceId
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-RoutingConfiguration

此连接的路由配置

参数属性

类型:PSRoutingConfiguration
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-SharedKey

设置此连接的共享密钥。

参数属性

类型:SecureString
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-TrafficSelectorPolicy

流量选择器策略的列表。

参数属性

类型:

PSTrafficSelectorPolicy[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-UseLocalAzureIpAddress

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

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-UsePolicyBasedTrafficSelectors

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

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-VpnConnectionProtocolType

网关连接协议:IKEv1/IKEv2

参数属性

类型:String
默认值:None
接受的值:IKEv1, IKEv2
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-VpnSite

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

参数属性

类型:PSVpnSite
默认值:None
支持通配符:False
不显示:False

参数集

ByVpnGatewayNameByVpnSiteObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ByVpnGatewayObjectByVpnSiteObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ByVpnGatewayResourceIdByVpnSiteObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-VpnSiteId

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

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ByVpnGatewayNameByVpnSiteResourceId
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ByVpnGatewayObjectByVpnSiteResourceId
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ByVpnGatewayResourceIdByVpnSiteResourceId
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-VpnSiteLinkConnection

此 VpnConnection 具有的 VpnSiteLinkConnection 列表。

参数属性

类型:

PSVpnSiteLinkConnection[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-WhatIf

显示 cmdlet 运行时会发生什么情况。 命令脚本未运行。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:无线

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters

输入

PSVpnGateway

String

输出

PSVpnConnection