Skip to content

Commit 802b407

Browse files
author
Moary Chen
authored
Add readme description for spring kv sample on how to authenticate using certificate (Azure#18465)
1 parent 03fb570 commit 802b407

File tree

1 file changed

+29
-3
lines changed
  • sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-keyvault-secrets

1 file changed

+29
-3
lines changed

sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-keyvault-secrets/README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,25 @@ az keyvault secret set --name <yourSecretPropertyName> \
5656
--vault-name <your_keyvault_name>
5757
```
5858

59-
59+
- If you want to use certificate authentication, upload the certificate file to App registrations in Azure Active Directory by using Azure Portal.
60+
You can manually add a new application or use the service principal created in the previous step.
61+
62+
1. Select **App registrations**, then select the application name or service principal name just created.
63+
64+
1. Select **Certificates & secrets**, then select **Upload Certificate**, upload your cer, pem, or crt type certificate, click **Add** button to complete the upload.
65+
66+
1. If you add a new application, grant appropriate permissions to the application created.
67+
68+
You can use the following az cli commands:
69+
```bash
70+
az keyvault set-policy --name <your_keyvault_name> \
71+
--secret-permission get list \
72+
--spn <your_application_id_create_in_current_step>
73+
```
6074
## Examples
6175

62-
### Add the property setting
63-
Open `application.properties` file and add below properties to specify your Azure Key Vault url, Azure service principle client id and client key.
76+
### The service-principal-based authentication property setting
77+
Open `application.properties` file and add below properties to specify your Azure Key Vault url, Azure service principal client id and client key.
6478

6579
```properties
6680
azure.keyvault.uri=put-your-azure-keyvault-uri-here
@@ -89,6 +103,18 @@ The valid secret-service-version value can be found [here][version_link].
89103

90104
If property not set, the property will be filled with the latest value.
91105

106+
### The certificate-based authentication property setting
107+
If you use certificate authentication, you only need to replace the property `azure.keyvault.client-key` with `azure.keyvault.certificate-path`, which points to your certificate.
108+
109+
```properties
110+
azure.keyvault.uri=put-your-azure-keyvault-uri-here
111+
azure.keyvault.client-id=put-your-azure-client-id-here
112+
azure.keyvault.certificate-path=put-your-certificate-file-path-here
113+
azure.keyvault.tenant-id=put-your-azure-tenant-id-here
114+
azure.keyvault.authority-host=put-your-own-authority-host-here(fill with default value if empty)
115+
azure.keyvault.secret-service-version=specify secretServiceVersion value(fill with default value if empty)
116+
```
117+
92118
## Run with Maven
93119
```
94120
cd azure-spring-boot-samples/azure-spring-boot-sample-keyvault-secrets

0 commit comments

Comments
 (0)