# enhanced-env-azure-vault

> Managing environment variables using Azure Key Vault tags

Latest version **1.2.6** (published 2022-01-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install enhanced-env-azure-vault
pnpm add enhanced-env-azure-vault
yarn add enhanced-env-azure-vault
bun add enhanced-env-azure-vault
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.6 |
| Published | 2022-01-29 |
| First published | 2021-05-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 31.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Pavel Stancik |
| Maintainers | pavelstancik |

## Links

- npm: https://www.npmjs.com/package/enhanced-env-azure-vault
- Repository: https://github.com/PavelStancik/enhanced-env-azure-vault
- Homepage: https://github.com/PavelStancik/enhanced-env-azure-vault#readme
- Issues: https://github.com/PavelStancik/enhanced-env-azure-vault/issues
- npm.io page: https://npm.io/package/enhanced-env-azure-vault

## Dependencies (5)

- [dotenv](https://npm.io/package/dotenv.md) ^14.3.2
- [ts-node](https://npm.io/package/ts-node.md) ^10.4.0
- [progress](https://npm.io/package/progress.md) ^2.0.3
- [@azure/identity](https://npm.io/package/@azure/identity.md) ^2.0.1
- [@azure/keyvault-secrets](https://npm.io/package/@azure/keyvault-secrets.md) ^4.3.0

## Recent versions

- 1.2.6 (latest) — 2022-01-29
- 1.2.5 — 2021-08-27
- 1.2.4 — 2021-07-02
- 1.2.3 — 2021-05-23
- 1.2.2 — 2021-05-21
- 1.2.1 — 2021-05-09
- 1.2.0 — 2021-05-09

## README

enhanced-env-azure-vault
========================
Managing environment variables using Azure Key Vault tags.

### Problem
When your application has many environment variables, they 
become difficult to manage. 

Sharing long env file with team members and then sharing again when updating them is a difficult task.
Managing multiple environemnt (local, demo, staging, production,...) again introduces some more challenges.

### Solution
If you are already using azure, manage your environment variables using key vault. It's a good service with many
benefits. [(learn more)](https://azure.microsoft.com/en-us/services/key-vault/)
- create a azure key vault.
- create a service principal with access to above key vault.
- use this package to set up and load env.

### Installation

```npm
npm install enhanced-env-azure-vault
```
or
```yarn
yarn add enhanced-env-azure-vault
```
### Usage
Send all your environment variables to your azure key vault.

Setup process is described in /examples/insert.ts.

```javascript

// enhanced-env-azure-vault expects the following environment variables
// KEY_VAULT_URI: The keyvault uri in Azure
// 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

import * as manager from 'enhanced-env-azure-vault';

// Your environment variables.
const envKeys = [

    { name: 'API_URL', value: 'AA', tags: { environment: 'testing', type: 'backend' } },
    { name: 'API_URL_FE', value: 'AA', tags: { environment: 'staging', type: 'frontend' } }

    // Any other variables
];

const result = await manager.setup({ envKeys });

```

### Load Variables in your app.
 
```javascript
import * as manager from 'enhanced-env-azure-vault';
const result = await manager.init({ envKeys });

```
  
### Getting all Variables from Azure, based on tags. 

```javascript
const scanVault = async (): Promise<secretObject[]> => {
  return await manager.listAll();
};

scanVault()
  .then(async (res) => {
    await res.forEach((element) => {
      if (element.tags && element.tags.type === "backend") {
        console.log(element);
        getEnv(element.name).then((env) => console.log(process.env));
      }
    });
  })
  .then((env) => console.log(env))
  .catch((err) => {
    console.log("Error scanning Azure Vault: ", err);
  });

// Now we can distinguish for example [testing / staging / production] environments
// AND type: [backend / frontend]
// OR utilize any other tag patterns 
```

---
_Source: https://npm.io/package/enhanced-env-azure-vault · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
