Skip to content

Commit d11fdde

Browse files
authored
Merge pull request #215032 from hui1110/delete_raw_sdk_part
Remove the KV secret SDK section in the tutorial Managed identity to connect Key Vault
2 parents 79b4714 + 81f314c commit d11fdde

File tree

1 file changed

+0
-70
lines changed

1 file changed

+0
-70
lines changed

articles/spring-apps/tutorial-managed-identities-key-vault.md

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -241,76 +241,6 @@ spring.cloud.azure.keyvault.secret.property-sources[0].credential.client-id={Cli
241241

242242
You'll see the message `Successfully got the value of secret connectionString from Key Vault https://<your-keyvault-name>.vault.azure.net/: jdbc:sqlserver://SERVER.database.windows.net:1433;database=DATABASE;`.
243243

244-
## Build the sample Spring Boot app with Java SDK
245-
246-
This sample can set and get secrets from Azure Key Vault. The [Azure Key Vault Secret client library for Java](/java/api/overview/azure/security-keyvault-secrets-readme) provides Azure Active Directory token authentication support across the Azure SDK. The library provides a set of `TokenCredential` implementations that you can use to construct Azure SDK clients to support Azure AD token authentication.
247-
248-
The Azure Key Vault Secret client library enables you to securely store and control the access to tokens, passwords, API keys, and other secrets. The library offers operations to create, retrieve, update, delete, purge, back up, restore, and list the secrets and its versions.
249-
250-
To build the sample, use the following steps:
251-
252-
1. Clone the sample project.
253-
254-
```azurecli
255-
git clone https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples.git
256-
```
257-
258-
1. Specify your key vault in your app.
259-
260-
```azurecli
261-
cd Azure-Spring-Cloud-Samples/managed-identity-keyvault
262-
vim src/main/resources/application.properties
263-
```
264-
265-
To use managed identity for Azure Spring Apps apps, add properties with the following content to *src/main/resources/application.properties*.
266-
267-
```properties
268-
azure.keyvault.enabled=true
269-
azure.keyvault.uri=https://<your-keyvault-name>.vault.azure.net
270-
```
271-
272-
1. Include [ManagedIdentityCredentialBuilder](/java/api/com.azure.identity.managedidentitycredentialbuilder) to get a token from Azure Active Directory and [SecretClientBuilder](/java/api/com.azure.security.keyvault.secrets.secretclientbuilder) to set or get secrets from Key Vault in your code.
273-
274-
Get the example from the [MainController.java](https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples/blob/master/managed-identity-keyvault/src/main/java/com/microsoft/azure/MainController.java#L28) file of the cloned sample project.
275-
276-
Include `azure-identity` and `azure-security-keyvault-secrets` as a dependency in your *pom.xml* file. Get the example from the [pom.xml](https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples/blob/master/managed-identity-keyvault/pom.xml#L21) file of the cloned sample project.
277-
278-
1. Use the following command to package your sample app.
279-
280-
```azurecli
281-
mvn clean package
282-
```
283-
284-
1. Now deploy the app to Azure with the following command:
285-
286-
```azurecli
287-
az spring app deploy \
288-
--resource-group <your-resource-group-name> \
289-
--name "springapp" \
290-
--service <your-Azure-Spring-Apps-instance-name> \
291-
--jar-path target/asc-managed-identity-keyvault-sample-0.1.0.jar
292-
```
293-
294-
1. Access the public endpoint or test endpoint to test your app.
295-
296-
First, get the value of your secret that you set in Azure Key Vault.
297-
298-
```azurecli
299-
curl https://myspringcloud-springapp.azuremicroservices.io/secrets/connectionString
300-
```
301-
302-
You'll see the message `Successfully got the value of secret connectionString from Key Vault https://<your-keyvault-name>.vault.azure.net/: jdbc:sqlserver://SERVER.database.windows.net:1433;database=DATABASE;`.
303-
304-
Now create a secret and then retrieve it using the Java SDK.
305-
306-
```azurecli
307-
curl -X PUT https://myspringcloud-springapp.azuremicroservices.io/secrets/test?value=success
308-
309-
curl https://myspringcloud-springapp.azuremicroservices.io/secrets/test
310-
```
311-
312-
You'll see the message `Successfully got the value of secret test from Key Vault https://<your-keyvault-name>.vault.azure.net: success`.
313-
314244
## Next steps
315245

316246
* [How to access Storage blob with managed identity in Azure Spring Apps](https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples/tree/master/managed-identity-storage-blob)

0 commit comments

Comments
 (0)