@@ -91,6 +91,8 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
9191 #secretRefreshEnabled: boolean = false ;
9292 #secretReferences: ConfigurationSetting [ ] = [ ] ; // cached key vault references
9393 #secretRefreshTimer: RefreshTimer ;
94+ #resolveSecretInParallel: boolean = false ;
95+
9496 /**
9597 * Selectors of key-values obtained from @see AzureAppConfigurationOptions.selectors
9698 */
@@ -181,6 +183,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
181183 this . #secretRefreshEnabled = true ;
182184 this . #secretRefreshTimer = new RefreshTimer ( secretRefreshIntervalInMs ) ;
183185 }
186+ this . #resolveSecretInParallel = options . keyVaultOptions . parallelSecretResolutionEnabled ?? false ;
184187 }
185188 this . #adapters. push ( new AzureKeyVaultKeyValueAdapter ( options ?. keyVaultOptions , this . #secretRefreshTimer) ) ;
186189 this . #adapters. push ( new JsonKeyValueAdapter ( ) ) ;
@@ -504,7 +507,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
504507 async #loadSelectedAndWatchedKeyValues( ) {
505508 this . #secretReferences = [ ] ; // clear all cached key vault reference configuration settings
506509 const keyValues : [ key : string , value : unknown ] [ ] = [ ] ;
507- const loadedSettings = await this . #loadConfigurationSettings( ) ;
510+ const loadedSettings : ConfigurationSetting [ ] = await this . #loadConfigurationSettings( ) ;
508511 if ( this . #refreshEnabled && ! this . #watchAll) {
509512 await this . #updateWatchedKeyValuesEtag( loadedSettings ) ;
510513 }
@@ -514,14 +517,30 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
514517 this . #aiConfigurationTracing. reset ( ) ;
515518 }
516519
517- // adapt configuration settings to key-values
520+ const secretResolutionPromises : Promise < void > [ ] = [ ] ;
518521 for ( const setting of loadedSettings ) {
519- if ( this . #secretRefreshEnabled && isSecretReference ( setting ) ) {
520- this . #secretReferences. push ( setting ) ;
522+ if ( isSecretReference ( setting ) ) {
523+ if ( this . #secretRefreshEnabled) {
524+ this . #secretReferences. push ( setting ) ;
525+ }
526+ if ( this . #resolveSecretInParallel) {
527+ // secret references are resolved asynchronously to improve performance
528+ const secretResolutionPromise = this . #processKeyValue( setting )
529+ . then ( ( [ key , value ] ) => {
530+ keyValues . push ( [ key , value ] ) ;
531+ } ) ;
532+ secretResolutionPromises . push ( secretResolutionPromise ) ;
533+ continue ;
534+ }
521535 }
536+ // adapt configuration settings to key-values
522537 const [ key , value ] = await this . #processKeyValue( setting ) ;
523538 keyValues . push ( [ key , value ] ) ;
524539 }
540+ if ( secretResolutionPromises . length > 0 ) {
541+ // wait for all secret resolution promises to be resolved
542+ await Promise . all ( secretResolutionPromises ) ;
543+ }
525544
526545 this . #clearLoadedKeyValues( ) ; // clear existing key-values in case of configuration setting deletion
527546 for ( const [ k , v ] of keyValues ) {
@@ -566,7 +585,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
566585 */
567586 async #loadFeatureFlags( ) {
568587 const loadFeatureFlag = true ;
569- const featureFlagSettings = await this . #loadConfigurationSettings( loadFeatureFlag ) ;
588+ const featureFlagSettings : ConfigurationSetting [ ] = await this . #loadConfigurationSettings( loadFeatureFlag ) ;
570589
571590 if ( this . #requestTracingEnabled && this . #featureFlagTracing !== undefined ) {
572591 // Reset old feature flag tracing in order to track the information present in the current response from server.
0 commit comments