@@ -70,19 +70,23 @@ public async Task<KeyVaultDescriptor> GetSecretAsync(
7070 {
7171 this . ValidateKeyVaultStore ( ) ;
7272 this . StoreDescription . ThrowIfNull ( nameof ( this . StoreDescription ) ) ;
73- KeyVaultManager . ValidateDescriptor ( descriptor , nameof ( descriptor . ObjectName ) , nameof ( descriptor . VaultUri ) ) ;
73+ KeyVaultManager . ValidateDescriptor ( descriptor , nameof ( descriptor . ObjectName ) ) ;
7474
75- var vaultUri = new Uri ( descriptor . VaultUri ) ;
76- var secretName = descriptor . ObjectName ;
75+ // Use descriptor.VaultUri if set, otherwise use the store's EndpointUri
76+ Uri vaultUri = ! string . IsNullOrWhiteSpace ( descriptor . VaultUri )
77+ ? new Uri ( descriptor . VaultUri )
78+ : ( ( DependencyKeyVaultStore ) this . StoreDescription ) . EndpointUri ;
7779
78- var client = new SecretClient ( vaultUri , ( ( DependencyKeyVaultStore ) this . StoreDescription ) . Credentials ) ;
80+ string secretName = descriptor . ObjectName ;
81+
82+ SecretClient client = new SecretClient ( vaultUri , ( ( DependencyKeyVaultStore ) this . StoreDescription ) . Credentials ) ;
7983
8084 try
8185 {
8286 return await ( retryPolicy ?? KeyVaultManager . DefaultRetryPolicy ) . ExecuteAsync ( async ( ) =>
8387 {
8488 KeyVaultSecret secret = await client . GetSecretAsync ( secretName , cancellationToken : cancellationToken ) ;
85- var result = new KeyVaultDescriptor ( descriptor )
89+ KeyVaultDescriptor result = new KeyVaultDescriptor ( descriptor )
8690 {
8791 Value = secret . Value ,
8892 Version = secret . Properties . Version ,
@@ -142,19 +146,23 @@ public async Task<KeyVaultDescriptor> GetKeyAsync(
142146 IAsyncPolicy retryPolicy = null )
143147 {
144148 this . ValidateKeyVaultStore ( ) ;
145- KeyVaultManager . ValidateDescriptor ( descriptor , nameof ( descriptor . ObjectName ) , nameof ( descriptor . VaultUri ) ) ;
149+ KeyVaultManager . ValidateDescriptor ( descriptor , nameof ( descriptor . ObjectName ) ) ;
150+
151+ // Use descriptor.VaultUri if set, otherwise use the store's EndpointUri
152+ Uri vaultUri = ! string . IsNullOrWhiteSpace ( descriptor . VaultUri )
153+ ? new Uri ( descriptor . VaultUri )
154+ : ( ( DependencyKeyVaultStore ) this . StoreDescription ) . EndpointUri ;
146155
147- var vaultUri = new Uri ( descriptor . VaultUri ) ;
148- var keyName = descriptor . ObjectName ;
156+ string keyName = descriptor . ObjectName ;
149157
150- var client = new KeyClient ( vaultUri , ( ( DependencyKeyVaultStore ) this . StoreDescription ) . Credentials ) ;
158+ KeyClient client = new KeyClient ( vaultUri , ( ( DependencyKeyVaultStore ) this . StoreDescription ) . Credentials ) ;
151159
152160 try
153161 {
154162 return await ( retryPolicy ?? KeyVaultManager . DefaultRetryPolicy ) . ExecuteAsync ( async ( ) =>
155163 {
156164 KeyVaultKey key = await client . GetKeyAsync ( keyName , cancellationToken : cancellationToken ) ;
157- var result = new KeyVaultDescriptor ( descriptor )
165+ KeyVaultDescriptor result = new KeyVaultDescriptor ( descriptor )
158166 {
159167 ObjectType = KeyVaultObjectType . Key ,
160168 ObjectName = keyName ,
@@ -213,19 +221,23 @@ public async Task<KeyVaultDescriptor> GetCertificateAsync(
213221 IAsyncPolicy retryPolicy = null )
214222 {
215223 this . ValidateKeyVaultStore ( ) ;
216- KeyVaultManager . ValidateDescriptor ( descriptor , nameof ( descriptor . ObjectName ) , nameof ( descriptor . VaultUri ) ) ;
224+ KeyVaultManager . ValidateDescriptor ( descriptor , nameof ( descriptor . ObjectName ) ) ;
225+
226+ // Use descriptor.VaultUri if set, otherwise use the store's EndpointUri
227+ Uri vaultUri = ! string . IsNullOrWhiteSpace ( descriptor . VaultUri )
228+ ? new Uri ( descriptor . VaultUri )
229+ : ( ( DependencyKeyVaultStore ) this . StoreDescription ) . EndpointUri ;
217230
218- var vaultUri = new Uri ( descriptor . VaultUri ) ;
219- var certName = descriptor . ObjectName ;
231+ string certName = descriptor . ObjectName ;
220232
221- var client = new CertificateClient ( vaultUri , ( ( DependencyKeyVaultStore ) this . StoreDescription ) . Credentials ) ;
233+ CertificateClient client = new CertificateClient ( vaultUri , ( ( DependencyKeyVaultStore ) this . StoreDescription ) . Credentials ) ;
222234
223235 try
224236 {
225237 return await ( retryPolicy ?? KeyVaultManager . DefaultRetryPolicy ) . ExecuteAsync ( async ( ) =>
226238 {
227239 KeyVaultCertificateWithPolicy cert = await client . GetCertificateAsync ( certName , cancellationToken : cancellationToken ) ;
228- var result = new KeyVaultDescriptor ( descriptor )
240+ KeyVaultDescriptor result = new KeyVaultDescriptor ( descriptor )
229241 {
230242 ObjectType = KeyVaultObjectType . Certificate ,
231243 ObjectName = certName ,
@@ -278,7 +290,7 @@ public async Task<KeyVaultDescriptor> GetCertificateAsync(
278290 private static void ValidateDescriptor ( DependencyDescriptor descriptor , params string [ ] requiredProperties )
279291 {
280292 descriptor . ThrowIfNull ( nameof ( descriptor ) ) ;
281- foreach ( var property in requiredProperties )
293+ foreach ( string property in requiredProperties )
282294 {
283295 if ( ! descriptor . ContainsKey ( property ) || string . IsNullOrWhiteSpace ( descriptor [ property ] ? . ToString ( ) ) )
284296 {
0 commit comments