77using Azure . Identity ;
88using Azure . Security . KeyVault . Secrets ;
99using Microsoft . Extensions . Logging ;
10+ using AzureSecurityKeyVaultSecret = Azure . Security . KeyVault . Secrets . KeyVaultSecret ;
1011
1112namespace NuGet . Services . KeyVault
1213{
@@ -39,9 +40,8 @@ public async Task<string> GetSecretAsync(string secretName)
3940
4041 public async Task < string > GetSecretAsync ( string secretName , ILogger logger )
4142 {
42- var response = await _keyVaultClient . Value . GetSecretAsync ( secretName ) ;
43- var secret = response . Value ;
44- return secret . Value ;
43+ AzureSecurityKeyVaultSecret response = await _keyVaultClient . Value . GetSecretAsync ( secretName ) ;
44+ return response . Value ;
4545 }
4646
4747 public async Task < ISecret > GetSecretObjectAsync ( string secretName )
@@ -51,9 +51,8 @@ public async Task<ISecret> GetSecretObjectAsync(string secretName)
5151
5252 public async Task < ISecret > GetSecretObjectAsync ( string secretName , ILogger logger )
5353 {
54- var response = await _keyVaultClient . Value . GetSecretAsync ( secretName ) ;
55- var secret = response . Value ;
56- return new KeyVaultSecret ( secretName , secret . Value , secret . Properties . ExpiresOn ) ;
54+ AzureSecurityKeyVaultSecret response = await _keyVaultClient . Value . GetSecretAsync ( secretName ) ;
55+ return new KeyVaultSecret ( secretName , response . Value , response . Properties . ExpiresOn ) ;
5756 }
5857
5958 private SecretClient InitializeClient ( )
@@ -75,8 +74,13 @@ private SecretClient InitializeClient()
7574 {
7675 credential = new ClientCertificateCredential ( _configuration . TenantId , _configuration . ClientId , _configuration . Certificate ) ;
7776 }
78- return new SecretClient ( _configuration . GetKeyVaultUri ( ) , credential ) ;
77+ return new SecretClient ( GetKeyVaultUri ( _configuration ) , credential ) ;
7978 }
80- }
8179
80+ private Uri GetKeyVaultUri ( KeyVaultConfiguration keyVaultConfiguration )
81+ {
82+ var uriString = $ "https://{ keyVaultConfiguration . VaultName } .vault.azure.net/";
83+ return new Uri ( uriString ) ;
84+ }
85+ }
8286}
0 commit comments