From 66422c284168dbf96da2a484dda05d95260c0745 Mon Sep 17 00:00:00 2001 From: George Arama <50641385+gearama@users.noreply.github.com> Date: Fri, 20 Aug 2021 12:43:43 -0700 Subject: [PATCH] some updates (#2760) * some updates * keyvault->key vault * Update sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.md Co-authored-by: Rick Winter * Update sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.md Co-authored-by: Rick Winter * Update sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample1-basic-operations/sample1-basic-operations.md Co-authored-by: Rick Winter * final updates Co-authored-by: Rick Winter --- .../azure-security-keyvault-secrets/README.md | 28 ++++++++----------- ...o_world.md => sample1-basic-operations.md} | 12 ++++---- .../sample2-backup-restore.cpp | 10 +++---- .../sample2-backup-restore.md | 24 ++++++++-------- .../sample3-delete-recover.md | 8 +++--- .../sample4-get-secrets-deleted.md | 17 ++++++----- 6 files changed, 46 insertions(+), 53 deletions(-) rename sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample1-basic-operations/{sample1_hello_world.md => sample1-basic-operations.md} (87%) diff --git a/sdk/keyvault/azure-security-keyvault-secrets/README.md b/sdk/keyvault/azure-security-keyvault-secrets/README.md index 9e2844fb6..dc63e6fb8 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/README.md +++ b/sdk/keyvault/azure-security-keyvault-secrets/README.md @@ -25,27 +25,27 @@ az keyvault create --resource-group --name - [Replaceable HTTP transport adapter](https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/core/azure-core#http-transport-adapter) | [Long-running operations](https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/core/azure-core#long-running-operations) | - ## Examples -For detailed samples please review the samples provided. +For detailed samples please review the samples provided. -### Create a client +### Create a client First step is to create a SecretClient. @@ -55,8 +55,8 @@ auto clientId = std::getenv("AZURE_CLIENT_ID"); auto clientSecret = std::getenv("AZURE_CLIENT_SECRET"); auto credential = std::make_shared(tenantId, clientId, clientSecret); - // create client - SecretClient secretClient(std::getenv("AZURE_KEYVAULT_URL"), credential); +// create client +SecretClient secretClient(std::getenv("AZURE_KEYVAULT_URL"), credential); ``` ### Create a secret @@ -157,21 +157,21 @@ You will notice that additional information is logged, like the client request I Several Azure Key Vault secrets client library samples are available to you in this GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Azure Key Vault: -* Sample1-Basic-Operations: +* [Sample1-Basic-Operations](https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample1-basic-operations): * Create a secret * Get a secret * Update a secret * Delete and Purge a secret -* Sample2-Backup-Restore +* [Sample2-Backup-Restore](https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore): * Backup a secret * Restore a deleted secret -* Sample3-Delete-Recover +* [Sample3-Delete-Recover](https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample3-delete-recover): * Delete a secret * Recover a deleted Secret -* Sample4-Get-Secrets-Deleted +* [Sample4-Get-Secrets-Deleted](https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample4-get-secrets-deleted): * List all secrets * List all of a secrets versions * List all deletes secrets @@ -214,10 +214,4 @@ Azure SDK for C++ is licensed under the [MIT](https://github.com/Azure/azure-sdk [azure_sdk_for_cpp_contributing_developer_guide]: https://github.com/Azure/azure-sdk-for-cpp/blob/main/CONTRIBUTING.md#developer-guide [azure_sdk_for_cpp_contributing_pull_requests]: https://github.com/Azure/azure-sdk-for-cpp/blob/main/CONTRIBUTING.md#pull-requests [azure_cli]: https://docs.microsoft.com/cli/azure -[azure_pattern_circuit_breaker]: https://docs.microsoft.com/azure/architecture/patterns/circuit-breaker -[azure_pattern_retry]: https://docs.microsoft.com/azure/architecture/patterns/retry -[azure_portal]: https://portal.azure.com [azure_sub]: https://azure.microsoft.com/free/ -[c_compiler]: https://visualstudio.microsoft.com/vs/features/cplusplus/ -[cloud_shell]: https://docs.microsoft.com/azure/cloud-shell/overview -[cloud_shell_bash]: https://shell.azure.com/bash diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample1-basic-operations/sample1_hello_world.md b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample1-basic-operations/sample1-basic-operations.md similarity index 87% rename from sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample1-basic-operations/sample1_hello_world.md rename to sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample1-basic-operations/sample1-basic-operations.md index 5b1154d34..9746a30fc 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample1-basic-operations/sample1_hello_world.md +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample1-basic-operations/sample1-basic-operations.md @@ -1,7 +1,7 @@ # Creating, getting, updating, and deleting secrets This sample demonstrates how to create, get, update, and delete and purge a secret in Azure Key Vault. -To get started, you'll need a URI to an Azure Key Vault. +To get started, you'll need a URI to an Azure Key Vault. ## Creating a SecretClient @@ -26,7 +26,7 @@ SecretClient secretClient(std::getenv("AZURE_KEYVAULT_URL"), credential); ## Creating a Secret -To create a secret all you need to set id the name and secret value. +Call SetSecret to create a new secret with name and secret value. ```cpp Snippet:SecretSample1SetSecret std::string secretName("MySampleSecret"); @@ -37,7 +37,7 @@ secretClient.SetSecret(secretName, secretValue); ## Getting a Secret -To get a secret from the keyvault you will need to call GetSecret. +Call GetSecret to retrieve a secret from Key Vault. ```cpp Snippet:SecretSample1GetSecret // get secret @@ -48,7 +48,7 @@ std::cout << "Secret is returned with name " << secret.Name << " and value " << ## Updating secret properties -We forgot to set the content type for the secret we created, we can do that using the UpdateSecretProperties method. +Call UpdateSecretProperties to change on of the secret properties. ```cpp Snippet:SecretSample1UpdateSecretProperties @@ -63,14 +63,14 @@ std::cout << "Secret's content type is now " << updatedSecret.Properties.Content ## Deleting a secret -The secret is no longer needed so we need to delete it. +Call StartDeleteSecret to delete a secret. This is a long running operation. ```cpp Snippet:SecretSample1DeleteSecret // start deleting the secret DeleteSecretOperation operation = secretClient.StartDeleteSecret(secret.Name); ``` -## Purging a deleted key +## Purging a deleted secret If the Azure Key Vault is soft delete-enabled and you want to permanently delete the secret before its `ScheduledPurgeDate`, the secret needs to be purged. diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.cpp index bccb2d444..3e7338b2c 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.cpp @@ -55,7 +55,7 @@ int main() size_t backUpSize = 0; { - std::cout << "\t-Backup Key" << std::endl; + std::cout << "\t-Backup Secret" << std::endl; auto backupSecretResult = secretClient.BackupSecret(secret.Name).Value; auto const& backedupSecret = backupSecretResult.Secret; backUpSize = backedupSecret.size(); @@ -78,10 +78,10 @@ int main() // purge the deleted secret secretClient.PurgeDeletedSecret(secret.Name); - // let's wait for one minute so we know the key was purged. + // let's wait for one minute so we know the secret was purged. std::this_thread::sleep_for(60s); - // Restore the key from the file backup + // Restore the secret from the file backup std::cout << "\t-Read from file." << std::endl; std::ifstream inFile; inFile.open("backup.dat"); @@ -89,13 +89,13 @@ int main() inFile >> inMemoryBackup.data(); inFile.close(); - std::cout << "\t-Restore Key" << std::endl; + std::cout << "\t-Restore Secret" << std::endl; auto restoredSecret = secretClient.RestoreSecretBackup(inMemoryBackup).Value; AssertSecretsEqual(secret, restoredSecret); operation = secretClient.StartDeleteSecret(restoredSecret.Name); - // You only need to wait for completion if you want to purge or recover the key. + // You only need to wait for completion if you want to purge or recover the secret. operation.PollUntilDone(2s); secretClient.PurgeDeletedSecret(restoredSecret.Name); } diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.md b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.md index 0861d0a42..c190a2a15 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.md +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2-backup-restore.md @@ -1,7 +1,7 @@ # Backup and Restore secrets This sample demonstrates how to backup and restore in Azure Key Vault. -To get started, you'll need a URI to an Azure Key Vault. +To get started, you'll need a URI to an Azure Key Vault. ## Creating a SecretClient @@ -26,7 +26,7 @@ SecretClient secretClient(std::getenv("AZURE_KEYVAULT_URL"), credential); ## Creating a Secret -To create a secret all you need to set id the name and secret value. +Call SetSecret to create a secret with the name and secret value. ```cpp Snippet:SecretSample2SetSecret std::string secretName("MySampleSecret"); @@ -37,7 +37,7 @@ secretClient.SetSecret(secretName, secretValue); ## Getting a Secret -To get a secret from the keyvault you will need to call GetSecret. +Call GetSecret to retrieve a secret from Key Vault. ```cpp Snippet:SecretSample2GetSecret // get secret @@ -48,25 +48,25 @@ std::cout << "Secret is returned with name " << secret.Name << " and value " << ## Creating a Backup for the secret properties -In order to get the backup of the secret we need to call BackupSecret, which will return a vector of bytes representing the backed up content. +Call BackupSecret to retrieve the secret backup. BackupSecret will will return a vector of bytes representing the backed up content. ```cpp Snippet:SecretSample2BackupSecret -std::cout << "\t-Backup Key" << std::endl; -std::vector backupKey(secretClient.BackupSecret(secret.Name).Value.Secret); -backUpSize = backupKey.size(); +std::cout << "\t-Backup secret" << std::endl; +std::vector backupSecret(secretClient.BackupSecret(secret.Name).Value.Secret); +backUpSize = backupSecret.size(); ``` ## Deleting the secret in order to later restore it -The secret is no longer needed so we need to delete it. +Call StartDeleteSecret to delete a secret. This is a long running operation. ```cpp Snippet:SecretSample2DeleteSecret // start deleting the secret DeleteSecretOperation operation = secretClient.StartDeleteSecret(secret.Name); ``` -## Purging a deleted key +## Purging a deleted secret If the Azure Key Vault is soft delete-enabled and you want to permanently delete the secret before its `ScheduledPurgeDate`, the secret needs to be purged. @@ -78,12 +78,12 @@ operation.PollUntilDone(2s); secretClient.PurgeDeletedSecret(secret.Name); ``` -## Restoring a secret +## Restoring a secret -In order to restore a secret we need to call RestoreSecretBackup api passing in the byte vector obtained at the previous(backup) step. +Call RestoreSecretBackup to restore a secret from a backup obtained at the previous(backup) step. ```cpp Snippet:SecretSample2RestoreSecret -std::cout << "\t-Restore Key" << std::endl; +std::cout << "\t-Restore Secret" << std::endl; auto restoredSecret = secretClient.RestoreSecretBackup(inMemoryBackup).Value; ``` diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample3-delete-recover/sample3-delete-recover.md b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample3-delete-recover/sample3-delete-recover.md index 12bdde075..8271859f8 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample3-delete-recover/sample3-delete-recover.md +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample3-delete-recover/sample3-delete-recover.md @@ -25,7 +25,7 @@ SecretClient secretClient(std::getenv("AZURE_KEYVAULT_URL"), credential); ## Creating a Secret -To create a secret all you need to set id the name and secret value. +Call SetSecret to create a new secret with name and secret value. ```cpp Snippet:SecretSample3SetSecret std::string secretName("MySampleSecret"); @@ -36,7 +36,7 @@ secretClient.SetSecret(secretName, secretValue); ## Getting a Secret -To get a secret from the keyvault you will need to call GetSecret. +Call GetSecret to retrieve a secret from Key Vault. ```cpp Snippet:SecretSample3GetSecret // get secret @@ -47,7 +47,7 @@ std::cout << "Secret is returned with name " << secret.Name << " and value " << ## Deleting a secret -The secret is no longer needed so we need to delete it. +Call StartDeleteSecret to delete a secret. This is a long running operation. ```cpp Snippet:SecretSample3DeleteSecret // start deleting the secret @@ -56,7 +56,7 @@ DeleteSecretOperation operation = secretClient.StartDeleteSecret(secret.Name); ## Recover a Deleted secret -To recover a deleted secret we need to call StartRecoverDeletedSecret and then poll untill the operation is done. +Call StartRecoverDeletedSecret to recover a deleted secret and then poll until the operation is done. ```cpp Snippet:SecretSample3RecoverSecret // call restore secret diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample4-get-secrets-deleted/sample4-get-secrets-deleted.md b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample4-get-secrets-deleted/sample4-get-secrets-deleted.md index 714caf317..d7096aae0 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample4-get-secrets-deleted/sample4-get-secrets-deleted.md +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample4-get-secrets-deleted/sample4-get-secrets-deleted.md @@ -25,7 +25,7 @@ SecretClient secretClient(std::getenv("AZURE_KEYVAULT_URL"), credential); ## Creating a couple of Secrets -To create a secret all you need to set id the name and secret value. +Call SetSecret to create a couple of new secret with names and secret values. ```cpp Snippet:SecretSample4SetSecret std::string secretName("MySampleSecret"); @@ -36,9 +36,9 @@ Secret secret1 = secretClient.SetSecret(secretName, secretValue).Value; Secret secret2 = secretClient.SetSecret(secretName2, secretValue).Value; ``` -## Getting the properties of all the secrets in the keyvault +## Getting the properties of all the secrets in the key vault -To get the properties of the secrets in the keyvault we will call GetPropertiesOfSecrets. The results of this call are paged to a maximum of 25 SecretProperties per page. +Call GetPropertiesOfSecrets to get the properties of all the secrets in the key vault. The results of this call are paged to a maximum of 25 SecretProperties per page. ```cpp Snippet:SecretSample4ListAllSecrets // get properties of secrets @@ -53,8 +53,7 @@ for (auto secrets = secretClient.GetPropertiesOfSecrets(); secrets.HasPage(); se ## Get the versions of a Secret -in order to list all the versions of a secret we need to call GetPropertiesOfSecretsVersions, which responds similarly with a paged response of up to 25 versions of the secret per page. - +Call GetPropertiesOfSecretsVersions in order to list all the versions of a secret. Responds similarly with a paged response of up to 25 versions of the secret per page. ```cpp Snippet:SecretSample4GetVersions // get all the versions of a secret @@ -72,7 +71,7 @@ for (auto secretsVersion = secretClient.GetPropertiesOfSecretsVersions(secret1.N ## Delete both secrets -The secrets is no longer needed so we need to delete them, in order to demonstrate the delete related operations. We shall not purge the secrets yet. +Call StartDeleteSecret to delete a secret. This is a long running operation. We shall not purge the secrets yet. ```cpp Snippet:SecretSample4DeleteSecrets // start deleting the secret @@ -88,7 +87,7 @@ operation.PollUntilDone(2s); ## Get Deleted Secrets -To get a list of preprties of all deleted secrets we will call GetDeletedSecrets, similarly to the previous calls this is a paged response with the same limit of 25 items per response. +Call GetDeletedSecrets to get a list of properties of all deleted secrets. This is a paged response with the same limit of 25 items per response. ```cpp Snippet:SecretSample4GetDeletedSecrets // get all the versions of a secret @@ -104,7 +103,7 @@ for (auto deletedSecrets = secretClient.GetDeletedSecrets(); deletedSecrets.HasP ## Get Deleted Secret -To get information about a specific deleted secret we will call GetDeletedSecret passing the secret name as a parameter. +Call GetDeletedSecret to get information about a specific deleted secret. ```cpp Snippet:SecretSample4GetDeletedSecret // get one deleted secret @@ -114,7 +113,7 @@ std::cout << "Deleted Secret with name: " << deletedSecret.Value.Name; ## Purge the secrets to cleanup -Since the secrets were deleted previously now we need to call purge to finish cleaning up. +Call PurgeDeletedSecret to finish cleaning up. ```cpp Snippet:SecretSample4PurgeSecrets // cleanup