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.
Pipeline options used to configure Key Vault API requests. Omit this parameter to use the default pipeline configuration.
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");
Backs up the specified secret.
The name of the secret.
The optional parameters.
Deletes a secret stored in Azure Key Vault. This function returns a Long Running Operation poller that allows you to wait indefinitely 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);
Deletes a secret from a specified key vault.
The optional parameters.
Recovers the deleted secret in the specified vault. This function returns a Long Running Operation poller that allows you to wait indefinitely 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.beginRecoverDeletedSecret("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);
Recovers the deleted secret to the latest version.
The optional parameters.
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");
Gets the specified deleted secret.
The name of the secret.
The optional parameters.
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");
Get a specified secret from a given key vault.
The name of the secret.
The optional parameters.
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()) {
console.log("deleted secret: ", deletedSecret);
}
List all secrets in the vault.
The optional parameters.
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.
The optional parameters.
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);
}
List all secrets in the vault.
The optional parameters.
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");
Permanently deletes the specified secret.
The name of the secret.
The optional parameters.
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);
Restores a backed up secret to a vault.
The backup blob associated with a secret bundle.
The optional parameters.
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");
Adds a secret in a specified key vault.
The name of the secret.
The value of the secret.
The optional parameters.
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.updateSecretProperties(secretName, secret.properties.version, { enabled: false });
Updates the attributes associated with a specified secret in a given key vault.
The name of the secret.
The version of the secret.
The optional parameters.
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.