Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Key Vault - Secrets
Identity - Credential
------------------------
1) Set a secret
2) Get that secret
3) Delete that secret (Clean up the resource)
`);
// EnvironmentCredential expects the following three environment variables:
// * AZURE_TENANT_ID: The tenant ID in Azure Active Directory
// * AZURE_CLIENT_ID: The application (client) ID registered in the AAD tenant
// * AZURE_CLIENT_SECRET: The client secret for the registered application
const credential = new EnvironmentCredential();
const url = process.env["AZURE_PROJECT_URL"] || "";
KeyVaultSecrets.client = new SecretsClient(url, credential);
KeyVaultSecrets.secretName = `MySecretName-${uuidv1()}`;
KeyVaultSecrets.secretValue = "MySecretValue";
try {
await KeyVaultSecrets.setSecret();
await KeyVaultSecrets.getSecret();
} catch (err) {
throw err;
} finally {
await KeyVaultSecrets.deleteSecret();
}
}