|
| 1 | +--- |
| 2 | +title: Configure Azure Application Gateway Private Link |
| 3 | +description: This article shows you how to configure Application Gateway Private Link. |
| 4 | +services: application-gateway |
| 5 | +author: greglin |
| 6 | +ms.service: application-gateway |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 05/09/2022 |
| 9 | +ms.author: greglin |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +# Configure Azure Application Gateway Private Link |
| 14 | + |
| 15 | +Application Gateway Private Link allows you to connect your workloads over a private connection spanning across VNets and subscriptions. For more information, see [Application Gateway Private Link](private-link.md). |
| 16 | + |
| 17 | +:::image type="content" source="media/private-link/private-link.png" alt-text="Diagram showing Application Gateway Private Link"::: |
| 18 | + |
| 19 | + |
| 20 | +## Configuration options |
| 21 | + |
| 22 | +Application Gateway Private Link can be configured via multiple options, such as, but not limited to, the Azure portal, Azure PowerShell, and Azure CLI. |
| 23 | + |
| 24 | +# [Azure portal](#tab/portal) |
| 25 | + |
| 26 | +**Define a subnet for Private Link Configuration** |
| 27 | + |
| 28 | +To enable Private Link Configuration, a subnet, different from the Application Gateway subnet, is required for the private link IP configuration. Private Link must use a subnet that doesn't contain any Application Gateways. Subnet sizing can be determined by the number of connections required for your deployment. Each IP address allocated to this subnet ensures 64-K concurrent TCP connections that can be established via Private Link at single point in time. Allocate more IP addresses to allow more connections via Private Link. For example: `n * 64K`; where `n` is the number of IP addresses being provisioned. |
| 29 | + |
| 30 | +> [!Note] |
| 31 | +> The maximum number of IP addresses per private link configuration is eight. Only dynamic allocation is supported. |
| 32 | +
|
| 33 | +The following steps can be completed to create a new subnet: |
| 34 | + |
| 35 | +[Add, change, or delete a virtual network subnet](../virtual-network/virtual-network-manage-subnet.md#add-a-subnet) |
| 36 | + |
| 37 | +**Configure Private Link** |
| 38 | + |
| 39 | +The Private link configuration defines the infrastructure used by Application Gateway to enable connections from Private Endpoints. To create the Private link configuration, complete the following steps: |
| 40 | + |
| 41 | +1. Go to the [Azure portal](https://portal.azure.com) |
| 42 | +1. Search for and select **Application Gateways**. |
| 43 | +1. Select the name of the application gateway you want to enable private link. |
| 44 | +1. Select **Private link** |
| 45 | +1. Configure the following items: |
| 46 | + |
| 47 | + - **Name**: The name of the private link configuration. |
| 48 | + - **Private link subnet**: The subnet IP addresses should be consumed from. |
| 49 | + - **Frontend IP Configuration**: The frontend IP address that private link should forward traffic to on Application Gateway. |
| 50 | + - **Private IP address settings**: specify at least one IP address |
| 51 | +1. Select **Add**. |
| 52 | + |
| 53 | +**Configure Private Endpoint** |
| 54 | + |
| 55 | +A private endpoint is a network interface that uses a private IP address from the virtual network containing clients wishing to connect to your gateway. Each of the clients will use the private IP address of the Private Endpoint to tunnel traffic to the Application Gateway. To create a private endpoint, complete the following steps: |
| 56 | + |
| 57 | +1. Select the **Private endpoint connections** tab. |
| 58 | +1. Select **Create**. |
| 59 | +1. On the **Basics** tab, configure a resource group, name, and region for the Private Endpoint. Select **Next**. |
| 60 | +1. On the **Resource** tab, select **Next**. |
| 61 | +1. On the **Virtual Network** tab, configure a virtual network and subnet where the private endpoint network interface should be provisioned to. Configure whether the private endpoint should have a dynamic or static IP address. Last, configure if you want a new private link zone to be created to automatically manage IP addressing. Select **Next**. |
| 62 | +1. On the **Tags** tab, optionally configure resource tags. Select **Next**. |
| 63 | +1. Select **Create**. |
| 64 | + |
| 65 | +> [!Note] |
| 66 | +> If the public or private IP configuration resource is missing when trying to select a _Target sub-resource_ on the _Resource_ tab of private endpoint creation, please ensure a listener is actively utilizing the respected frontend IP configuration. Frontend IP configurations without an associated listener will not be shown as a _Target sub-resource_. |
| 67 | +
|
| 68 | +# [Azure PowerShell](#tab/powershell) |
| 69 | + |
| 70 | +To configure Private link on an existing Application Gateway via Azure PowerShell, the following commands can be referenced: |
| 71 | + |
| 72 | +```azurepowershell |
| 73 | +# Disable Private Link Service Network Policies |
| 74 | +# https://docs.microsoft.com/azure/private-link/disable-private-endpoint-network-policy |
| 75 | +$net =@{ |
| 76 | + Name = 'AppGW-PL-PSH' |
| 77 | + ResourceGroupName = 'AppGW-PL-PSH-RG' |
| 78 | +} |
| 79 | +$vnet = Get-AzVirtualNetwork @net |
| 80 | +
|
| 81 | +($vnet | Select -ExpandProperty subnets | Where-Object {$_.Name -eq 'AppGW-PL-Subnet'}).PrivateLinkServiceNetworkPolicies = "Disabled" |
| 82 | +
|
| 83 | +$vnet | Set-AzVirtualNetwork |
| 84 | +
|
| 85 | +# Get Application Gateway Frontend IP Name |
| 86 | +$agw = Get-AzApplicationGateway -Name AppGW-PL-PSH -ResourceGroupName AppGW-PL-PSH-RG |
| 87 | +# List the names |
| 88 | +$agw.FrontendIPConfigurations | Select Name |
| 89 | +
|
| 90 | +# Add a new Private Link configuration and associate it with an existing Frontend IP |
| 91 | +$PrivateLinkIpConfiguration = New-AzApplicationGatewayPrivateLinkIpConfiguration ` |
| 92 | + -Name "ipConfig01" ` |
| 93 | + -Subnet ($vnet | Select -ExpandProperty subnets | Where-Object {$_.Name -eq 'AppGW-PL-Subnet'}) ` |
| 94 | + -Primary |
| 95 | +
|
| 96 | +# Add the Private Link configuration to the gateway configuration |
| 97 | +Add-AzApplicationGatewayPrivateLinkConfiguration ` |
| 98 | + -ApplicationGateway $agw ` |
| 99 | + -Name "privateLinkConfig01" ` |
| 100 | + -IpConfiguration $PrivateLinkIpConfiguration |
| 101 | +
|
| 102 | +# Associate private link configuration to Frontend IP |
| 103 | +$agwPip = ($agw | Select -ExpandProperty FrontendIpConfigurations| Where-Object {$_.Name -eq 'appGwPublicFrontendIp'}).PublicIPAddress.Id |
| 104 | +$privateLinkConfiguration = ($agw | Select -ExpandProperty PrivateLinkConfigurations | Where-Object {$_.Name -eq 'privateLinkConfig01'}).Id |
| 105 | +Set-AzApplicationGatewayFrontendIPConfig -ApplicationGateway $agw -Name "appGwPublicFrontendIp" -PublicIPAddressId $agwPip -PrivateLinkConfigurationId $privateLinkConfiguration |
| 106 | +
|
| 107 | +# Apply the change to the gateway |
| 108 | +Set-AzApplicationGateway -ApplicationGateway $agw |
| 109 | +
|
| 110 | +# Disable Private Endpoint Network Policies |
| 111 | +# https://docs.microsoft.com/azure/private-link/disable-private-endpoint-network-policy |
| 112 | +$net =@{ |
| 113 | + Name = 'AppGW-PL-Endpoint-PSH-VNET' |
| 114 | + ResourceGroupName = 'AppGW-PL-Endpoint-PSH-RG' |
| 115 | +} |
| 116 | +$vnet_plendpoint = Get-AzVirtualNetwork @net |
| 117 | +
|
| 118 | +($vnet_plendpoint | Select -ExpandProperty subnets | Where-Object {$_.Name -eq 'MySubnet'}).PrivateEndpointNetworkPolicies = "Disabled" |
| 119 | +
|
| 120 | +$vnet_plendpoint | Set-AzVirtualNetwork |
| 121 | +
|
| 122 | +# Create Private Link Endpoint - Group ID is the same as the frontend IP configuration |
| 123 | +$privateEndpointConnection = New-AzPrivateLinkServiceConnection -Name "AppGW-PL-Connection" -PrivateLinkServiceId $agw.Id -GroupID "appGwPublicFrontendIp" |
| 124 | +
|
| 125 | +## Create private endpoint |
| 126 | +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 |
| 127 | +``` |
| 128 | +A list of all Azure PowerShell references for Private Link Configuration on Application Gateway can be found here: |
| 129 | +- [Get-AzApplicationGatewayPrivateLinkConfiguration](/powershell/module/az.network/get-azapplicationgatewayprivatelinkconfiguration) |
| 130 | +- [New-AzApplicationGatewayPrivateLinkConfiguration](/powershell/module/az.network/new-azapplicationgatewayprivatelinkconfiguration) |
| 131 | +- [New-AzApplicationGatewayPrivateLinkIpConfiguration](/powershell/module/az.network/new-azapplicationgatewayprivatelinkipconfiguration) |
| 132 | +- [Add-AzApplicationGatewayPrivateLinkConfiguration](/powershell/module/az.network/add-azapplicationgatewayprivatelinkconfiguration) |
| 133 | +- [Remove-AzApplicationGatewayPrivateLinkConfiguration](/powershell/module/az.network/remove-azapplicationgatewayprivatelinkconfiguration) |
| 134 | +- [Set-AzApplicationGatewayPrivateLinkConfiguration](/powershell/module/az.network/set-azapplicationgatewayprivatelinkconfiguration) |
| 135 | + |
| 136 | +# [Azure CLI](#tab/cli) |
| 137 | + |
| 138 | +To configure Private link on an existing Application Gateway via Azure CLI, the following commands can be referenced: |
| 139 | + |
| 140 | +```azurecli |
| 141 | +# Disable Private Link Service Network Policies |
| 142 | +# https://docs.microsoft.com/en-us/azure/private-link/disable-private-endpoint-network-policy |
| 143 | +az network vnet subnet update \ |
| 144 | + --name AppGW-PL-Subnet \ |
| 145 | + --vnet-name AppGW-PL-CLI-VNET \ |
| 146 | + --resource-group AppGW-PL-CLI-RG \ |
| 147 | + --disable-private-link-service-network-policies true |
| 148 | +
|
| 149 | +# Get Application Gateway Frontend IP Name |
| 150 | +az network application-gateway frontend-ip list \ |
| 151 | + --gateway-name AppGW-PL-CLI \ |
| 152 | + --resource-group AppGW-PL-CLI-RG |
| 153 | +
|
| 154 | +# Add a new Private Link configuration and associate it with an existing Frontend IP |
| 155 | +az network application-gateway private-link add \ |
| 156 | + --frontend-ip appGwPublicFrontendIp \ |
| 157 | + --name privateLinkConfig01 \ |
| 158 | + --subnet /subscriptions/XXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/AppGW-PL-CLI-RG/providers/Microsoft.Network/virtualNetworks/AppGW-PL-CLI-VNET/subnets/AppGW-PL-Subnet \ |
| 159 | + --gateway-name AppGW-PL-CLI \ |
| 160 | + --resource-group AppGW-PL-CLI-RG |
| 161 | +
|
| 162 | +# Get Private Link resource ID |
| 163 | +az network application-gateway private-link list \ |
| 164 | + --gateway-name AppGW-PL-CLI \ |
| 165 | + --resource-group AppGW-PL-CLI-RG |
| 166 | +
|
| 167 | +
|
| 168 | +
|
| 169 | +# Disable Private Endpoint Network Policies |
| 170 | +# https://docs.microsoft.com/en-us/azure/private-link/disable-private-endpoint-network-policy |
| 171 | +az network vnet subnet update \ |
| 172 | + --name MySubnet \ |
| 173 | + --vnet-name AppGW-PL-Endpoint-CLI-VNET \ |
| 174 | + --resource-group AppGW-PL-Endpoint-CLI-RG \ |
| 175 | + --disable-private-endpoint-network-policies true |
| 176 | +
|
| 177 | +# Create Private Link Endpoint - Group ID is the same as the frontend IP configuration |
| 178 | +az network private-endpoint create \ |
| 179 | + --name AppGWPrivateEndpoint \ |
| 180 | + --resource-group AppGW-PL-Endpoint-CLI-RG \ |
| 181 | + --vnet-name AppGW-PL-Endpoint-CLI-VNET \ |
| 182 | + --subnet MySubnet \ |
| 183 | + --group-id appGwPublicFrontendIp \ |
| 184 | + --private-connection-resource-id /subscriptions/XXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/AppGW-PL-CLI-RG/providers/Microsoft.Network/applicationGateways/AppGW-PL-CLI \ |
| 185 | + --connection-name AppGW-PL-Connection |
| 186 | +``` |
| 187 | + |
| 188 | +A list of all Azure CLI references for Private Link Configuration on Application Gateway can be found here: [Azure CLI CLI - Private Link](/cli/azure/network/application-gateway/private-link) |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +## Next steps |
| 193 | + |
| 194 | +- Learn about Azure Private Link: [What is Azure Private Link?](../private-link/private-link-overview.md) |
0 commit comments