在 Azure Key Vault 中使用 JavaScript 启动和禁用密钥

若要在 Azure Key Vault 中启用密钥供加密操作使用,请使用 SecretClient 类的 updateKeyProperties 方法。

启用密钥

若要在 Azure Key Vault 中启用密钥,请使用 KeyClient 类的 updateKeyProperties 方法。

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

有关完整代码示例,请查看更新密钥属性示例。

禁用新密钥

若要禁用新密钥,请使用 createKey 方法,并使用 createKeyOptions 禁用该密钥。

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

禁用现有密钥

若要在 Azure Key Vault 中禁用密钥,请使用 KeyClient 类的 updateKeyProperties 方法。

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

有关完整代码示例,请查看更新密钥属性示例。

后续步骤