使用 Azure 应用程序网关专用链接,可以从不同虚拟网络 (VNet) 和订阅中的工作负载建立与应用程序网关的安全的专用连接。 此功能提供专用连接,无需向公共 Internet 公开流量。 有关详细信息,请参阅应用程序网关专用链接。
Configuration options
可以使用多种方法配置应用程序网关专用链接:
- Azure 门户
- Azure PowerShell
- Azure CLI
Prerequisites
在配置专用链接之前,请确保具备:
- 现有的应用程序网关
- 具有专用链接专用子网的虚拟网络(独立于应用程序网关子网)
- 用于创建和配置专用链接资源的相应权限
为专用链接配置定义子网
若要启用专用链接配置,必须创建独立于应用程序网关子网的专用子网。 此子网专用于专用链接 IP 配置,不能包含任何应用程序网关实例。
子网大小调整注意事项:
- 分配给此子网的每个 IP 地址最多支持通过专用链接进行 65,536 个并发 TCP 连接
- 要计算所需的 IP 地址:
n × 65,536
个连接,其中 n
是已预配的 IP 地址数
- 每个专用链接配置最多 8 个 IP 地址
- 仅支持动态 IP 地址分配
Important
应用程序网关名称和专用链接配置名称的组合长度不得超过 70 个字符,以避免部署失败。
若要为专用链接创建专用子网,请参阅 添加、更改或删除虚拟网络子网。
专用链接配置定义了用于启用从专用终结点到应用程序网关的连接的基础设施。 在创建专用链接配置之前,请确保侦听器已主动配置为使用目标前端 IP 配置。
按照以下步骤创建专用链接配置:
- 导航到 Azure 门户。
- 搜索并选择“应用程序网关”。
- 选择应用程序网关实例。
- 在左侧导航窗格中,选择 “专用”链接,然后选择“ + 添加”。
- 配置以下设置:
-
名称:输入专用链接配置的名称
-
专用链接子网:为专用链接 IP 地址选择专用子网
-
前端 IP 配置:选择专用链接应将流量转发到的前端 IP 配置
-
专用 IP 地址设置:配置至少一个 IP 地址
- 选择 “添加” 以创建配置。
- 在应用程序网关设置中,复制并保存 资源 ID。 从不同的 Microsoft Entra 租户设置专用终结点时,需要此标识符。
专用终结点是一个网络接口,它使用虚拟网络中的专用 IP 地址安全地连接到 Azure 应用程序网关。 客户端使用专用终结点的专用 IP 地址通过安全隧道与应用程序网关建立连接。
若要创建专用终结点,请执行以下步骤:
- 在应用程序网关门户中,选择 “专用终结点连接 ”选项卡。
- 选择 “+ 专用终结点”。
- 在 “基本信息 ”选项卡上:
- 为专用终结点配置资源组、名称和区域
- 选择“下一步:资源>”
- 在 “资源 ”选项卡上:
- 在 “虚拟网络 ”选项卡上:
- 选择要在其中创建专用终结点网络接口的虚拟网络和子网
- 选择“下一步:DNS>”
- 在 “DNS ”选项卡上:
- 根据需要配置 DNS 设置
- 选择 “下一步:标记” >
- 在“ 标记 ”选项卡上:
- (可选)添加资源标记
- 选择 “下一步:查看 + 创建” >
- 查看配置,然后选择“创建”。
Important
如果在用于创建专用终结点的“资源”选项卡上尝试选择“目标子资源”时缺少公共或专用 IP 配置资源,确保侦听器正在积极利用你指定的前端 IP 配置。 没有关联侦听器的前端 IP 配置不能显示为 目标子资源。
Note
从其他 Microsoft Entra 租户预配专用终节点时,必须使用 Azure 应用程序网关资源 ID,并将前端 IP 配置名称指定为目标子资源。
例如,如果你的专用 IP 配置在门户中命名为 PrivateFrontendIp
,那么请使用 PrivateFrontendIp
作为目标子资源值。
Caution
将专用终结点移动到其他订阅时,必须先删除专用链接和专用终结点之间的现有连接。 删除后,在目标订阅中创建新的专用终结点连接以重新建立连接。
Prerequisites
在使用 PowerShell 命令之前,请确保具备:
- 安装和配置 Azure PowerShell 模块
- 修改应用程序网关和网络资源的相应权限
- 现有的应用程序网关和虚拟网络 (VNet) 服务
使用以下 PowerShell 命令在现有应用程序网关上配置专用链接:
# Disable Private Link Service Network Policies
# /private-link/disable-private-endpoint-network-policy
$net =@{
Name = 'AppGW-PL-PSH'
ResourceGroupName = 'AppGW-PL-PSH-RG'
}
$vnet = Get-AzVirtualNetwork @net
($vnet | Select -ExpandProperty subnets | Where-Object {$_.Name -eq 'AppGW-PL-Subnet'}).PrivateLinkServiceNetworkPolicies = "Disabled"
# Apply the network policy changes
$vnet | Set-AzVirtualNetwork
# Get Application Gateway Frontend IP Name
$agw = Get-AzApplicationGateway -Name AppGW-PL-PSH -ResourceGroupName AppGW-PL-PSH-RG
# List the available Frontend IP configuration Names
$agw.FrontendIPConfigurations | Select Name
# Create Private Link IP configuration
$PrivateLinkIpConfiguration = New-AzApplicationGatewayPrivateLinkIpConfiguration `
-Name "ipConfig01" `
-Subnet ($vnet | Select -ExpandProperty subnets | Where-Object {$_.Name -eq 'AppGW-PL-Subnet'}) `
-Primary
# Add Private Link configuration to Application Gateway
Add-AzApplicationGatewayPrivateLinkConfiguration `
-ApplicationGateway $agw `
-Name "privateLinkConfig01" `
-IpConfiguration $PrivateLinkIpConfiguration
# Associate Private Link configuration with Frontend IP
$agwPip = ($agw | Select -ExpandProperty FrontendIpConfigurations| Where-Object {$_.Name -eq 'appGwPublicFrontendIp'}).PublicIPAddress.Id
$privateLinkConfiguration = ($agw | Select -ExpandProperty PrivateLinkConfigurations | Where-Object {$_.Name -eq 'privateLinkConfig01'}).Id
Set
-AzApplicationGatewayFrontendIPConfig
-ApplicationGateway $agw -Name "appGwPublicFrontendIp"
-PublicIPAddressId $agwPip
-PrivateLinkConfigurationId $privateLinkConfiguration
# Apply changes to Application Gateway
Set-AzApplicationGateway -ApplicationGateway $agw
# Configure Private Endpoint network (in the client/consumer virtual network)
# Disable Private Endpoint Network Policies
# /private-link/disable-private-endpoint-network-policy
$net =@{
Name = 'AppGW-PL-Endpoint-PSH-VNET'
ResourceGroupName = 'AppGW-PL-Endpoint-PSH-RG'
}
$vnet_plendpoint = Get-AzVirtualNetwork @net
($vnet_plendpoint | Select -ExpandProperty subnets | Where-Object {$_.Name -eq 'MySubnet'}).PrivateEndpointNetworkPolicies = "Disabled"
$vnet_plendpoint | Set-AzVirtualNetwork
# Create Private Link Endpoint - Group ID is the same as the frontend IP configuration
$privateEndpointConnection = New-AzPrivateLinkServiceConnection -Name "AppGW-PL-Connection" -PrivateLinkServiceId $agw.Id -GroupID "appGwPublicFrontendIp"
## Create the Private Endpoint
New-AzPrivateEndpoint -Name "AppGWPrivateEndpoint" -ResourceGroupName $vnet_plendpoint.ResourceGroupName -Location $vnet_plendpoint.Location -Subnet ($vnet_plendpoint | Select -ExpandProperty subnets | Where-Object {$_.Name -eq 'MySubnet'}) -PrivateLinkServiceConnection $privateEndpointConnection
PowerShell cmdlet 参考
以下 Azure PowerShell cmdlet 可用于管理应用程序网关专用链接配置:
Prerequisites
在使用 Azure CLI 命令之前,请确保具备:
- 已安装并配置 Azure CLI
- 修改应用程序网关和网络资源的相应权限
- 现有的应用程序网关和虚拟网络 (VNet) 服务
使用以下 Azure CLI 命令在现有应用程序网关上配置专用链接:
# Disable Private Link Service Network Policies on the Private Link subnet
# Reference: /private-link/disable-private-endpoint-network-policy
az network vnet subnet update \
--name AppGW-PL-Subnet \
--vnet-name AppGW-PL-CLI-VNET \
--resource-group AppGW-PL-CLI-RG \
--disable-private-link-service-network-policies true
# List available Frontend IP configurations
az network application-gateway frontend-ip list \
--gateway-name AppGW-PL-CLI \
--resource-group AppGW-PL-CLI-RG
# Create Private Link configuration and associate with Frontend IP
az network application-gateway private-link add \
--frontend-ip appGwPublicFrontendIp \
--name privateLinkConfig01 \
--subnet /subscriptions/XXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/AppGW-PL-CLI-RG/providers/Microsoft.Network/virtualNetworks/AppGW-PL-CLI-VNET/subnets/AppGW-PL-Subnet \
--gateway-name AppGW-PL-CLI \
--resource-group AppGW-PL-CLI-RG
# Verify Private Link configuration
az network application-gateway private-link list \
--gateway-name AppGW-PL-CLI \
--resource-group AppGW-PL-CLI-RG
# Configure Private Endpoint network (in the client/consumer virtual network)
# Disable Private Endpoint Network Policies
az network vnet subnet update \
--name MySubnet \
--vnet-name AppGW-PL-Endpoint-CLI-VNET \
--resource-group AppGW-PL-Endpoint-CLI-RG \
--disable-private-endpoint-network-policies true
# Create Private Endpoint
# Note: Group ID must match the Frontend IP configuration name
az network private-endpoint create \
--name AppGWPrivateEndpoint \
--resource-group AppGW-PL-Endpoint-CLI-RG \
--vnet-name AppGW-PL-Endpoint-CLI-VNET \
--subnet MySubnet \
--group-id appGwPublicFrontendIp \
--private-connection-resource-id /subscriptions/XXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/AppGW-PL-CLI-RG/providers/Microsoft.Network/applicationGateways/AppGW-PL-CLI \
--connection-name AppGW-PL-Connection
Azure CLI 参考
有关应用程序网关专用链接配置的综合 Azure CLI 命令参考,请参阅 Azure CLI - 应用程序网关专用链接。
Next steps
若要详细了解 Azure 专用链接和相关服务,