From 5da9ce20b9f205b04d3564eb138c81d23bc95abb Mon Sep 17 00:00:00 2001 From: Manfred Riem Date: Thu, 18 Jan 2024 13:55:17 -0600 Subject: [PATCH] Fixes #336 - Add Java example snippet (#337) --- azure-keyvault/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/azure-keyvault/README.md b/azure-keyvault/README.md index 1ff6ba7..2bb2f1e 100644 --- a/azure-keyvault/README.md +++ b/azure-keyvault/README.md @@ -76,6 +76,25 @@ For example: -v $PWD/certs:/home/piranha/certs manorrock/ocelot-azure-keyvault ``` +## How do you use this with the Azure SDK for Java? + +The sample snippet below shows you how you would interact with the simulator +using the Azure SDK for Java. + +```java + var credential = new BasicAuthenticationCredential("username", "password"); + var keyVaultUri = "https://localhost:8200"; + var secretClient = new SecretClientBuilder() + .vaultUrl(keyVaultUri) + .credential(credential) + .httpLogOptions(new HttpLogOptions().setLogLevel(BODY_AND_HEADERS)) + .disableChallengeResourceVerification() + .buildClient(); + + secretClient.setSecret("mySecret", "mySecretValue"); + String value = secretClient.getSecret("mySecret"); +``` + ## Supported operations 1. [Get Secret](https://learn.microsoft.com/en-us/rest/api/keyvault/secrets/get-secret/get-secret?view=rest-keyvault-secrets-7.4&tabs=HTTP)