11import * as fs from 'fs'
22import { URL } from 'url'
33import Bottleneck from 'bottleneck'
4- import dotenv , { DotenvParseOptions , DotenvParseOutput } from 'dotenv'
4+ import dotenv , { DotenvParseOptions } from 'dotenv'
55import { ManagedIdentityCredential , ClientSecretCredential } from '@azure/identity'
66import { SecretClient } from '@azure/keyvault-secrets'
77import { 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 )
@@ -86,8 +86,6 @@ export default class DotenvAzure {
8686 */
8787 async parse ( src : string , options ?: DotenvParseOptions ) : Promise < DotenvAzureParseOutput > {
8888 const dotenvVars = dotenv . parse ( src , options )
89- dotenvVars . AZURE_APP_CONFIG_LABELS = dotenvVars . AZURE_APP_CONFIG_LABELS ? dotenvVars . AZURE_APP_CONFIG_LABELS : process . env . AZURE_APP_CONFIG_LABELS || ''
90- dotenvVars . AZURE_APP_CONFIG_CONNECTION_STRING = dotenvVars . AZURE_APP_CONFIG_CONNECTION_STRING ? dotenvVars . AZURE_APP_CONFIG_CONNECTION_STRING : process . env . AZURE_APP_CONFIG_CONNECTION_STRING || ''
9189 const azureVars = await this . loadFromAzure ( dotenvVars )
9290 return { ...azureVars , ...dotenvVars }
9391 }
@@ -98,7 +96,8 @@ export default class DotenvAzure {
9896 * @param dotenvVars - dotenv parse() output containing azure credentials variables
9997 * @returns an object with keys and values
10098 */
101- async loadFromAzure ( dotenvVars ?: DotenvParseOutput ) : Promise < VariablesObject > {
99+ async loadFromAzure ( dotenvVars ?: Record < string , string | undefined > ) : Promise < VariablesObject > {
100+ // const vars = {...dotenvVars, ...process.env}
102101 const credentials = this . getAzureCredentials ( dotenvVars )
103102 const appConfigClient = new AppConfigurationClient ( credentials . connectionString )
104103 const labels = dotenvVars ?. AZURE_APP_CONFIG_LABELS || ''
@@ -203,10 +202,10 @@ export default class DotenvAzure {
203202 )
204203 }
205204
206- private getAzureCredentials ( dotenvVars : DotenvParseOutput = { } ) : AzureCredentials {
205+ private getAzureCredentials ( dotenvVars : Record < string , string | undefined > = { } ) : AzureCredentials {
207206 const vars = { ...dotenvVars , ...process . env }
208207 const connectionString = this . connectionString || vars . AZURE_APP_CONFIG_CONNECTION_STRING
209-
208+
210209 if ( ! connectionString ) {
211210 throw new MissingAppConfigCredentialsError ( )
212211 }
0 commit comments