Nota
O acesso a esta página requer autorização. Podes tentar iniciar sessão ou mudar de diretório.
O acesso a esta página requer autorização. Podes tentar mudar de diretório.
Crie o SecretClient com as credenciais de autenticação programática apropriadas e use o cliente para habilitar e desabilitar um segredo do Cofre de Chaves do Azure.
Ativar um segredo
Para habilitar um segredo no Cofre da Chave do Azure, use o método updateSecretProperties da classe SecretClient .
const name = 'mySecret';
const version= 'd9f2f96f120d4537ba7d82fecd913043'
const properties = await client.updateSecretProperties(
secretName,
version,
{ enabled: true }
);
// get secret value
const { value } = await client.getSecret(secretName, version);
This method returns the SecretProperties object.
Desativar um novo segredo
Para desativar um segredo ao criá-lo, use o método setSecret com a opção enabled definida como false.
const mySecretName = 'mySecret';
const mySecretValue = 'mySecretValue';
// Success
const { name, value, properties } = await client.setSecret(
mySecretName,
mySecretValue,
{ enabled: false }
);
// Can't read value of disabled secret
try{
const secret = await client.getSecret(
mySecretName,
properties.version
);
} catch(err){
// `Operation get is not allowed on a disabled secret.`
console.log(err.message);
}
Desativar um segredo existente
Para desabilitar um segredo existente no Cofre da Chave do Azure, use o método updateSecretProperties da classe SecretClient .
const name = 'mySecret';
const version= 'd9f2f96f120d4537ba7d82fecd913043';
// Success
const properties = await client.updateSecretProperties(
secretName,
version,
{ enabled: false }
);
// Can't read value of disabled secret
try{
const { value } = await client.getSecret(secretName, version);
} catch(err){
// `Operation get is not allowed on a disabled secret.`
console.log(err.message);
}
This method returns the SecretProperties object.