Skip to content

Commit 014f2bb

Browse files
authored
Merge pull request #115077 from MikeDodaro/addCLI-custom-dns
Add CLI commands from PR #112119
2 parents 214b6bc + 8c15287 commit 014f2bb

File tree

1 file changed

+49
-10
lines changed

1 file changed

+49
-10
lines changed

articles/spring-cloud/spring-cloud-tutorial-custom-domain.md

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Certificates encrypt web traffic. These TLS/SSL certificates can be stored in Az
1616
## Prerequisites
1717
* An application deployed to Azure Spring Cloud (see [Quickstart: Launch an existing Azure Spring Cloud application using the Azure portal](spring-cloud-quickstart-launch-app-portal.md), or use an existing app).
1818
* A domain name with access to the DNS registry for domain provider such as GoDaddy.
19-
* A private certificate from a third-party provider. The certificate must match the domain.
19+
* A private certificate (that is, your self-signed certificate) from a third-party provider. The certificate must match the domain.
2020
* A deployed instance of [Azure Key Vault](https://docs.microsoft.com/azure/key-vault/key-vault-overview)
2121

2222
## Import certificate
@@ -31,20 +31,39 @@ To upload your certificate to key vault:
3131
1. Under **Password**, enter the private key for your certificate.
3232
1. Click **Create**.
3333

34-
![Import certificate 1](./media/custom-dns-tutorial/import-certificate-a.png)
34+
![Import certificate 1](./media/custom-dns-tutorial/import-certificate-a.png)
3535

3636
To import certificate to Azure Spring Cloud:
3737
1. Go to your service instance.
3838
1. From the left navigation pane of your app, select **TLS/SSL settings**.
3939
1. Then click **Import Key Vault Certificate**.
4040

41-
![Import certificate](./media/custom-dns-tutorial/import-certificate.png)
41+
![Import certificate](./media/custom-dns-tutorial/import-certificate.png)
4242

43-
When you have successfully imported your certificate, you'll see it on the list of **Private Key Certificates**.
43+
Or, you can use the Azure CLI to import the certificate:
44+
45+
```
46+
az spring-cloud certificate add --name <cert name> --vault-uri <key vault uri> --vault-certificate-name <key vault cert name>
47+
```
48+
49+
> [!IMPORTANT]
50+
> Ensure you grant Azure Spring Cloud access to your key vault before you execute the previous import certificate command. If you haven't, you can execute the following command to grant the access rights.
51+
52+
```
53+
az keyvault set-policy -g <key vault resource group> -n <key vault name> --object-id 938df8e2-2b9d-40b1-940c-c75c33494239 --certificate-permissions get list
54+
```
55+
56+
When you have successfully imported your certificate, you'll see it in the list of **Private Key Certificates**.
4457

4558
![Private key certificate](./media/custom-dns-tutorial/key-certificates.png)
4659

47-
>[!IMPORTANT]
60+
Or, you can use the Azure CLI to show a list of certificates:
61+
62+
```
63+
az spring-cloud certificate list
64+
```
65+
66+
> [!IMPORTANT]
4867
> To secure a custom domain with this certificate, you still need to bind the certificate to a specific domain. Follow the steps in this document under the heading **Add SSL Binding**.
4968
5069
## Add Custom Domain
@@ -67,27 +86,42 @@ Go to application page.
6786
1. Select **Custom Domain**.
6887
2. Then **Add Custom Domain**.
6988

70-
![Custom domain](./media/custom-dns-tutorial/custom-domain.png)
89+
![Custom domain](./media/custom-dns-tutorial/custom-domain.png)
7190

7291
3. Type the fully qualified domain name for which you added a CNAME record, such as www.contoso.com. Make sure that Hostname record type is set to CNAME (<service_name>.azuremicroservices.io)
7392
4. Click **Validate** to enable the **Add** button.
7493
5. Click **Add**.
7594

76-
![Add custom domain](./media/custom-dns-tutorial/add-custom-domain.png)
95+
![Add custom domain](./media/custom-dns-tutorial/add-custom-domain.png)
96+
97+
Or, you can use the Azure CLI to add a custom domain:
98+
```
99+
az spring-cloud app custom-domain bind --domain-name <domain name> --app <app name>
100+
```
77101

78102
One app can have multiple domains, but one domain can only map to one app. When you've successfully mapped your custom domain to the app, you'll see it on the custom domain table.
79103

80104
![Custom domain table](./media/custom-dns-tutorial/custom-domain-table.png)
81105

82-
>[!NOTE]
106+
Or, you can use the Azure CLI to show a list of custom domains:
107+
```
108+
az spring-cloud app custom-domain list --app <app name>
109+
```
110+
111+
> [!NOTE]
83112
> A **Not Secure** label for your custom domain means that it's not yet bound to an SSL certificate. Any HTTPS request from a browser to your custom domain will receive an error or warning.
84113
85114
## Add SSL binding
86115
In the custom domain table, select **Add ssl binding** as shown in the previous figure.
87116
1. Select your **Certificate** or import it.
88117
1. Click **Save**.
89118

90-
![Add SSL binding](./media/custom-dns-tutorial/add-ssl-binding.png)
119+
![Add SSL binding](./media/custom-dns-tutorial/add-ssl-binding.png)
120+
121+
Or, you can use the Azure CLI to **Add ssl binding**:
122+
```
123+
az spring-cloud app custom-domain update --domain-name <domain name> --certificate <cert name> --app <app name>
124+
```
91125

92126
After you successfully add SSL binding, the domain state will be secure: **Healthy**.
93127

@@ -100,10 +134,15 @@ In your app page, in the left navigation, select **Custom Domain**. Then, set **
100134

101135
![Add SSL binding](./media/custom-dns-tutorial/enforce-http.png)
102136

137+
Or, you can use the Azure CLI to enforce HTTPS:
138+
```
139+
az spring-cloud app update -name <app-name> --https-only <true|false> -g <resource group> --service <service-name>
140+
```
141+
103142
When the operation is complete, navigate to any of the HTTPS URLs that point to your app. Note that HTTP URLs don't work.
104143

105144
## See also
106145
* [What is Azure Key Vault?](https://docs.microsoft.com/azure/key-vault/key-vault-overview)
107146
* [Import a certificate](https://docs.microsoft.com/azure/key-vault/certificate-scenarios#import-a-certificate)
108-
* [Launch your Spring Cloud App using the Azure CLI](https://docs.microsoft.com/azure/spring-cloud/spring-cloud-quickstart-launch-app-cli)
147+
* [Launch your Spring Cloud App by using the Azure CLI](https://docs.microsoft.com/azure/spring-cloud/spring-cloud-quickstart-launch-app-cli)
109148

0 commit comments

Comments
 (0)