/// <summary> /// Gets the specified key /// </summary> /// <param name="keyId"> a global key identifier of the key to get </param> /// <returns> retrieved key bundle </returns> private static KeyBundle GetKey(KeyBundle key) { KeyBundle retrievedKey; string keyVersion = inputValidator.GetKeyVersion(); string keyName = inputValidator.GetKeyName(allowDefault: false); if (keyVersion != string.Empty || keyName != string.Empty) { var vaultAddress = inputValidator.GetVaultAddress(); if (keyVersion != string.Empty) { keyName = inputValidator.GetKeyName(true); retrievedKey = keyVaultClient.GetKeyAsync(vaultAddress, keyName, keyVersion).GetAwaiter().GetResult(); } else { retrievedKey = keyVaultClient.GetKeyAsync(vaultAddress, keyName).GetAwaiter().GetResult(); } } else { // If the key is not initialized get the key id from args var keyId = (key != null) ? key.Key.Kid : inputValidator.GetKeyId(); // Get the key using its ID retrievedKey = keyVaultClient.GetKeyAsync(keyId).GetAwaiter().GetResult(); } Console.Out.WriteLine("Retrived key:---------------"); PrintoutKey(retrievedKey); //store the created key for the next operation if we have a sequence of operations return(retrievedKey); }