|
| 1 | +--- |
| 2 | +title: Map a custom domain to Azure Spring Apps with the Standard consumption plan |
| 3 | +description: Learn how to map a web domain to apps in Azure Spring Apps. |
| 4 | +author: karlerickson |
| 5 | +ms.author: haojianzhong |
| 6 | +ms.service: spring-apps |
| 7 | +ms.topic: quickstart |
| 8 | +ms.date: 03/21/2023 |
| 9 | +ms.custom: devx-track-java |
| 10 | +--- |
| 11 | + |
| 12 | +# Map a custom domain to Azure Spring Apps with the Standard consumption plan |
| 13 | + |
| 14 | +**This article applies to:** ✔️ Standard consumption (Preview) ❌ Basic/Standard ❌ Enterprise |
| 15 | + |
| 16 | + This article shows you how to map a custom web site domain, such as `https://www.contoso.com`, to your app in Azure Spring Apps. This mapping is accomplished by using a `CNAME` record that the Domain Name Service (DNS) uses to store node names throughout the network. |
| 17 | + |
| 18 | +The mapping secures the custom domain with a certificate and enforces Transport Layer Security (TLS), also known as the Secure Sockets Layer (SSL). |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- An Azure subscription. If you don't have a subscription, create a [free account](https://azure.microsoft.com/free/) before you begin. |
| 23 | +- [Azure CLI](/cli/azure/install-azure-cli) |
| 24 | +- An application deployed to Azure Spring Apps. For more information, see [Quickstart: Build and deploy apps to Azure Spring Apps](/azure/spring-apps/quickstart-deploy-apps). |
| 25 | +- A domain name registered in the DNS registry as provided by a web hosting or domain provider. |
| 26 | +- A certificate resource created under an Azure Container Apps environment. For more information, see [Add certificate in Container App](../container-apps/custom-domains-certificates.md). |
| 27 | + |
| 28 | +## Map a custom domain |
| 29 | + |
| 30 | +To map the custom domain, you create the CNAME record and then use the Azure CLI to bind the domain to an app in Azure Spring Apps. |
| 31 | + |
| 32 | +First, use the following steps to create the `CNAME` record: |
| 33 | + |
| 34 | +1. Contact your DNS provider to request a `CNAME` record to map your domain to the Full Qualified Domain Name (FQDN) of your Spring app. |
| 35 | + |
| 36 | +1. Add a `TXT` record with the name `asuid.{subdomain}` with the value being the verification ID of your Azure Container Apps environment. You can obtain this value by using the following command. |
| 37 | + |
| 38 | + ```azurecli |
| 39 | + az containerapp env show \ |
| 40 | + --resource-group <resource-group-name> \ |
| 41 | + --name <Azure-Container-Apps-environment-name> \ |
| 42 | + --query 'properties.customDomainConfiguration.customDomainVerificationId' |
| 43 | + ``` |
| 44 | + |
| 45 | + After you add the `CNAME` and `TXT` record, the DNS records page will resemble the following table. |
| 46 | + |
| 47 | + | Name | Type | Value | |
| 48 | + |---------------------|---------|--------------------------------------------------------------------| |
| 49 | + | `{subdomain}` | `CNAME` | `testapp.agreeablewater-4c8480b3.eastus.azurecontainerapps.io` | |
| 50 | + | `asuid.{subdomain}` | `A` | `6K861CL04CATKUCFF604024064D57PB52F5DF7B67BC3033BA9808BDA8998U270` | |
| 51 | + |
| 52 | +1. Next, bind the custom domain to your app by using the following command. |
| 53 | + |
| 54 | + ```azurecli |
| 55 | + az spring app custom-domain bind \ |
| 56 | + --resource-group <resource-group-name> \ |
| 57 | + --service <Azure-Spring-Apps-service-instance-name> \ |
| 58 | + --app <app-name> \ |
| 59 | + --domain-name <your-custom-domain-name> \ |
| 60 | + --certificate <name-of-your-certificate-under-Azure-Container-Apps-environment> |
| 61 | + ``` |
| 62 | + |
| 63 | +## Clean up resources |
| 64 | + |
| 65 | +Be sure to delete the resources you created in this article when you no longer need them. To delete the resources, just delete the resource group that contains them. You can delete the resource group using the Azure portal. Alternately, to delete the resource group by using Azure CLI, use the following commands: |
| 66 | + |
| 67 | +```azurecli |
| 68 | +echo "Enter the Resource Group name:" && |
| 69 | +read resourceGroupName && |
| 70 | +az group delete --name $resourceGroupName && |
| 71 | +echo "Press [ENTER] to continue ..." |
| 72 | +``` |
| 73 | + |
| 74 | +## Next steps |
| 75 | + |
| 76 | +- [Azure Spring Apps documentation](./index.yml) |
0 commit comments