Skip to content

Commit a35fbba

Browse files
author
Kyle Hayes
authored
Merge pull request #1 from kylehayes/azure-creds-from-process-env
feat: support for labels
2 parents 186128a + 7fc8c29 commit a35fbba

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dotenv-azure",
3-
"version": "2.0.0",
3+
"version": "2.0.5",
44
"description": "Load environment variables from Azure's services App Configuration, Key Vault or a .env file",
55
"keywords": [
66
"azure",

src/dotenv-azure.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from 'fs'
22
import { URL } from 'url'
33
import Bottleneck from 'bottleneck'
4-
import dotenv, { DotenvParseOptions, DotenvParseOutput } from 'dotenv'
4+
import dotenv, { DotenvParseOptions } from 'dotenv'
55
import { ManagedIdentityCredential, ClientSecretCredential } from '@azure/identity'
66
import { SecretClient } from '@azure/keyvault-secrets'
77
import { AppConfigurationClient, ConfigurationSetting } from '@azure/app-configuration'
@@ -60,8 +60,8 @@ export default class DotenvAzure {
6060
async config(options: DotenvAzureConfigOptions = {}): Promise<DotenvAzureConfigOutput> {
6161
const { safe = false } = options
6262
const dotenvResult = dotenv.config(options)
63-
64-
const azureVars = await this.loadFromAzure(dotenvResult.parsed)
63+
const vars:Record<string, string | undefined> = {...(dotenvResult.parsed || {}), ...process.env}
64+
const azureVars = await this.loadFromAzure(vars)
6565
const joinedVars = { ...azureVars, ...dotenvResult.parsed }
6666

6767
populateProcessEnv(azureVars)
@@ -96,7 +96,8 @@ export default class DotenvAzure {
9696
* @param dotenvVars - dotenv parse() output containing azure credentials variables
9797
* @returns an object with keys and values
9898
*/
99-
async loadFromAzure(dotenvVars?: DotenvParseOutput): Promise<VariablesObject> {
99+
async loadFromAzure(dotenvVars?: Record<string, string | undefined>): Promise<VariablesObject> {
100+
// const vars = {...dotenvVars, ...process.env}
100101
const credentials = this.getAzureCredentials(dotenvVars)
101102
const appConfigClient = new AppConfigurationClient(credentials.connectionString)
102103
const labels = dotenvVars?.AZURE_APP_CONFIG_LABELS || ''
@@ -201,10 +202,10 @@ export default class DotenvAzure {
201202
)
202203
}
203204

204-
private getAzureCredentials(dotenvVars: DotenvParseOutput = {}): AzureCredentials {
205+
private getAzureCredentials(dotenvVars: Record<string, string | undefined> = {}): AzureCredentials {
205206
const vars = { ...dotenvVars, ...process.env }
206207
const connectionString = this.connectionString || vars.AZURE_APP_CONFIG_CONNECTION_STRING
207-
208+
208209
if (!connectionString) {
209210
throw new MissingAppConfigCredentialsError()
210211
}

0 commit comments

Comments
 (0)