-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from chenrujun/update-keyvault-secret-to-versi…
…on-4.0 Update keyvault secret to version 4.0
- Loading branch information
Showing
13 changed files
with
185 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 0 additions & 149 deletions
149
keyvault/azure-spring-boot-starter-keyvault-secrets/keyvault-secrets/README.md
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
keyvault/azure-spring-boot-starter-keyvault-secrets/keyvault-secrets/pom.xml
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...-spring-boot-starter-keyvault-secrets/keyvault-secrets/src/main/resources/application.yml
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
.../spring-cloud-azure-starter-keyvault-secrets/multiple-property-source/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
# Spring Cloud Azure Starter Key Vault Secrets Sample | ||
|
||
This sample illustrates the simplest usage of `spring-cloud-azure-starter-keyvault-secrets`. To learn all features, please refer to [reference doc](https://microsoft.github.io/spring-cloud-azure/docs/4.0.0-beta.1/reference/html/index.html). | ||
|
||
## Create Azure resources | ||
|
||
1. Read [document about register an application](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app), register an application. get the `Application (client) ID`: **${AZURE_CLIENT_ID_1}**, and create a secret, get the `Client Secret Value`: **${AZURE_CLIENT_SECRET_1}**. | ||
2. Read [document about create key vault](https://docs.microsoft.com/en-us/azure/key-vault/general/quick-create-portal), get the `Directory ID`: **${AZURE_TENANT_ID_1}** and `Vault URI` **${ENDPOINT_1}**. | ||
3. Read [document about assign Key Vault access policy](https://docs.microsoft.com/en-us/azure/key-vault/general/assign-access-policy?tabs=azure-portal), assign `Secret Management` template to the client(or principal) we created in step 1. | ||
4. Same to previous steps, get **${AZURE_CLIENT_ID_2}**, **${AZURE_CLIENT_SECRET_2}**, **${AZURE_TENANT_ID_2}** and **${ENDPOINT_1}**. assign `Secret Management` template to the **${AZURE_CLIENT_ID_2}. | ||
|
||
## Fill the values in application.yml | ||
Fill these values in application.yml: **${AZURE_TENANT_ID_1}**, **${AZURE_CLIENT_ID_1}**, **${AZURE_CLIENT_SECRET_1}**, **${ENDPOINT_1}**, **${AZURE_TENANT_ID_2}**, **${AZURE_CLIENT_ID_2}**, **${AZURE_CLIENT_SECRET_2}**, **${ENDPOINT_2}**. | ||
|
||
## Start application | ||
Start the application, you will see a log like this: | ||
```text | ||
secretNameInKeyVault1: secret-value-1 | ||
secretNameInKeyVault2: secret-name-in-key-vault-2-value-2 | ||
secretNameInKeyVaultBoth: secret-value-1 | ||
``` | ||
|
||
We can see that property-source-1 have higher priority. | ||
|
33 changes: 33 additions & 0 deletions
33
keyvault/spring-cloud-azure-starter-keyvault-secrets/multiple-property-source/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.azure.spring</groupId> | ||
<artifactId>azure-spring-boot-samples</artifactId> | ||
<version>1.0.0</version> | ||
<relativePath>../../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>spring-cloud-azure-starter-keyvault-secrets-sample-multiple-property-source</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.azure.spring</groupId> | ||
<artifactId>spring-cloud-azure-starter-keyvault-secrets</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-actuator</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
31 changes: 31 additions & 0 deletions
31
...va/com/azure/spring/keyvault/secrets/sample/single/property/source/SampleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.spring.keyvault.secrets.sample.single.property.source; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SampleApplication implements CommandLineRunner { | ||
|
||
@Value("${secret-name-in-key-vault-1}") | ||
private String secretNameInKeyVault1; | ||
@Value("${secret-name-in-key-vault-2}") | ||
private String secretNameInKeyVault2; | ||
@Value("${secret-name-in-key-vault-both}") | ||
private String secretNameInKeyVaultBoth; | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SampleApplication.class, args); | ||
} | ||
|
||
public void run(String[] args) { | ||
System.out.println("secretNameInKeyVault1: " + secretNameInKeyVault1); | ||
System.out.println("secretNameInKeyVault2: " + secretNameInKeyVault2); | ||
System.out.println("secretNameInKeyVaultBoth: " + secretNameInKeyVaultBoth); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...zure-starter-keyvault-secrets/multiple-property-source/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
spring: | ||
cloud: | ||
azure: | ||
keyvault: | ||
secret: | ||
property-source-enabled: true | ||
property-sources: | ||
- | ||
name: key-vault-1 | ||
endpoint: ${ENDPOINT_1} | ||
profile: | ||
tenant-id: ${AZURE_TENANT_ID_1} | ||
credential: | ||
client-id: ${AZURE_CLIENT_ID_1} | ||
client-secret: ${AZURE_CLIENT_SECRET_1} | ||
- | ||
name: key-vault-2 | ||
endpoint: ${ENDPOINT_2} | ||
profile: | ||
tenant-id: ${AZURE_TENANT_ID_2} | ||
credential: | ||
client-id: ${AZURE_CLIENT_ID_2} | ||
client-secret: ${AZURE_CLIENT_SECRET_2} |
21 changes: 21 additions & 0 deletions
21
...lt/spring-cloud-azure-starter-keyvault-secrets/single-property-source/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
# Spring Cloud Azure Starter Key Vault Secrets Sample | ||
|
||
This sample illustrates the simplest usage of `spring-cloud-azure-starter-keyvault-secrets`. To learn all features, please refer to [reference doc](https://microsoft.github.io/spring-cloud-azure/docs/4.0.0-beta.1/reference/html/index.html). | ||
|
||
## Create Azure resources | ||
|
||
1. Read [document about register an application](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app), register an application. get the `Application (client) ID`: **${AZURE_CLIENT_ID}**, and create a secret, get the `Client Secret Value`: **${AZURE_CLIENT_SECRET}**. | ||
2. Read [document about create key vault](https://docs.microsoft.com/en-us/azure/key-vault/general/quick-create-portal), get the `Directory ID`: **${AZURE_TENANT_ID}** and `Vault URI` **${ENDPOINT}**. | ||
3. Read [document about assign Key Vault access policy](https://docs.microsoft.com/en-us/azure/key-vault/general/assign-access-policy?tabs=azure-portal), assign `Secret Management` template to the client(or principal) we created in step 1. | ||
|
||
## Fill the values in application.yml | ||
Fill these values in application.yml: **${AZURE_TENANT_ID}**, **${AZURE_CLIENT_ID}**, **${AZURE_CLIENT_SECRET}**, **${ENDPOINT}**. | ||
|
||
## Start application | ||
Start the application, you will see a log like this: | ||
```text | ||
property springDataSourceUrl in Azure Key Vault: <spring-data-source-url-value> | ||
``` | ||
|
||
|
Oops, something went wrong.