@avanio/variable-util-azurekv
TypeScript icon, indicating that this package has built-in type declarations

0.9.1 • Public • Published

variable-util-node

Azure keyvault loader for @avanio/variable-util-azurekv

install

npm i @avanio/variable-util @avanio/variable-util-azurekv --save

Examples

setLogger(console); // or log4js or winston
// Azure KV loader
const credentials = new ClientSecretCredential(tenantId, clientId, clientSecret); // or any other Azure credentials (managed identity, etc.)
const kvEnv = new AzureSecretsConfigLoader(async () => ({credentials, url: `${process.env.KV_URI}`})).getLoader;
const fileEnv = new FileConfigLoader({fileName: './settings.json', type: 'json'}).getLoader;
// parser instaces
const urlParser = new UrlParser({urlSanitize: true}); // urlSanitize hides credentials from logs

// lookup from: env process.env.DATABASE_URI => JSON file "settings.json" DATABASE_URI key => keyvault process.env.KV_URI name  "zz-yy-database"
const databaseUrl: URL = await getConfigVariable('DATABASE_URI', [env(), fileEnv(), kvEnv('zz-yy-database')], urlParser, new URL('db://localhost'), {
	showValue: true,
});

new AzureSecretsConfigLoader(options).getLoader: IConfigLoader

A IConfigLoader instance that loads configuration values from Azure Keyvault secrets.

Note: getLoader is function generator which can override key we are looking for example, kvEnv() with default key or kvEnv('OVERRIDE_KEY')

  • options.credentials (required): TokenCredential.
  • options.url (required): string of Azure Keyvault URL.
  • options.disabled (optional): boolean to disable this loader.
  • options.isSilent (optional): boolean to hide error messages. (default: true)

Readme

Keywords

none

Package Sidebar

Install

npm i @avanio/variable-util-azurekv

Weekly Downloads

11

Version

0.9.1

License

MIT

Unpacked Size

12.4 kB

Total Files

6

Last publish

Collaborators

  • samutoljamo
  • olliglorioso
  • mharj