Skip to content

Commit

Permalink
Fixes #336 - Add Java example snippet (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Jan 18, 2024
1 parent 2691b82 commit 5da9ce2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions azure-keyvault/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5da9ce2

Please sign in to comment.