Skip to content

Commit

Permalink
Made minor corrections to all KeyVault READMEs. (#13319)
Browse files Browse the repository at this point in the history
* Made minor corrections to all KeyVault READMEs.

* Applied PR feedback.

* Fixed minor grammar issues and added quotation marks where needed.

* Add azure-data-appconfiguration as an AdditionalModule to Keyvault (#13647)

(cherry picked from commit b75d732)

* Made minor fix for the sake of consistency.

Co-authored-by: James Suplizio <jasupliz@microsoft.com>
  • Loading branch information
vcolin7 and JimSuplizio authored Aug 4, 2020
1 parent 7b74e69 commit 3fac428
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 51 deletions.
22 changes: 11 additions & 11 deletions sdk/keyvault/azure-security-keyvault-certificates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certificatePolle
certificateClient.beginCreateCertificate("certificateName", CertificatePolicy.getDefault());
certificatePoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
KeyVaultCertificate certificate = certificatePoller.getFinalResult();
System.out.printf("Certificate created with name \"%s\"\n", certificate.getName());
System.out.printf("Certificate created with name \"%s\"%n", certificate.getName());
```
### Retrieve a certificate
Retrieve a previously stored certificate by calling `getCertificate` or `getCertificateVersion`.
```Java
KeyVaultCertificateWithPolicy certificate = certificateClient.getCertificate("<certificate-name>");
System.out.printf("Recevied certificate with name \"%s\", version %s and secret id %s\n",
System.out.printf("Recevied certificate with name \"%s\", version %s and secret id %s%n",
certificate.getProperties().getName(), certificate.getProperties().getVersion(), certificate.getSecretId());
```
Expand All @@ -159,7 +159,7 @@ KeyVaultCertificate certificate = certificateClient.getCertificate("<certificate
// Update certificate enabled status.
certificate.getProperties().setEnabled(false);
KeyVaultCertificate updatedCertificate = certificateClient.updateCertificateProperties(certificate.getProperties());
System.out.printf("Updated certificate with name \"%s\" and enabled status \"%s\"\n",
System.out.printf("Updated certificate with name \"%s\" and enabled status \"%s\"%n",
updatedCertificate.getProperties().getName(), updatedCertificate.getProperties().isEnabled());
```
Expand Down Expand Up @@ -235,7 +235,7 @@ Retrieve a previously stored certificate by calling `getCertificate` or `getCert
```Java
certificateAsyncClient.getCertificate("<certificate-name>")
.subscribe(certificateResponse ->
System.out.printf("Certificate was returned with name \"%s\" and secretId %s\n",
System.out.printf("Certificate was returned with name \"%s\" and secretId %s%n",
certificateResponse.getProperties().getName(), certificateResponse.getSecretId()));
```
Expand All @@ -250,8 +250,8 @@ certificateAsyncClient.getCertificate("<certificate-name>")
certificate.getProperties().setEnabled(false);
certificateAsyncClient.updateCertificateProperties(certificate.getProperties())
.subscribe(certificateResponse ->
System.out.printf("Certificate's enabled status %s\n",
certificateResponse.getProperties().isEnabled().toString()));
System.out.printf("Certificate's enabled status: %s%n",
certificateResponse.getProperties().isEnabled()));
});
```
Expand All @@ -261,9 +261,9 @@ Delete an existing certificate by calling `beginDeleteCertificate`.
```java
certificateAsyncClient.beginDeleteCertificate("<certificate-name>")
.subscribe(pollResponse -> {
System.out.printf("Deletion status: %s\n", pollResponse.getStatus().toString());
System.out.printf("Deleted certificate name: %s\n", pollResponse.getValue().getName());
System.out.printf("Certificate deletion date: %s\n", pollResponse.getValue().getDeletedOn().toString());
System.out.printf("Deletion status: %s%n", pollResponse.getStatus());
System.out.printf("Deleted certificate name: %s%n", pollResponse.getValue().getName());
System.out.printf("Certificate deletion date: %s%n", pollResponse.getValue().getDeletedOn());
});
```
Expand All @@ -278,8 +278,8 @@ certificateAsyncClient.listPropertiesOfCertificates()
certificateAsyncClient.getCertificateVersion(certificateProperties.getName(),
certificateProperties.getVersion())
.subscribe(certificateResponse ->
System.out.printf("Received certificate with name \"%s\" and key id %s",
certificateResponse.getName(), certificateResponse.getKeyId())));
System.out.printf("Received certificate with name \"%s\" and key id %s", certificateResponse.getName(),
certificateResponse.getKeyId())));
```
## Troubleshooting
Expand Down
43 changes: 21 additions & 22 deletions sdk/keyvault/azure-security-keyvault-keys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,20 @@ KeyClient keyClient = new KeyClientBuilder()
KeyVaultKey rsaKey = keyClient.createRsaKey(new CreateRsaKeyOptions("CloudRsaKey")
.setExpiresOn(OffsetDateTime.now().plusYears(1))
.setKeySize(2048));
System.out.printf("Key created with name \"%s\" and id %s\n", rsaKey.getName(), rsaKey.getId());
System.out.printf("Key created with name \"%s\" and id %s%n", rsaKey.getName(), rsaKey.getId());
KeyVaultKey ecKey = keyClient.createEcKey(new CreateEcKeyOptions("CloudEcKey")
.setCurveName(KeyCurveName.P_256)
.setExpiresOn(OffsetDateTime.now().plusYears(1)));
System.out.printf("Key created with name \"%s\" and id %s\n", ecKey.getName(), ecKey.getId());
System.out.printf("Key created with name \"%s\" and id %s%n", ecKey.getName(), ecKey.getId());
```
### Retrieve a key
Retrieve a previously stored key by calling `getKey`.
```Java
KeyVaultKey key = keyClient.getKey("<key-name>");
System.out.printf("A key was returned with name \"%s\" and id %s\n", key.getName(), key.getId());
System.out.printf("A key was returned with name \"%s\" and id %s%n", key.getName(), key.getId());
```
### Update an existing key
Expand All @@ -184,7 +184,7 @@ KeyVaultKey key = keyClient.getKey("<key-name>");
// Update the expiry time of the key.
key.getProperties().setExpiresOn(OffsetDateTime.now().plusDays(30));
KeyVaultKey updatedKey = keyClient.updateKeyProperties(key.getProperties());
System.out.printf("Key's updated expiry time: %s\n", updatedKey.getProperties().getExpiresOn().toString());
System.out.printf("Key's updated expiry time: %s%n", updatedKey.getProperties().getExpiresOn());
```
### Delete a key
Expand All @@ -198,7 +198,7 @@ PollResponse<DeletedKey> deletedKeyPollResponse = deletedKeyPoller.poll();
// Deleted key is accessible as soon as polling begins.
DeletedKey deletedKey = deletedKeyPollResponse.getValue();
// Deletion date only works for a SoftDelete-enabled Key Vault.
System.out.printf("Deletion date: %s\n", deletedKey.getDeletedOn().toString());
System.out.printf("Deletion date: %s%n", deletedKey.getDeletedOn());
// Key is being deleted on server.
deletedKeyPoller.waitForCompletion();
Expand All @@ -212,7 +212,7 @@ List the keys in the key vault by calling `listPropertiesOfKeys`.
// get the key with its key material information.
for (KeyProperties keyProperties : keyClient.listPropertiesOfKeys()) {
KeyVaultKey keyWithMaterial = keyClient.getKey(keyProperties.getName(), keyProperties.getVersion());
System.out.printf("Received key with name \"%s\" and type \"%s\"\n", keyWithMaterial.getName(),
System.out.printf("Received key with name \"%s\" and type \"%s\"%n", keyWithMaterial.getName(),
keyWithMaterial.getKey().getKeyType());
}
```
Expand All @@ -231,8 +231,8 @@ new Random(0x1234567L).nextBytes(plainText);
// Let's encrypt a simple plain text of size 100 bytes.
EncryptResult encryptionResult = cryptoClient.encrypt(EncryptionAlgorithm.RSA_OAEP, plainText);
System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"\n",
encryptionResult.getCipherText().length, encryptionResult.getAlgorithm().toString());
System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"%n",
encryptionResult.getCipherText().length, encryptionResult.getAlgorithm());
```
### Decrypt
Expand All @@ -245,7 +245,7 @@ EncryptResult encryptionResult = cryptoClient.encrypt(EncryptionAlgorithm.RSA_OA
//Let's decrypt the encrypted result.
DecryptResult decryptionResult = cryptoClient.decrypt(EncryptionAlgorithm.RSA_OAEP, encryptionResult.getCipherText());
System.out.printf("Returned plainText size is %d bytes\n", decryptionResult.getPlainText().length);
System.out.printf("Returned plainText size is %d bytes%n", decryptionResult.getPlainText().length);
```
### Async API
Expand Down Expand Up @@ -280,12 +280,12 @@ keyAsyncClient.createRsaKey(new CreateRsaKeyOptions("CloudRsaKey")
.setExpiresOn(OffsetDateTime.now().plusYears(1))
.setKeySize(2048))
.subscribe(key ->
System.out.printf("Key created with name \"%s\" and id %s\n", key.getName(), key.getId()));
System.out.printf("Key created with name \"%s\" and id %s%n", key.getName(), key.getId()));
keyAsyncClient.createEcKey(new CreateEcKeyOptions("CloudEcKey")
.setExpiresOn(OffsetDateTime.now().plusYears(1)))
.subscribe(key ->
System.out.printf("Key created with name \"%s\" and id %s\n", key.getName(), key.getId()));
System.out.printf("Key created with name \"%s\" and id %s%n", key.getName(), key.getId()));
```
### Retrieve a key asynchronously
Expand All @@ -294,7 +294,7 @@ Retrieve a previously stored key by calling `getKey`.
```Java
keyAsyncClient.getKey("<key-name>")
.subscribe(key ->
System.out.printf("Key was returned with name \"%s\" and id %s\n", key.getName(), key.getId()));
System.out.printf("Key was returned with name \"%s\" and id %s%n", key.getName(), key.getId()));
```
### Update an existing key asynchronously
Expand All @@ -308,8 +308,7 @@ keyAsyncClient.getKey("<key-name>")
key.getProperties().setExpiresOn(OffsetDateTime.now().plusDays(50));
keyAsyncClient.updateKeyProperties(key.getProperties())
.subscribe(updatedKey ->
System.out.printf("Key's updated expiry time: %s\n",
updatedKey.getProperties().getExpiresOn().toString()));
System.out.printf("Key's updated expiry time: %s%n", updatedKey.getProperties().getExpiresOn()));
});
```
Expand All @@ -319,9 +318,9 @@ Delete an existing key by calling `beginDeleteKey`.
```java
keyAsyncClient.beginDeleteKey("<key-name>")
.subscribe(pollResponse -> {
System.out.printf("Deletetion status: %s\n", pollResponse.getStatus().toString());
System.out.printf("Deleted key name: %s\n", pollResponse.getValue().getName());
System.out.printf("Key deletion date: %s\n", pollResponse.getValue().getDeletedOn().toString());
System.out.printf("Deletetion status: %s%n", pollResponse.getStatus());
System.out.printf("Deleted key name: %s%n", pollResponse.getValue().getName());
System.out.printf("Key deletion date: %s%n", pollResponse.getValue().getDeletedOn());
});
```
Expand Down Expand Up @@ -353,8 +352,8 @@ new Random(0x1234567L).nextBytes(plainText);
// Let's encrypt a simple plain text of size 100 bytes.
cryptoAsyncClient.encrypt(EncryptionAlgorithm.RSA_OAEP, plainText)
.subscribe(encryptionResult -> {
System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"\n",
encryptionResult.getCipherText().length, encryptionResult.getAlgorithm().toString());
System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"%n",
encryptionResult.getCipherText().length, encryptionResult.getAlgorithm());
});
```
Expand All @@ -368,12 +367,12 @@ new Random(0x1234567L).nextBytes(plainText);
// Let's encrypt a simple plain text of size 100 bytes.
cryptoAsyncClient.encrypt(EncryptionAlgorithm.RSA_OAEP, plainText)
.subscribe(encryptionResult -> {
System.out.printf("Returned cipherText size is %d bytes with algorithm %s\n",
encryptionResult.getCipherText().length, encryptionResult.getAlgorithm().toString());
System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"%n",
encryptionResult.getCipherText().length, encryptionResult.getAlgorithm());
//Let's decrypt the encrypted response.
cryptoAsyncClient.decrypt(EncryptionAlgorithm.RSA_OAEP, encryptionResult.getCipherText())
.subscribe(decryptionResult ->
System.out.printf("Returned plainText size is %d bytes\n", decryptionResult.getPlainText().length));
System.out.printf("Returned plainText size is %d bytes%n", decryptionResult.getPlainText().length));
});
```
Expand Down
36 changes: 18 additions & 18 deletions sdk/keyvault/azure-security-keyvault-secrets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ The following sections provide several code snippets covering some of the most c
### Create a secret
Create a secret to be stored in the Azure Key Vault.
- `setSecret` creates a new secret in the Azure Key Vault. If the secret with name already exists then a new version of the secret is created.
- `setSecret` creates a new secret in the Azure Key Vault. If a secret with the given name already exists then a new version of the secret is created.
```Java
import com.azure.identity.DefaultAzureCredentialBuilder;
Expand All @@ -135,15 +135,15 @@ SecretClient secretClient = new SecretClientBuilder()
.buildClient();
KeyVaultSecret secret = secretClient.setSecret("<secret-name>", "<secret-value>");
System.out.printf("Secret created with name \"%s\" and value \"%s\"\n", secret.getName(), secret.getValue());
System.out.printf("Secret created with name \"%s\" and value \"%s\"%n", secret.getName(), secret.getValue());
```
### Retrieve a secret
Retrieve a previously stored secret by calling `getSecret`.
```Java
KeyVaultSecret secret = secretClient.getSecret("<secret-name>");
System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"\n", secret.getName(), secret.getValue());
System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"%n", secret.getName(), secret.getValue());
```
### Update an existing secret
Expand All @@ -155,7 +155,7 @@ KeyVaultSecret secret = secretClient.getSecret("<secret-name>");
// Update the expiry time of the secret.
secret.getProperties().setExpiresOn(OffsetDateTime.now().plusDays(30));
SecretProperties updatedSecretProperties = secretClient.updateSecretProperties(secret.getProperties());
System.out.printf("Secret's updated expiry time: %s\n", updatedSecretProperties.getExpiresOn().toString());
System.out.printf("Secret's updated expiry time: %s%n", updatedSecretProperties.getExpiresOn());
```
### Delete a secret
Expand All @@ -168,7 +168,7 @@ SyncPoller<DeletedSecret, Void> deletedSecretPoller = secretClient.beginDeleteSe
PollResponse<DeletedSecret> deletedSecretPollResponse = deletedSecretPoller.poll();
// Deletion date only works for a SoftDelete-enabled Key Vault.
System.out.println("Deletion date: \"%s\"" + deletedSecretPollResponse.getValue().getDeletedOn().toString());
System.out.printf("Deletion date: %s%n", deletedSecretPollResponse.getValue().getDeletedOn());
// Secret is being deleted on server.
deletedSecretPoller.waitForCompletion();
Expand All @@ -178,10 +178,11 @@ deletedSecretPoller.waitForCompletion();
List the secrets in the Azure Key Vault by calling `listPropertiesOfSecrets`.
```Java
// List operations don't return the secrets with value information. So, for each returned secret we call getSecret to get the secret with its value information.
// List operations don't return the secrets with value information. So, for each returned secret we call getSecret to
// get the secret with its value information.
for (SecretProperties secretProperties : secretClient.listPropertiesOfSecrets()) {
KeyVaultSecret secretWithValue = secretClient.getSecret(secretProperties.getName(), secretProperties.getVersion());
System.out.printf("Retreieved secret with name \"%s\" and value \"%s\"\n", secretWithValue.getName(),
KeyVaultSecret secretWithValue = secretClient.getSecret(secretProperties.getName(), secretProperties.getVersion());
System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"%n", secretWithValue.getName(),
secretWithValue.getValue());
}
```
Expand All @@ -198,7 +199,7 @@ The following sections provide several code snippets covering some of the most c
### Create a secret asynchronously
Create a secret to be stored in the Azure Key Vault.
- `setSecret` creates a new secret in the Azure Key Vault. if the secret with name already exists then a new version of the secret is created.
- `setSecret` creates a new secret in the Azure Key Vault. If a secret with the given name already exists then a new version of the secret is created.
```Java
import com.azure.identity.DefaultAzureCredentialBuilder;
Expand All @@ -212,7 +213,7 @@ SecretAsyncClient secretAsyncClient = new SecretClientBuilder()
secretAsyncClient.setSecret("<secret-name>", "<secret-value>")
.subscribe(secret ->
System.out.printf("Created secret with name \"%s\" and value \"%s\"\n", secret.getName(), secret.getValue()));
System.out.printf("Created secret with name \"%s\" and value \"%s\"%n", secret.getName(), secret.getValue()));
```
### Retrieve a secret asynchronously
Expand All @@ -221,7 +222,7 @@ Retrieve a previously stored secret by calling `getSecret`.
```Java
secretAsyncClient.getSecret("<secret-name>")
.subscribe(secret ->
System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"\n", secret.getName(), secret.getValue()));
System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"%n", secret.getName(), secret.getValue()));
```
### Update an existing secret asynchronously
Expand All @@ -234,8 +235,7 @@ secretAsyncClient.getSecret("<secret-name>")
secret.getProperties().setExpiresOn(OffsetDateTime.now().plusDays(50));
secretAsyncClient.updateSecretProperties(secret.getProperties())
.subscribe(updatedSecretProperties ->
System.out.printf("Secret's updated expiry time: %s\n",
updatedSecretProperties.getExpiresOn().toString()));
System.out.printf("Secret's updated expiry time: %s%n", updatedSecretProperties.getExpiresOn()));
});
```
Expand All @@ -245,23 +245,23 @@ Delete an existing secret by calling `beginDeleteSecret`.
```Java
secretAsyncClient.beginDeleteSecret("<secret-name>")
.subscribe(pollResponse -> {
System.out.println("Deletion status: " + pollResponse.getStatus().toString());
System.out.println("Deleted secret name: " + pollResponse.getValue().getName());
System.out.println("Deleted secret value: " + pollResponse.getValue().getValue());
System.out.printf("Deletion status: %s%n", pollResponse.getStatus());
System.out.printf("Deleted secret name: %s%n", pollResponse.getValue().getName());
System.out.printf("Deleted secret value: %s%n", pollResponse.getValue().getValue());
});
```
### List secrets asynchronously
List the secrets in the Azure Key Vault by calling `listPropertiesOfSecrets`.
```Java
// The List Secrets operation returns secrets without their value, so for each secret returned we call `getSecret`
// The List secrets operation returns secrets without their value, so for each secret returned we call `getSecret`
// to get its value as well.
secretAsyncClient.listPropertiesOfSecrets()
.subscribe(secretProperties ->
secretAsyncClient.getSecret(secretProperties.getName(), secretProperties.getVersion())
.subscribe(secretResponse ->
System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"", secretResponse.getName(),
System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"%n", secretResponse.getName(),
secretResponse.getValue())));
```
Expand Down

0 comments on commit 3fac428

Please sign in to comment.