0.8.0 • Published 14 days ago

@avanio/variable-util-azurekv v0.8.0

Weekly downloads
-
License
MIT
Repository
-
Last release
14 days ago

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)
0.8.0

14 days ago

0.6.1

27 days ago

0.6.0

2 months ago

0.5.1

6 months ago

0.3.0

10 months ago

0.5.0

9 months ago

0.0.5

11 months ago

0.0.4

1 year ago

0.0.3

1 year ago