|
| 1 | +--- |
| 2 | +title: 'Connect Azure Front Door Premium to an application gateway origin with Private Link (preview)' |
| 3 | +titleSuffix: Azure Private Link |
| 4 | +description: Learn how to connect your Azure Front Door Premium to an application gateway privately. |
| 5 | +services: frontdoor |
| 6 | +author: duongau |
| 7 | +ms.service: azure-frontdoor |
| 8 | +ms.topic: how-to |
| 9 | +ms.date: 09/18/2024 |
| 10 | +ms.author: duau |
| 11 | +zone_pivot_groups: front-door-dev-exp-ps-cli |
| 12 | +--- |
| 13 | + |
| 14 | +# Connect Azure Front Door Premium to an application gateway with Private Link |
| 15 | +This article will guide you through how to configure Azure Front Door Premium tier to connect to your application gateway privately using the Azure Private Link service. |
| 16 | + |
| 17 | +::: zone pivot="front-door-cli" |
| 18 | + |
| 19 | +## Prerequisites - CLI |
| 20 | + |
| 21 | +[!INCLUDE [azure-cli-prepare-your-environment](~/reusable-content/azure-cli/azure-cli-prepare-your-environment.md)] |
| 22 | + |
| 23 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 24 | +- Have a functioning Azure Front Door Premium profile and an endpoint. For more information on how to create an Azure Front Door profile, see [Create a Front Door - CLI](create-front-door-cli.md). |
| 25 | +- Have a functioning Azure Application Gateway. For more information on how to create an Application Gateway, see [Direct web traffic with Azure Application Gateway - Azure CLI](/articles/application-gateway/quick-create-cli.md). |
| 26 | + |
| 27 | +## Enable Private Link on Application Gateway |
| 28 | +Follow the steps in [Configure Azure Application Gateway Private Link](/articles/application-gateway/private-link-configure.md). Skip the last step of creating a private endpoint. |
| 29 | + |
| 30 | +## Create origin group and origin on Azure Front Door |
| 31 | + |
| 32 | +1. Run [az afd origin-group create](/cli/azure/afd/origin-group#az-afd-origin-group-create) to create an origin group. |
| 33 | + |
| 34 | +```azurecli-interactive |
| 35 | +az afd origin-group create \ |
| 36 | + --resource-group myRGFD \ |
| 37 | + --origin-group-name og \ |
| 38 | + --profile-name contosoafd \ |
| 39 | + --probe-request-type GET \ |
| 40 | + --probe-protocol Http \ |
| 41 | + --probe-interval-in-seconds 60 \ |
| 42 | + --probe-path / \ |
| 43 | + --sample-size 4 \ |
| 44 | + --successful-samples-required 3 \ |
| 45 | + --additional-latency-in-milliseconds 50 |
| 46 | +``` |
| 47 | +2. Run [az afd origin create](/cli/azure/afd/origin#az-afd-origin-create) to add your application gateway as an origin to your origin group. |
| 48 | + |
| 49 | +```azurecli-interactive |
| 50 | +az afd origin create \ |
| 51 | + --enabled-state Enabled \ |
| 52 | + --resource-group myRGFD \ |
| 53 | + --origin-group-name og \ |
| 54 | + --origin-name appgwog \ |
| 55 | + --profile-name Hari \ |
| 56 | + --host-name x.x.x.x \ |
| 57 | + --origin-host-header x.x.x.x \ |
| 58 | + --http-port 80 \ |
| 59 | + --https-port 443 \ |
| 60 | + --priority 1 \ |
| 61 | + --weight 500 \ |
| 62 | + --enable-private-link true \ |
| 63 | + --private-link-location centralus \ |
| 64 | + --private-link-request-message 'AFD Private Link request.' \ |
| 65 | + --private-link-resource /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myRGAG/providers/Microsoft.Network/applicationGateways/myAppGateway \ |
| 66 | + --private-link-sub-resource-type appGwPublicFrontendIp |
| 67 | +``` |
| 68 | +> [!NOTE] |
| 69 | +> `SharedPrivateLinkResourceGroupId` is the same as the Application Gateway frontend IP configuration. This value may be different for different frontend IP configurations. |
| 70 | +
|
| 71 | +## Approve Private Endpoint Connection |
| 72 | + |
| 73 | +1. Run [az network private-endpoint-connection list](/cli/azure/network/private-endpoint-connection#az-network-private-endpoint-connection-list) to list the private endpoint connections. Note down the 'Resource ID' of the private endpoint connection available for your application gateway, in the first line of your output. |
| 74 | + |
| 75 | +```azurecli-interactive |
| 76 | + az network private-endpoint-connection list --name myAppGateway --resource-group myRGAG --type Microsoft.Network/applicationgateways |
| 77 | +
|
| 78 | +``` |
| 79 | + |
| 80 | +2. Run [az network private-endpoint-connection approve](/cli/azure/network/private-endpoint-connection#az-network-private-endpoint-connection-approve) to approve the private endpoint connection. |
| 81 | + |
| 82 | +```azurecli-interactive |
| 83 | + az network private-endpoint-connection approve --id /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myRGAG/providers/Microsoft.Network/applicationGateways/myAppGateway/privateEndpointConnections/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| 84 | +
|
| 85 | +``` |
| 86 | +## Complete Azure Front Door setup |
| 87 | +Add a route to map the endpoint that you created earlier to the origin group. This route forwards requests from the endpoint to your origin group. Run [az afd route create](/cli/azure/afd/route#az-afd-route-create) to map your endpoint to the origin group. |
| 88 | + |
| 89 | +```azurecli-interactive |
| 90 | +az afd route create \ |
| 91 | + --resource-group myRGFD \ |
| 92 | + --profile-name contosoafd \ |
| 93 | + --endpoint-name contosofrontend \ |
| 94 | + --forwarding-protocol MatchRequest \ |
| 95 | + --route-name route \ |
| 96 | + --https-redirect Enabled \ |
| 97 | + --origin-group og \ |
| 98 | + --supported-protocols Http Https \ |
| 99 | + --link-to-default-domain Enabled |
| 100 | +``` |
| 101 | +Your Front Door profile has become fully functional with the last step. |
| 102 | +::: zone-end |
| 103 | + |
| 104 | +::: zone pivot="front-door-ps" |
| 105 | + |
| 106 | +## Prerequisites - PowerShell |
| 107 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 108 | +- Azure PowerShell installed locally or Azure Cloud Shell |
| 109 | + |
| 110 | +[!INCLUDE [updated-for-az](~/reusable-content/ce-skilling/azure/includes/updated-for-az.md)] |
| 111 | + |
| 112 | +[!INCLUDE [cloud-shell-try-it.md](~/reusable-content/ce-skilling/azure/includes/cloud-shell-try-it.md)] |
| 113 | +- Have a functioning Azure Front Door Premium profile and an endpoint. For more information on how to create an Azure Front Door profile, see [Create a Front Door - PowerShell](create-front-door-powershell.md). |
| 114 | +- Have a functioning Azure Application Gateway. For more information on how to create an Application Gateway, see [Direct web traffic with Azure Application Gateway using Azure PowerShell](/articles/application-gateway/quick-create-powershell.md) |
| 115 | + |
| 116 | +## Enable Private Link on Application Gateway |
| 117 | +1. Follow the steps in [Configure Azure Application Gateway Private Link](/articles/application-gateway/private-link-configure.md). Skip the last step of creating a private endpoint. |
| 118 | + |
| 119 | +## Create origin group and origin on Azure Front Door |
| 120 | +1. Use [New-AzFrontDoorCdnOriginGroupHealthProbeSettingObject](/powershell/module/az.cdn/new-azfrontdoorcdnorigingrouphealthprobesettingobject) and [New-AzFrontDoorCdnOriginGroupLoadBalancingSettingObject](/powershell/module/az.cdn/new-azfrontdoorcdnorigingrouploadbalancingsettingobject) to create in-memory objects for storing health probe and load balancing settings. Run [New-AzFrontDoorCdnOriginGroup](/powershell/module/az.cdn/new-azfrontdoorcdnorigingroup) to create an origin group that will contain your application gateway. |
| 121 | + |
| 122 | +```azurepowershell-interactive |
| 123 | +# Create health probe settings |
| 124 | +
|
| 125 | +$HealthProbeSetting = New-AzFrontDoorCdnOriginGroupHealthProbeSettingObject ` |
| 126 | + -ProbeIntervalInSecond 60 ` |
| 127 | + -ProbePath "/" ` |
| 128 | + -ProbeRequestType GET ` |
| 129 | + -ProbeProtocol Http |
| 130 | +
|
| 131 | +# Create load balancing settings |
| 132 | +
|
| 133 | +$LoadBalancingSetting = New-AzFrontDoorCdnOriginGroupLoadBalancingSettingObject ` |
| 134 | + -AdditionalLatencyInMillisecond 50 ` |
| 135 | + -SampleSize 4 ` |
| 136 | + -SuccessfulSamplesRequired 3 |
| 137 | +
|
| 138 | +# Create origin group |
| 139 | +
|
| 140 | +$originpool = New-AzFrontDoorCdnOriginGroup ` |
| 141 | + -OriginGroupName og ` |
| 142 | + -ProfileName contosoAFD ` |
| 143 | + -ResourceGroupName myRGFD ` |
| 144 | + -HealthProbeSetting $HealthProbeSetting ` |
| 145 | + -LoadBalancingSetting $LoadBalancingSetting |
| 146 | +``` |
| 147 | +2. Run [New-AzFrontDoorCdnOrigin](/powershell/module/az.cdn/new-azfrontdoorcdnorigin) to add your application gateway to your origin group. |
| 148 | + |
| 149 | +> [!NOTE] |
| 150 | +> 'SharedPrivateLinkResourceGroupId' is the same as the Application Gateway frontend IP configuration. This value may be different for different frontend IP configurations. |
| 151 | +
|
| 152 | +```azurepowershell-interactive |
| 153 | +New-AzFrontDoorCdnOrigin ` |
| 154 | + -OriginGroupName og ` |
| 155 | + -OriginName appgatewayorigin ` |
| 156 | + -ProfileName contosoAFD ` |
| 157 | + -ResourceGroupName myRGFD ` |
| 158 | + -HostName x.x.x.x ` |
| 159 | + -HttpPort 80 ` |
| 160 | + -HttpsPort 443 ` |
| 161 | + -OriginHostHeader x.x.x.x ` |
| 162 | + -Priority 1 ` |
| 163 | + -PrivateLinkId /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myRGAG/providers/Microsoft.Network/applicationGateways/myAppGateway ` |
| 164 | + -SharedPrivateLinkResourceGroupId appGwPublicFrontendIp ` |
| 165 | + -SharedPrivateLinkResourcePrivateLinkLocation CentralUS ` |
| 166 | + -SharedPrivateLinkResourceRequestMessage 'AFD Private Link request' ` |
| 167 | + -Weight 1000 ` |
| 168 | +``` |
| 169 | +## Approve the private endpoint |
| 170 | +1. Run [Get-AzPrivateEndpointConnection](/powershell/module/az.network/get-azprivateendpointconnection) to get the connection name of the private endpoint connection to be approved. |
| 171 | + |
| 172 | +```azurepowershell-interactive |
| 173 | +Get-AzPrivateEndpointConnection -ResourceGroupName myRGAG -ServiceName myAppGateway -PrivateLinkResourceType Microsoft.Network/applicationgateways |
| 174 | +
|
| 175 | +``` |
| 176 | +2. Run [Get-AzPrivateEndpointConnection](/powershell/module/az.network/get-azprivateendpointconnection) to approve the private endpoint connection. The value for the field 'Name' should be the value you received in the previous step. |
| 177 | + |
| 178 | +```azurepowershell-interactive |
| 179 | +
|
| 180 | +Approve-AzPrivateEndpointConnection -Name xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -ResourceGroupName myRGAG -ServiceName myAppGateway -PrivateLinkResourceType Microsoft.Network/applicationgateways |
| 181 | +
|
| 182 | +``` |
| 183 | + |
| 184 | +## Complete Azure Front Door setup |
| 185 | +1. Run [New-AzFrontDoorCdnRoute](/powershell/module/az.cdn/new-azfrontdoorcdnroute) to map your endpoint to the origin group. This route forwards requests from the endpoint to your origin group. |
| 186 | + |
| 187 | + |
| 188 | +```azurepowershell-interactive |
| 189 | +# Create a route to map the endpoint to the origin group |
| 190 | +
|
| 191 | +$Route = New-AzFrontDoorCdnRoute ` |
| 192 | + -EndpointName contosofrontend ` |
| 193 | + -Name defaultroute ` |
| 194 | + -ProfileName contosoAFD ` |
| 195 | + -ResourceGroupName myRGFD ` |
| 196 | + -ForwardingProtocol MatchRequest ` |
| 197 | + -HttpsRedirect Enabled ` |
| 198 | + -LinkToDefaultDomain Enabled ` |
| 199 | + -OriginGroupId og ` |
| 200 | + -SupportedProtocol Http,Https |
| 201 | +``` |
| 202 | +Your Front Door profile has become fully functional with the last step. |
| 203 | + |
| 204 | +::: zone-end |
| 205 | + |
| 206 | +## Commonly seen mistakes |
| 207 | +The following are the commonly seen mistakes while configuring an application gateway origin with private link enabled. |
| 208 | +1. Private link configuration was not set in advance to the Front Door creation steps. |
| 209 | +2. Adding the application gateway origin with privatelink to an existing origin group with public origins. Front door doesn't allow public and private origins in the same origin group. |
| 210 | +3. Wrong Application frontend IP configuration name is passed as the value for GroupId. |
| 211 | + |
| 212 | + |
| 213 | +## Next steps |
| 214 | + |
| 215 | +Learn about [Private Link service with storage account](../storage/common/storage-private-endpoints.md). |
0 commit comments