You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/container-apps/custom-domains-certificates.md
+169-6Lines changed: 169 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,9 @@ author: craigshoemaker
6
6
ms.service: azure-container-apps
7
7
ms.custom: build-2023, ignite-2024
8
8
ms.topic: how-to
9
-
ms.date: 05/28/2024
9
+
ms.date: 1/14/2025
10
10
ms.author: cshoe
11
+
zone_pivot_groups: azure-cli-or-portal
11
12
---
12
13
13
14
# Custom domain names and bring your own certificates in Azure Container Apps
@@ -20,12 +21,14 @@ Azure Container Apps allows you to bind one or more custom domains to a containe
20
21
- Ingress must be enabled for the container app.
21
22
22
23
> [!NOTE]
23
-
> If you configure a [custom environment DNS (Domain Name System) suffix](environment-custom-dns-suffix.md), you cannot add a custom domain that contains this suffix to your Container App.
24
+
> If you configure a [custom environment DNS (Domain Name System) suffix](environment-custom-dns-suffix.md), you can't add a custom domain that contains this suffix to your Container App.
24
25
25
26
## Add a custom domain and certificate
26
27
28
+
::: zone pivot="azure-portal"
29
+
27
30
> [!IMPORTANT]
28
-
> If you are using a new certificate, you must have an existing [SNI domain certificate](https://wikipedia.org/wiki/Server_Name_Indication) file available to upload to Azure.
31
+
> If you're using a new certificate, you must have an existing [SNI domain certificate](https://wikipedia.org/wiki/Server_Name_Indication) file available to upload to Azure.
29
32
30
33
1. Navigate to your container app in the [Azure portal](https://portal.azure.com)
31
34
@@ -63,7 +66,7 @@ Azure Container Apps allows you to bind one or more custom domains to a containe
63
66
| Apex domain | A record | An apex domain is a domain at the root level of your domain. For example, if your DNS (Domain Name System) zone is `contoso.com`, then `contoso.com` is the apex domain. |
64
67
| Subdomain | CNAME | A subdomain is a domain that is part of another domain. For example, if your DNS zone is `contoso.com`, then `www.contoso.com` is an example of a subdomain that can be configured in the zone. |
65
68
66
-
1. Using the DNS provider that is hosting your domain, create DNS records based on the *Hostname record type* you selected using the values shown in the *Domain validation* section. The records point the domain to your container app and verify that you own it. The setup depends on whether you are using custom domains with the private endpoint (preview) feature:
69
+
1. Using the DNS provider that is hosting your domain, create DNS records based on the *Hostname record type* you selected using the values shown in the *Domain validation* section. The records point the domain to your container app and verify that you own it. The setup depends on whether you're using custom domains with the private endpoint (preview) feature:
67
70
68
71
# [General](#tab/general)
69
72
@@ -89,7 +92,7 @@ Azure Container Apps allows you to bind one or more custom domains to a containe
89
92
|--|--|--|
90
93
| A |`@`| The Private IP of your private endpoint on your container apps environment. |
91
94
92
-
In addition, you will need to add the following record to your public DNS zone.
95
+
In addition, you'll need to add the following record to your public DNS zone.
93
96
94
97
| Record type | Host | Value |
95
98
|--|--|--|
@@ -111,7 +114,167 @@ Azure Container Apps allows you to bind one or more custom domains to a containe
111
114
1. Once the operation is complete, you see your domain name in the list of custom domains with a status of *Secured*. Navigate to your domain to verify that it's accessible.
112
115
113
116
> [!NOTE]
114
-
> For container apps in internal Container Apps environments, [additional configuration](./networking.md#dns) is required to use custom domains with VNET-scope ingress.
117
+
> For container apps in internal Container Apps environments, [extra configuration](./networking.md#dns) is required to use custom domains with VNET-scope ingress.
118
+
119
+
::: zone-end
120
+
121
+
::: zone pivot="azure-cli"
122
+
123
+
Container Apps supports apex domains and subdomains. Each domain type requires a different DNS record type and validation method.
124
+
125
+
| Domain type | Record type | Validation method | Notes |
126
+
|--|--|--|--|
127
+
| Apex domain | A record | HTTP | An apex domain is a domain at the root level of your domain. For example, if your DNS zone is `contoso.com`, then `contoso.com` is the apex domain. |
128
+
| Subdomain | CNAME | CNAME | A subdomain is a domain that is part of another domain. For example, if your DNS zone is `contoso.com`, then `www.contoso.com` is an example of a subdomain that can be configured in the zone. |
129
+
130
+
1. Log in to Azure with the Azure CLI.
131
+
132
+
```azurecli
133
+
az login
134
+
```
135
+
136
+
1. Next, install the Azure Container Apps extension for the CLI.
137
+
138
+
```azurecli
139
+
az extension add --name containerapp --upgrade
140
+
```
141
+
142
+
1. Set the following environment variables. Replace the `<PLACEHOLDERS>` with your values.
- Replace `<CERTIFICATE_LOCAL_PATH>` with the local path of your certificate file.
156
+
- Replace `<CERTIFICATE_LOWERCASE_NAME>` with a lowercase certificate name that is unique within the environment.
157
+
- Replace `<TARGET_PORT>` with the port that your container app is listening on.
158
+
159
+
1. Verify that your container app has HTTP ingress enabled.
160
+
161
+
```azurecli
162
+
az containerapp ingress show \
163
+
-n $CONTAINER_APP \
164
+
-g $RESOURCE_GROUP
165
+
```
166
+
167
+
If ingress isn't enabled, enable it with these steps:
168
+
169
+
```azurecli
170
+
az containerapp ingress enable \
171
+
-n $CONTAINER_APP \
172
+
-g $RESOURCE_GROUP \
173
+
--type external \
174
+
--target-port $TARGET_PORT \
175
+
--transport auto
176
+
```
177
+
178
+
1. If you're configuring an apex domain, get the IP address of your Container Apps environment.
179
+
180
+
```azurecli
181
+
az containerapp env show \
182
+
-n $ENVIRONMENT \
183
+
-g $RESOURCE_GROUP \
184
+
-o tsv \
185
+
--query "properties.staticIp"
186
+
```
187
+
188
+
1. If you're configuring a subdomain, get the automatically generated domain of your container app.
189
+
190
+
```azurecli
191
+
az containerapp show \
192
+
-n $CONTAINER_APP \
193
+
-g $RESOURCE_GROUP \
194
+
-o tsv \
195
+
--query "properties.configuration.ingress.fqdn"
196
+
```
197
+
198
+
1. Get the domain verification code.
199
+
200
+
```azurecli
201
+
az containerapp show \
202
+
-n $CONTAINER_APP \
203
+
-g $RESOURCE_GROUP \
204
+
-o tsv \
205
+
--query "properties.customDomainVerificationId"
206
+
```
207
+
208
+
1. Using the DNS provider that is hosting your domain, create DNS records based on the record type you selected using the values shown in the *Domain validation* section. The records point the domain to your container app and verify that you own it. The setup depends on whether you're using custom domains with the private endpoint (preview) feature:
209
+
210
+
# [General](#tab/general)
211
+
212
+
- If you selected *A record*, create the following DNS records:
213
+
214
+
| Record type | Host | Value |
215
+
|--|--|--|
216
+
| A | `@` | The IP address of your Container Apps environment. |
217
+
| TXT | `asuid` | The domain verification code. |
218
+
219
+
- If you selected *CNAME*, create the following DNS records:
220
+
221
+
| Record type | Host | Value |
222
+
|--|--|--|
223
+
| CNAME | The subdomain (for example, `www`) | The generated domain of your container app. |
224
+
| TXT | `asuid.` followed by the subdomain (for example, `asuid.www`) | The domain verification code. |
225
+
226
+
# [Private endpoint](#tab/private-endpoint)
227
+
228
+
When using a private endpoint for your incoming traffic, you need to [create a private DNS zone](how-to-use-private-endpoint.md#configure-the-private-dns-zone).
229
+
230
+
- If you selected *A record*, create the following DNS records:
231
+
232
+
| Record type | Host | Value |
233
+
|--|--|--|
234
+
| A | `@` | The Private IP of your private endpoint on your container apps environment. |
235
+
| TXT | `asuid` | The domain verification code. |
236
+
237
+
- If you selected *CNAME*, create the following DNS records:
238
+
239
+
| Record type | Host | Value |
240
+
|--|--|--|
241
+
| CNAME | The subdomain (for example, `www`) | The generated domain of your container app. |
242
+
| TXT | `asuid.` followed by the subdomain (for example, `asuid.www`) | The domain verification code. |
243
+
244
+
---
245
+
246
+
1. Upload the certificate to your environment.
247
+
248
+
```azurecli
249
+
az containerapp env certificate upload \
250
+
-g $RESOURCE_GROUP \
251
+
--name $ENVIRONMENT \
252
+
--certificate-file $CERTIFICATE_LOCAL_PATH \
253
+
--password $CERTIFICATE_PASSWORD \
254
+
--certificate-name $CERTIFICATE_LOWERCASE_NAME
255
+
```
256
+
257
+
1. Bind the certificate and domain to your container app.
258
+
259
+
```azurecli
260
+
az containerapp hostname bind \
261
+
--hostname $DOMAIN_NAME \
262
+
-g $RESOURCE_GROUP \
263
+
-n $CONTAINER_APP \
264
+
--environment $ENVIRONMENT \
265
+
--certificate $CERTIFICATE_LOWERCASE_NAME \
266
+
--validation-method <VALIDATION_METHOD>
267
+
```
268
+
269
+
- If you're configuring an *A record*, replace `<VALIDATION_METHOD>` with `HTTP`.
270
+
271
+
- If you're configuring a *CNAME*, replace `<VALIDATION_METHOD>` with `CNAME`.
272
+
273
+
It might take several minutes to issue the certificate and add the domain to your container app.
274
+
275
+
1. Once the operation is complete, navigate to your domain to verify that it's accessible.
@@ -18,7 +18,7 @@ Azure Container Apps allows you to bind one or more custom domains to a containe
18
18
If you want to set up a custom domain using your own certificate, see [Custom domain names and certificates in Azure Container Apps](custom-domains-certificates.md).
19
19
20
20
> [!NOTE]
21
-
> If you configure a [custom environment DNS suffix](environment-custom-dns-suffix.md), you cannot add a custom domain that contains this suffix to your Container App.
21
+
> If you configure a [custom environment DNS suffix](environment-custom-dns-suffix.md), you can't add a custom domain that contains this suffix to your Container App.
22
22
23
23
## Free certificate requirements
24
24
@@ -30,10 +30,11 @@ The requirements are:
30
30
31
31
- Must have an A record for apex domains that points to your Container Apps environment's IP address.
32
32
33
-
- Establish a CNAME record for subdomains that maps directly to the container app's automatically generated domain name. Mapping to an intermediate CNAME value blocks certificate issuance and renewal. Examples of CNAME values are traffic managers, Cloudflare, and similar services.
33
+
- Establish a CNAME record for subdomains that maps directly to the container app's generated domain name. Mapping to an intermediate CNAME value blocks certificate issuance and renewal. Examples of CNAME values are traffic managers, Cloudflare, and similar services.
34
34
35
35
> [!NOTE]
36
36
> To ensure the certificate issuance and subsequent renewals proceed successfully, all requirements must be met at all times when the managed certificate is assigned.
37
+
37
38
## Add a custom domain and managed certificate
38
39
39
40
::: zone pivot="azure-portal"
@@ -98,7 +99,7 @@ Container Apps supports apex domains and subdomains. Each domain type requires a
98
99
| Apex domain | A record | HTTP | An apex domain is a domain at the root level of your domain. For example, if your DNS zone is `contoso.com`, then `contoso.com` is the apex domain. |
99
100
| Subdomain | CNAME | CNAME | A subdomain is a domain that is part of another domain. For example, if your DNS zone is `contoso.com`, then `www.contoso.com` is an example of a subdomain that can be configured in the zone. |
100
101
101
-
1. Log in to Azure with the Azure CLI.
102
+
1. Log in to Azure with the Azure CLI.
102
103
103
104
```azurecli
104
105
az login
@@ -110,46 +111,73 @@ Container Apps supports apex domains and subdomains. Each domain type requires a
110
111
az extension add --name containerapp --upgrade
111
112
```
112
113
114
+
1. Set the following environment variables. Replace the `<PLACEHOLDERS>` with your values.
- Replace `<CERTIFICATE_LOCAL_PATH>` with the local path of your certificate file.
128
+
- Replace `<CERTIFICATE_LOWERCASE_NAME>` with a lowercase certificate name that is unique within the environment.
129
+
- Replace `<TARGET_PORT>` with the port that your container app is listening on.
130
+
113
131
1. Verify that your container app has HTTP ingress enabled.
114
132
115
133
```azurecli
116
-
az containerapp ingress show -n <CONTAINER_APP_NAME> -g <RESOURCE_GROUP_NAME>
134
+
az containerapp ingress show \
135
+
-n $CONTAINER_APP \
136
+
-g $RESOURCE_GROUP
117
137
```
118
138
119
139
If ingress isn't enabled, enable it with these steps:
120
140
121
141
```azurecli
122
-
az containerapp ingress enable -n <CONTAINER_APP_NAME> -g <RESOURCE_GROUP_NAME> \
123
-
--type external --target-port <TARGET_PORT> --transport auto
142
+
az containerapp ingress enable \
143
+
-n $CONTAINER_APP \
144
+
-g $RESOURCE_GROUP \
145
+
--type external \
146
+
--target-port $TARGET_PORT \
147
+
--transport auto
124
148
```
125
149
126
-
Replace `<CONTAINER_APP_NAME>` with the name of your container app, `<RESOURCE_GROUP_NAME>` with the name of the resource group that contains your container app, and `<TARGET_PORT>` with the port that your container app is listening on.
127
-
128
150
1. If you're configuring an apex domain, get the IP address of your Container Apps environment.
129
151
130
152
```azurecli
131
-
az containerapp env show -n <ENVIRONMENT_NAME> -g <RESOURCE_GROUP_NAME> -o tsv --query "properties.staticIp"
153
+
az containerapp env show \
154
+
-n $ENVIRONMENT \
155
+
-g $RESOURCE_GROUP \
156
+
-o tsv \
157
+
--query "properties.staticIp"
132
158
```
133
159
134
-
Replace `<ENVIRONMENT_NAME>` with the name of your environment, and `<RESOURCE_GROUP_NAME>` with the name of the resource group that contains your environment.
135
-
136
160
1. If you're configuring a subdomain, get the automatically generated domain of your container app.
137
161
138
162
```azurecli
139
-
az containerapp show -n <CONTAINER_APP_NAME> -g <RESOURCE_GROUP_NAME> -o tsv --query "properties.configuration.ingress.fqdn"
163
+
az containerapp show \
164
+
-n $CONTAINER_APP \
165
+
-g $RESOURCE_GROUP \
166
+
-o tsv \
167
+
--query "properties.configuration.ingress.fqdn"
140
168
```
141
169
142
-
Replace `<CONTAINER_APP_NAME>` with the name of your container app, and `<RESOURCE_GROUP_NAME>` with the name of the resource group that contains your container app.
143
-
144
170
1. Get the domain verification code.
145
171
146
172
```azurecli
147
-
az containerapp show -n <CONTAINER_APP_NAME> -g <RESOURCE_GROUP_NAME> -o tsv --query "properties.customDomainVerificationId"
173
+
az containerapp show \
174
+
-n $CONTAINER_APP \
175
+
-g $RESOURCE_GROUP \
176
+
-o tsv \
177
+
--query "properties.customDomainVerificationId"
148
178
```
149
179
150
-
Replace `<CONTAINER_APP_NAME>` with the name of your container app, and `<RESOURCE_GROUP_NAME>` with the name of the resource group that contains your container app.
151
-
152
-
1. Using the DNS provider that is hosting your domain, create DNS records based on the record type you selected using the values shown in the *Domain validation* section. The records point the domain to your container app and verify that you own it. The setup depends on whether you are using custom domains with the private endpoint (preview) feature:
180
+
1. Using the DNS provider that is hosting your domain, create DNS records based on the record type you selected using the values shown in the *Domain validation* section. The records point the domain to your container app and verify that you own it. The setup depends on whether you're using custom domains with the private endpoint (preview) feature:
153
181
154
182
# [General](#tab/general)
155
183
@@ -166,10 +194,10 @@ Container Apps supports apex domains and subdomains. Each domain type requires a
166
194
|--|--|--|
167
195
| CNAME | The subdomain (for example, `www`) | The generated domain of your container app. |
168
196
| TXT | `asuid.` followed by the subdomain (for example, `asuid.www`) | The domain verification code. |
169
-
197
+
170
198
# [Private endpoint](#tab/private-endpoint)
171
199
172
-
When using a private endpoint for your incoming traffic, you need to [create a private DNS zone](how-to-use-private-endpoint.md#configure-the-private-dns-zone).
200
+
When using a private endpoint for your incoming traffic, you need to [create a private DNS zone](how-to-use-private-endpoint.md#configure-the-private-dns-zone).
173
201
174
202
- If you selected *A record*, create the following DNS records:
175
203
@@ -190,20 +218,25 @@ Container Apps supports apex domains and subdomains. Each domain type requires a
190
218
1. Add the domain to your container app.
191
219
192
220
```azurecli
193
-
az containerapp hostname add --hostname <DOMAIN_NAME> -g <RESOURCE_GROUP_NAME> -n <CONTAINER_APP_NAME>
221
+
az containerapp hostname add \
222
+
--hostname $DOMAIN_NAME \
223
+
-g $RESOURCE_GROUP \
224
+
-n $CONTAINER_APP
194
225
```
195
226
196
-
Replace `<DOMAIN_NAME>` with the domain name you want to add, `<RESOURCE_GROUP_NAME>` with the name of the resource group that contains your container app, and `<CONTAINER_APP_NAME>` with the name of your container app.
197
-
198
227
1. Configure the managed certificate and bind the domain to your container app.
Replace `<DOMAIN_NAME>` with the domain name you want to add, `<RESOURCE_GROUP_NAME>` with the name of the resource group that contains your container app, `<CONTAINER_APP_NAME>` with the name of your container app, and `<ENVIRONMENT_NAME>` with the name of your environment.
205
-
206
238
- If you're configuring an *A record*, replace `<VALIDATION_METHOD>` with `HTTP`.
239
+
207
240
- If you're configuring a *CNAME*, replace `<VALIDATION_METHOD>` with `CNAME`.
208
241
209
242
It might take several minutes to issue the certificate and add the domain to your container app.
0 commit comments