SecretClient (Azure SDK for Java Reference Documentation)
Rachel Ross
Published Feb 16, 2026
Lists all versions of the specified secret. Each
secret returned only has its identifier and attributes populated. The secret values and secret versions are not listed in the response. This operation requires the secrets/list permission. Code sample
The sample below fetches all versions of the given secret. For each secret version retrieved, makes a call to getSecret(String, String) to get the version's value, and then prints it out.
for (SecretProperties secret : secretClient .listPropertiesOfSecretVersions("secretName", new Context(key1, value2))) { KeyVaultSecret secretWithValue = secretClient.getSecret(secret.getName(), secret.getVersion()); System.out.printf("Received secret's version with name %s and value %s", secretWithValue.getName(), secretWithValue.getValue()); } Iterate over secret versions by page
The sample below iterates over each secret by each page and calls SecretClient.getSecret(String, String). This will return the secret with the corresponding version's value.
secretClient.listPropertiesOfSecretVersions("secretName", new Context(key1, value2)) .iterableByPage().forEach(resp -> { System.out.printf("Got response headers . Url: %s, Status code: %d %n", resp.getRequest().getUrl(), resp.getStatusCode()); resp.getItems().forEach(value -> { KeyVaultSecret secretWithValue = secretClient.getSecret(value.getName(), value.getVersion()); System.out.printf("Received secret's version with name %s and value %s", secretWithValue.getName(), secretWithValue.getValue()); }); });