Enable and disable a key in Azure Key Vault with JavaScript

To enable a key for use with cryptographic operations in Azure Key Vault, use the updateKeyProperties method of the SecretClient class.

Enable a key

To enable a key in Azure Key Vault, use the updateKeyProperties method of the KeyClient class.

const properties = await keyClient.updateKeyProperties(
    keyName,
    version, // optional, remove to update the latest version
    { enabled: true }
);

Refer to the update key properties example for the full code example.

Disable a new key

To disable a new key, use the createKey method and use the createKeyOptions to disable the key.

const keyVaultKey = await keyClient.createKey(keyName, keyType, { enabled: false });

Disable an existing key

To disable a key in Azure Key Vault, use the updateKeyProperties method of the KeyClient class.

const properties = await keyClient.updateKeyProperties(
    keyName,
    version, // optional, remove to update the latest version
    { enabled: false }
);

Refer to the update key properties example for the full code example.

Next steps