Skip to content

Commit da17416

Browse files
Merge pull request #289703 from v-jaswel/aca/v-jaswel_work_20241031_work_item_336243
[ACA] Add how-to for AFD integration.
2 parents 3b17323 + bd80b6a commit da17416

File tree

2 files changed

+273
-0
lines changed

2 files changed

+273
-0
lines changed

articles/container-apps/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@
302302
href: vnet-custom.md
303303
- name: Deploy with an internal environment
304304
href: vnet-custom-internal.md
305+
- name: Integrate with Azure Front Door
306+
href: how-to-integrate-with-azure-front-door.md
305307
- name: Ingress
306308
items:
307309
- name: Overview
Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
---
2+
title: Access an Azure container app using an Azure Front Door
3+
description: Learn how to access an Azure container app using an Azure Front Door.
4+
services: container-apps
5+
author: craigshoemaker
6+
ms.service: azure-container-apps
7+
ms.custom: devx-track-azurepowershell, devx-track-azurecli
8+
ms.topic: how-to
9+
ms.date: 11/6/2024
10+
ms.author: cshoe
11+
---
12+
13+
# Create a private link to an Azure Container App with Azure Front Door (preview)
14+
15+
In this article, you learn how to connect directly from Azure Front Door to your Azure Container Apps using a private link instead of the public internet. In this tutorial, you create an Azure Container Apps workload profiles environment, an Azure Front Door, and connect them securely through a private link. You then verify the connectivity between your container app and the Azure Front Door.
16+
17+
## Prerequisites
18+
19+
- Azure account with an active subscription.
20+
- If you don't have one, you [can create one for free](https://azure.microsoft.com/free/).
21+
22+
- This feature is only available with the [Azure CLI](/cli/azure/install-azure-cli). To ensure you're running the latest version of the Azure CLI, run the following command.
23+
24+
```azurecli
25+
az upgrade
26+
```
27+
28+
- The latest version of the Azure Container Apps extension for the Azure CLI. To ensure you're running the latest version, run the following command.
29+
30+
```azurecli
31+
az extension add --name containerapp --upgrade --allow-preview true
32+
```
33+
34+
> [!NOTE]
35+
> Starting in May 2024, Azure CLI extensions no longer enable preview features by default. To access Container Apps [preview features](./whats-new.md), install the Container Apps extension with `--allow-preview true`.
36+
37+
- This feature is only supported for workload profile environments.
38+
39+
For more information about prerequisites and setup, see [Quickstart: Deploy your first container app with containerapp up](get-started.md?tabs=bash).
40+
41+
## Set environment variables
42+
43+
Set the following environment variables.
44+
45+
```azurecli
46+
RESOURCE_GROUP="my-container-apps"
47+
LOCATION="centralus"
48+
ENVIRONMENT_NAME="my-environment"
49+
CONTAINERAPP_NAME="my-container-app"
50+
AFD_PROFILE="my-afd-profile"
51+
AFD_ENDPOINT="my-afd-endpoint"
52+
AFD_ORIGIN_GROUP="my-afd-origin-group"
53+
AFD_ORIGIN="my-afd-origin"
54+
AFD_ROUTE="my-afd-route"
55+
```
56+
57+
## Create an Azure resource group
58+
59+
Create a resource group to organize the services related to your container app deployment.
60+
61+
```azurecli
62+
az group create \
63+
--name $RESOURCE_GROUP \
64+
--location $LOCATION
65+
```
66+
67+
## Create an environment
68+
69+
1. Create the Container Apps environment.
70+
71+
```azurecli
72+
az containerapp env create \
73+
--name $ENVIRONMENT_NAME \
74+
--resource-group $RESOURCE_GROUP \
75+
--location $LOCATION
76+
```
77+
78+
1. Retrieve the environment ID. You use this to configure the environment.
79+
80+
```azurecli
81+
ENVIRONMENT_ID=$(az containerapp env show \
82+
--resource-group $RESOURCE_GROUP \
83+
--name $ENVIRONMENT_NAME \
84+
--query "id" \
85+
--output tsv)
86+
```
87+
88+
1. Disable public network access for the environment.
89+
90+
```azurecli
91+
az containerapp env update \
92+
--id $ENVIRONMENT_ID \
93+
--public-network-access Disabled
94+
```
95+
96+
## Deploy a container app
97+
98+
1. Run the following command to deploy a container app in your environment.
99+
100+
```azurecli
101+
az containerapp up \
102+
--name $CONTAINERAPP_NAME \
103+
--resource-group $RESOURCE_GROUP \
104+
--location $LOCATION \
105+
--environment $ENVIRONMENT_NAME \
106+
--image mcr.microsoft.com/k8se/quickstart:latest \
107+
--target-port 80 \
108+
--ingress external \
109+
--query properties.configuration.ingress.fqdn
110+
```
111+
112+
1. Retrieve your container app endpoint.
113+
114+
```azurecli
115+
ACA_ENDPOINT=$(az containerapp show \
116+
--name $CONTAINERAPP_NAME \
117+
--resource-group $RESOURCE_GROUP \
118+
--query properties.configuration.ingress.fqdn \
119+
--output tsv)
120+
```
121+
122+
If you browse to the container app endpoint, you receive `ERR_CONNECTION_CLOSED` because the container app environment has public access disabled. Instead, you use an AFD endpoint to access your container app.
123+
124+
## Create an Azure Front Door profile
125+
126+
Create an AFD profile. Private link is not supported for origins in an AFD profile with SKU `Standard_AzureFrontDoor`.
127+
128+
```azurecli
129+
az afd profile create \
130+
--profile-name $AFD_PROFILE \
131+
--resource-group $RESOURCE_GROUP \
132+
--sku Premium_AzureFrontDoor
133+
```
134+
135+
## Create an Azure Front Door endpoint
136+
137+
Add an endpoint to your AFD profile.
138+
139+
```azurecli
140+
az afd endpoint create \
141+
--resource-group $RESOURCE_GROUP \
142+
--endpoint-name $AFD_ENDPOINT \
143+
--profile-name $AFD_PROFILE \
144+
--enabled-state Enabled
145+
```
146+
147+
## Create an Azure Front Door origin group
148+
149+
Create an AFD origin group.
150+
151+
```azurecli
152+
az afd origin-group create \
153+
--resource-group $RESOURCE_GROUP \
154+
--origin-group-name $AFD_ORIGIN_GROUP \
155+
--profile-name $AFD_PROFILE \
156+
--probe-request-type GET \
157+
--probe-protocol Http \
158+
--probe-interval-in-seconds 60 \
159+
--probe-path / \
160+
--sample-size 4 \
161+
--successful-samples-required 3 \
162+
--additional-latency-in-milliseconds 50
163+
```
164+
165+
## Create an Azure Front Door origin
166+
167+
Add an AFD origin to your origin group.
168+
169+
```azurecli
170+
az afd origin create \
171+
--resource-group $RESOURCE_GROUP \
172+
--origin-group-name $AFD_ORIGIN_GROUP \
173+
--origin-name $AFD_ORIGIN \
174+
--profile-name $AFD_PROFILE \
175+
--host-name $ACA_ENDPOINT \
176+
--origin-host-header $ACA_ENDPOINT \
177+
--priority 1 \
178+
--weight 500 \
179+
--enable-private-link true \
180+
--private-link-location $LOCATION \
181+
--private-link-request-message "AFD Private Link Request" \
182+
--private-link-resource $ENVIRONMENT_ID \
183+
--private-link-sub-resource-type managedEnvironments
184+
```
185+
186+
## List private endpoint connections
187+
188+
1. Run the following command to list the private endpoint connections for your environment.
189+
190+
```azurecli
191+
az network private-endpoint-connection list \
192+
--name $ENVIRONMENT_NAME \
193+
--resource-group $RESOURCE_GROUP \
194+
--type Microsoft.App/managedEnvironments
195+
```
196+
197+
1. Record the private endpoint connection resource ID from the response. The private endpoint connection has a `properties.privateLinkServiceConnectionState.description` value of `AFD Private Link Request`. The private endpoint connection resource ID looks like the following.
198+
199+
```
200+
/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.App/managedEnvironments/my-environment/privateEndpointConnections/<PRIVATE_ENDPOINT_CONNECTION_ID>
201+
```
202+
203+
Don't confuse this with the private endpoint ID, which looks like the following.
204+
205+
```
206+
/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/eafd-Prod-centralus/providers/Microsoft.Network/privateEndpoints/<PRIVATE_ENDPOINT_ID>
207+
```
208+
209+
## Approve the private endpoint connection
210+
211+
Run the following command to approve the connection. Replace the \<PLACEHOLDER\> with the private endpoint connection resource ID you recorded in the previous section.
212+
213+
```azurecli
214+
az network private-endpoint-connection approve --id <PRIVATE_ENDPOINT_CONNECTION_RESOURCE_ID>
215+
```
216+
217+
## Add a route
218+
219+
Run the following command to map the endpoint you created earlier to the origin group.
220+
221+
```azurecli
222+
az afd route create \
223+
--resource-group $RESOURCE_GROUP \
224+
--profile-name $AFD_PROFILE \
225+
--endpoint-name $AFD_ENDPOINT \
226+
--forwarding-protocol MatchRequest \
227+
--route-name $AFD_ROUTE \
228+
--https-redirect Enabled \
229+
--origin-group $AFD_ORIGIN_GROUP \
230+
--supported-protocols Http Https \
231+
--link-to-default-domain Enabled
232+
```
233+
234+
## Access your container app from Azure Front Door
235+
236+
1. Retrieve the hostname of your AFD endpoint.
237+
238+
```azurecli
239+
az afd endpoint show \
240+
--resource-group $RESOURCE_GROUP \
241+
--profile-name $AFD_PROFILE \
242+
--endpoint-name $AFD_ENDPOINT \
243+
--query hostName \
244+
--output tsv
245+
```
246+
247+
Your hostname looks like the following example.
248+
249+
```
250+
my-afd-endpoint.<HASH>.b01.azurefd.net
251+
```
252+
253+
1. Browse to the hostname. You see the output for the quickstart container app image.
254+
255+
It takes a few minutes for your AFD profile to be deployed globally, so if you do not see the expected output at first, wait a few minutes and then refresh.
256+
257+
## Clean up resources
258+
259+
If you're not going to continue to use this application, you can remove the **my-container-apps** resource group. This deletes the Azure Container Apps instance and all associated services. It also deletes the resource group that the Container Apps service automatically created and which contains the custom network components.
260+
261+
> [!CAUTION]
262+
> The following command deletes the specified resource group and all resources contained within it. If resources outside the scope of this guide exist in the specified resource group, they will also be deleted.
263+
264+
```azurecli-interactive
265+
az group delete --name $RESOURCE_GROUP
266+
```
267+
268+
## Related content
269+
270+
- [Azure Private Link](/azure/private-link/private-link-overview)
271+
- [Azure Front Door](/azure/frontdoor/)

0 commit comments

Comments
 (0)