@@ -946,22 +946,26 @@ private static ISqlConnectionFactory CreateDbConnectionFactory(
946946 ILoggerFactory loggerFactory ,
947947 string name ,
948948 string connectionString ,
949- ISecretInjector secretInjector )
949+ ICachingSecretInjector secretInjector )
950950 {
951951 var logger = loggerFactory . CreateLogger ( $ "AzureSqlConnectionFactory-{ name } ") ;
952952 return new AzureSqlConnectionFactory ( connectionString , secretInjector , logger ) ;
953953 }
954954
955- private static DbConnection CreateDbConnection ( ISqlConnectionFactory connectionFactory )
955+ public static DbConnection CreateDbConnection ( ISqlConnectionFactory connectionFactory )
956956 {
957+ if ( connectionFactory . TryCreate ( out var connection ) )
958+ {
959+ return connection ;
960+ }
957961 return Task . Run ( ( ) => connectionFactory . CreateAsync ( ) ) . Result ;
958962 }
959963
960964 private static void ConfigureGalleryReadOnlyReplicaEntitiesContext (
961965 ContainerBuilder builder ,
962966 ILoggerFactory loggerFactory ,
963967 ConfigurationService configuration ,
964- ISecretInjector secretInjector )
968+ ICachingSecretInjector secretInjector )
965969 {
966970 var galleryDbReadOnlyReplicaConnectionFactory = CreateDbConnectionFactory (
967971 loggerFactory ,
@@ -982,7 +986,7 @@ private static void ConfigureValidationEntitiesContext(
982986 ContainerBuilder builder ,
983987 ILoggerFactory loggerFactory ,
984988 ConfigurationService configuration ,
985- ISecretInjector secretInjector )
989+ ICachingSecretInjector secretInjector )
986990 {
987991 var validationDbConnectionFactory = CreateDbConnectionFactory (
988992 loggerFactory ,
@@ -1011,7 +1015,7 @@ private void RegisterAsynchronousValidation(
10111015 ContainerBuilder builder ,
10121016 ILoggerFactory loggerFactory ,
10131017 ConfigurationService configuration ,
1014- ISecretInjector secretInjector )
1018+ ICachingSecretInjector secretInjector )
10151019 {
10161020 builder
10171021 . RegisterType < NuGet . Services . Validation . ServiceBusMessageSerializer > ( )
0 commit comments