How to use the @azure/keyvault-secrets.SecretClient function in @azure/keyvault-secrets

To help you get started, we’ve selected a few @azure/keyvault-secrets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure-Samples / key-vault-node-quickstart / v4 / index.js View on Github external
var http = require('http');
const {DefaultAzureCredential} = require('@azure/identity');
const {SecretClient} = require('@azure/keyvault-secrets');
// DefaultAzureCredential 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 DefaultAzureCredential();
  
const vaultName = process.env["KEYVAULT_NAME"] || "";
const url = `https://${vaultName}.vault.azure.net`;
  
const client = new SecretClient(url, credential);

const secretName = "MySecretName";

var server = http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
});

async function main(){
    // Create a secret
    const result = await client.setSecret(secretName, "MySecretValue");
    console.log("Secret name: ", result.name);
    // Read the secret we created
    const secret = await client.getSecret(secretName);
    console.log("Successfully retrieved 'MySecretName':", secret.value);
}
github Majavapaja / Majavashakki / deployment / src / context.ts View on Github external
export async function login(): Promise {
  const creds = await msRestNodeAuth.loginWithServicePrincipalSecret(clientId, secret, tenant)
  const websites = new appservice.WebSiteManagementClient(creds as any, subscriptionId)
  return {
    websites,
    webapps: new appservice.WebApps(websites),
    secrets: new SecretClient(`https://majavashakki-vault.vault.azure.net`, new EnvironmentCredential()),
    cosmosdb: new cosmosdb.CosmosDBManagementClient(creds as any, subscriptionId),
    containerregistry: new ContainerRegistryManagementClient(creds as any, subscriptionId),
  }
}

@azure/keyvault-secrets

Isomorphic client library for Azure KeyVault's secrets.

MIT
Latest version published 19 days ago

Package Health Score

95 / 100
Full package analysis