How to use the @azure/identity.EnvironmentCredential function in @azure/identity

To help you get started, we’ve selected a few @azure/identity 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 / azure-sdk-for-js / common / smoke-test / KeyVault.ts View on Github external
static async Run() {
    console.log(KeyVaultSecrets.dedent`
        ------------------------
        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();
    }
  }
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/identity

Provides credential implementations for Azure SDK libraries that can authenticate with Microsoft Entra ID

MIT
Latest version published 2 months ago

Package Health Score

86 / 100
Full package analysis