Creates an instance of SecretClient.
Example usage:
import { SecretClient } from "@azure/keyvault-secrets";
import { DefaultAzureCredential } from "@azure/identity";
let vaultUrl = `https://<MY KEYVAULT HERE>.vault.azure.net`;
let credentials = new DefaultAzureCredential();
let client = new SecretClient(vaultUrl, credentials);
the base URL to the vault.
An object that implements the TokenCredential
interface used to authenticate requests to the service. Use the @azure/identity package to create a credential that suits your needs.
The base URL to the vault
Requests that a backup of the specified secret be downloaded to the client. All versions of the secret will be downloaded. This operation requires the secrets/backup permission.
Example usage:
let client = new SecretClient(url, credentials);
let backupResult = await client.backupSecret("MySecretName");
The name of the secret.
Deletes a secret stored in Azure Key Vault. This function returns a Long Running Operation poller that allows you to wait indifinetly until the secret is deleted.
This operation requires the secrets/delete permission.
Example usage:
const client = new SecretClient(url, credentials);
await client.setSecret("MySecretName", "ABC123");
const deletePoller = await client.beginDeleteSecret("MySecretName");
// Serializing the poller
const serialized = deletePoller.toString();
// A new poller can be created with:
// const newPoller = await client.beginDeleteSecret("MySecretName", { resumeFrom: serialized });
// Waiting until it's done
const deletedSecret = await deletePoller.pollUntilDone();
console.log(deletedSecret);
Recovers the deleted secret in the specified vault. This function returns a Long Running Operation poller that allows you to wait indifinetly until the secret is recovered.
This operation requires the secrets/recover permission.
Example usage:
const client = new SecretClient(url, credentials);
await client.setSecret("MySecretName", "ABC123");
const deletePoller = await client.beginDeleteSecret("MySecretName");
await deletePoller.pollUntilDone();
const recoverPoller = await client.recoverDeletedSecret("MySecretName");
// Serializing the poller
const serialized = recoverPoller.toString();
// A new poller can be created with:
// const newPoller = await client.beginRecoverDeletedSecret("MySecretName", { resumeFrom: serialized });
// Waiting until it's done
const deletedSecret = await recoverPoller.pollUntilDone();
console.log(deletedSecret);
The getDeletedSecret method returns the specified deleted secret along with its attributes. This operation requires the secrets/get permission.
Example usage:
let client = new SecretClient(url, credentials);
await client.getDeletedSecret("MyDeletedSecret");
The name of the secret.
The getSecret method is applicable to any secret stored in Azure Key Vault. This operation requires the secrets/get permission.
Example usage:
let client = new SecretClient(url, credentials);
let secret = await client.getSecret("MySecretName");
The name of the secret.
Iterates the deleted secrets in the vault. The full secret identifier and attributes are provided in the response. No values are returned for the secrets. This operations requires the secrets/list permission.
Example usage:
let client = new SecretClient(url, credentials);
for await (const deletedSecret of client.listDeletedSecrets()) {
const deletedSecret = await client.getSecret(deletedSecret.name);
console.log("deleted secret: ", deletedSecret);
}
Iterates all versions of the given secret in the vault. The full secret identifier and attributes are provided in the response. No values are returned for the secrets. This operations requires the secrets/list permission.
Example usage:
let client = new SecretClient(url, credentials);
for await (const secretProperties of client.listPropertiesOfSecretVersions("MySecretName")) {
const secret = await client.getSecret(secretProperties.name);
console.log("secret version: ", secret);
}
Name of the secret to fetch versions for.
Iterates the latest version of all secrets in the vault. The full secret identifier and attributes are provided in the response. No values are returned for the secrets. This operations requires the secrets/list permission.
Example usage:
let client = new SecretClient(url, credentials);
for await (const secretProperties of client.listPropertiesOfSecrets()) {
const secret = await client.getSecret(secretProperties.name);
console.log("secret: ", secret);
}
The purge deleted secret operation removes the secret permanently, without the possibility of recovery. This operation can only be enabled on a soft-delete enabled vault. This operation requires the secrets/purge permission.
Example usage:
const client = new SecretClient(url, credentials);
const deletePoller = await client.beginDeleteSecret("MySecretName");
await deletePoller.pollUntilDone();
await client.purgeDeletedSecret("MySecretName");
The name of the secret.
Restores a backed up secret, and all its versions, to a vault. This operation requires the secrets/restore permission.
Example usage:
let client = new SecretClient(url, credentials);
let mySecretBundle = await client.backupSecret("MySecretName");
// ...
await client.restoreSecretBackup(mySecretBundle);
The backup blob associated with a secret bundle.
The setSecret method adds a secret or secret version to the Azure Key Vault. If the named secret already exists, Azure Key Vault creates a new version of that secret. This operation requires the secrets/set permission.
Example usage:
let client = new SecretClient(url, credentials);
await client.setSecret("MySecretName", "ABC123");
The name of the secret.
The value of the secret.
The updateSecret method changes specified attributes of an existing stored secret. Properties that are not specified in the request are left unchanged. The value of a secret itself cannot be changed. This operation requires the secrets/set permission.
Example usage:
let secretName = "MySecretName";
let client = new SecretClient(url, credentials);
let secret = await client.getSecret(secretName);
await client.updateSecret(secretName, secret.version, { enabled: false });
The name of the secret.
The version of the secret.
Generated using TypeDoc
The SecretClient provides methods to manage KeyVaultSecret in the Azure Key Vault. The client supports creating, retrieving, updating, deleting, purging, backing up, restoring and listing KeyVaultSecrets. The client also supports listing DeletedSecret for a soft-delete enabled Azure Key Vault.