Skip to content

Commit 138cfaf

Browse files
add custom domain how-to
1 parent 8640568 commit 138cfaf

File tree

3 files changed

+176
-13
lines changed

3 files changed

+176
-13
lines changed

articles/container-apps/TOC.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,12 @@
376376
href: waf-app-gateway.md
377377
- name: Enable User Defined Routes (UDR)
378378
href: user-defined-routes.md
379-
- name: Use rule-based routing
380-
href: rule-based-routing.md
379+
- name: Rule based routing
380+
items:
381+
- name: Use rule-based routing
382+
href: rule-based-routing.md
383+
- name: Configure a custom domain
384+
href: rule-based-routing-custom-domain.md
381385
- name: Securing a custom VNET with an NSG
382386
href: firewall-integration.md
383387
- name: Use a private endpoint
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
---
2+
title: Use a custom domain with rule-based routing in Azure Container Apps (preview)
3+
description: Learn how to configure a custom domain with rule-based routing in Azure Container Apps.
4+
services: container-apps
5+
author: craigshoemaker
6+
ms.service: azure-container-apps
7+
ms.custom: devx-track-azurecli, devx-track-bicep
8+
ms.topic: how-to
9+
ms.date: 04/15/2025
10+
ms.author: cshoe
11+
zone_pivot_groups: azure-cli-bicep
12+
---
13+
14+
# Use a custom domain with rule-based routing in Azure Container Apps (preview)
15+
16+
HTTP route configurations support custom domains, allowing you to route traffic from your own domain names to your container apps.
17+
18+
## Prerequisites
19+
20+
- An existing Azure Container Apps environment
21+
- A custom domain that you own
22+
- SSL certificate for your domain (unless using automatic certificates)
23+
- Container apps deployed to your environment
24+
25+
> [!NOTE]
26+
> To set up your own custom domain and certificate, see [Custom domain names and free managed certificates](./custom-domains-managed-certificates.md).
27+
>
28+
> If you set `bindingType: "Auto"`, you don't need a `certificateId`. Container Apps creates the certificate for you based on the domain.
29+
30+
## Configuration
31+
32+
Update your Container Apps YAML file to include a `customDomains` section. The following example demonstrates how to set up this configuration.
33+
34+
```yml
35+
customDomains:
36+
- name: "<CUSTOM_DOMAIN_ENDPOINT>"
37+
certificateId: "<CERTIFICATE_ID>"
38+
bindingType: "SniEnabled" # Can also be "Disabled", "Auto"
39+
rules:
40+
- description: "Routing to App1"
41+
routes:
42+
- match:
43+
prefix: "/1"
44+
action:
45+
prefixRewrite: "/"
46+
targets:
47+
- containerApp: "<CONTAINER_APP_NAME>"
48+
- description: "Routing to App2"
49+
routes:
50+
- match:
51+
prefix: "/2"
52+
action:
53+
prefixRewrite: "/"
54+
targets:
55+
- containerApp: "<CONTAINER_APP_NAME>"
56+
```
57+
58+
This YAML configuration defines two routing rules for HTTP traffic.
59+
60+
| Property | Description |
61+
|---|---|
62+
| `customDomains.name` | The domain name you want to use (example: "app.contoso.com") |
63+
| `customDomains.certificateId` | Resource ID of your certificate (not needed with `bindingType: "Auto"`) |
64+
| `customDomains.bindingType` | How SSL is handled: "SniEnabled" (Server Name Indication), "Disabled" (HTTP only), or "Auto" (automatic certificate) |
65+
| `description` | Human-readable label for the rule |
66+
| `routes.match.prefix` | URL path prefix to match (example: "/api") |
67+
| `routes.action.prefixRewrite` | What to replace the matched prefix with before forwarding |
68+
| `targets.containerApp` | The name of the container app to route matching requests to |
69+
70+
These rules allow different paths on your custom domain to route to different container apps while also modifying the request path before it reaches the destination app.
71+
72+
## Work with your custom domain
73+
74+
Use the following commands to configure and use your custom domain mapping.
75+
76+
Before running the following commands, make sure to replace placeholders surrounded by `<>` with your own values.
77+
78+
### List route configurations
79+
80+
Use `az containerapp env http-route-config list` to list all the defined route configurations.
81+
82+
```azurecli
83+
az containerapp env http-route-config list \
84+
--resource-group <RESOURCE_GROUP_NAME> \
85+
--name <ENVIRONMENT_NAME>
86+
```
87+
88+
### Create a new route configuration
89+
90+
Use `az containerapp env http-route-config create` to create a new route configuration.
91+
92+
```azurecli
93+
az containerapp env http-route-config create \
94+
--resource-group <RESOURCE_GROUP_NAME> \
95+
--name <ENVIRONMENT_NAME> \
96+
--http-route-config-name <CONFIGURATION_NAME> \
97+
--yaml <CONTAINER_APPS_CONFIG_FILE>
98+
```
99+
100+
### Update a route configuration
101+
102+
Use `az containerapp env http-route-config update` to update an existing route configuration.
103+
104+
```azurecli
105+
az containerapp env http-route-config update \
106+
--resource-group <RESOURCE_GROUP_NAME> \
107+
--name <ENVIRONMENT_NAME> \
108+
--http-route-config-name <CONFIGURATION_NAME> \
109+
--yaml <CONTAINER_APPS_CONFIG_FILE>
110+
```
111+
112+
### Show a specific route configuration
113+
114+
Use `az containerapp env http-route-config show` to view details of a route configuration.
115+
116+
```azurecli
117+
az containerapp env http-route-config show \
118+
--resource-group <RESOURCE_GROUP_NAME> \
119+
--name <ENVIRONMENT_NAME> \
120+
--http-route-config-name <CONFIGURATION_NAME>
121+
```
122+
123+
### Delete a route configuration
124+
125+
Use `az containerapp env http-route-config delete` to remove a route configuration.
126+
127+
```azurecli
128+
az containerapp env http-route-config delete \
129+
--resource-group <RESOURCE_GROUP_NAME> \
130+
--name <ENVIRONMENT_NAME> \
131+
--http-route-config-name <CONFIGURATION_NAME>
132+
```
133+
134+
## Verify HTTP routing
135+
136+
After configuring your custom domain with rule-based routing:
137+
138+
1. Navigate to your custom domain in a browser. For example, `https://app.contoso.com/1`.
139+
140+
1. Verify that the request is routed to the first container app.
141+
142+
1. Change the path to `/2`. For example, `https://app.contoso.com/2`.
143+
144+
1. Verify that the request is now routed to the second container app.
145+
146+
## Related content
147+
148+
- [Rule-based routing in Azure Container Apps](./rule-based-routing.md)
149+
- [Custom domain names and free managed certificates](./custom-domains-managed-certificates.md)
150+
- [Azure CLI reference for HTTP route configuration](/cli/azure/containerapp/env/http-route-config)
151+
152+
> [!TIP]
153+
> Having issues? Let us know on GitHub by opening an issue in the [Azure Container Apps repo](https://github.com/microsoft/azure-container-apps).

articles/container-apps/rule-based-routing.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ services: container-apps
55
author: craigshoemaker
66
ms.service: azure-container-apps
77
ms.custom: devx-track-azurecli, devx-track-bicep
8-
ms.topic: how-to
9-
ms.date: 04/03/2025
8+
ms.topic: tutorial
9+
ms.date: 04/15/2025
1010
ms.author: cshoe
1111
zone_pivot_groups: azure-cli-bicep
1212
---
@@ -44,7 +44,7 @@ az upgrade
4444

4545
Ignore any warnings about modules currently in use.
4646

47-
Next, install or update the Azure Container Apps extension for the CLI.
47+
Install or update the Azure Container Apps extension for the CLI.
4848

4949
If you receive errors about missing parameters when you run `az containerapp` commands in Azure CLI or cmdlets from the `Az.App` module in PowerShell, be sure you have the latest version of the Azure Container Apps extension installed.
5050

@@ -54,6 +54,7 @@ az extension add --name containerapp --upgrade
5454

5555
> [!NOTE]
5656
> 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`.
57+
>
5758
> ```azurecli
5859
> az extension add --name containerapp --upgrade --allow-preview true
5960
> ```
@@ -235,7 +236,7 @@ $ROUTE_CONFIG_NAME="my-route-config"
235236
236237
1. In the output, find `outputs`, which contains your HTTP route configuration's fully qualified domain name (FQDN). For example:
237238
238-
```
239+
```json
239240
"outputs": {
240241
"fqdn": {
241242
"type": "String",
@@ -246,26 +247,31 @@ $ROUTE_CONFIG_NAME="my-route-config"
246247
247248
::: zone-end
248249
249-
## Test HTTP route configuration
250+
## Verify HTTP route configuration
251+
252+
1. Browse to your HTTP route configuration FQDN with the path `/app1`.
253+
254+
For example: `my-route-config.ambitiouspebble-11ba6155.eastus.azurecontainerapps.io/app1`.
250255
251-
1. Browse to your HTTP route configuration FQDN with the path `/app1`. For example: `my-route-config.ambitiouspebble-11ba6155.eastus.azurecontainerapps.io/app1`. You see the Container Apps quickstart image.
256+
You see the Container Apps quickstart image.
252257
253-
1. Browse to your HTTP route configuration FQDN with the path `/app2`. For example: `my-route-config.ambitiouspebble-11ba6155.eastus.azurecontainerapps.io/app2`. You see the ASP.NET quickstart image.
258+
1. Browse to your HTTP route configuration FQDN with the path `/app2`.
259+
260+
For example: `my-route-config.ambitiouspebble-11ba6155.eastus.azurecontainerapps.io/app2`.
261+
262+
You see the ASP.NET quickstart image.
254263
255264
## Clean up resources
256265
257266
If you're not going to continue to use this application, run the following command to delete the resource group along with all the resources created in this quickstart.
258267
259268
> [!CAUTION]
260-
> The following command deletes the specified resource group and all resources contained within it. If resources outside the scope of this quickstart exist in the specified resource group, they will also be deleted.
269+
> The following command deletes the specified resource group and all resources contained within it. If resources outside the scope of this quickstart exist in the specified resource group, they'll also be deleted.
261270
262271
```azurecli
263272
az group delete --name my-container-apps
264273
```
265274

266-
> [!TIP]
267-
> Having issues? Let us know on GitHub by opening an issue in the [Azure Container Apps repo](https://github.com/microsoft/azure-container-apps).
268-
269275
## Related content
270276

271277
- [Azure CLI reference](/cli/azure/containerapp/env/http-route-config)

0 commit comments

Comments
 (0)