@@ -529,15 +529,6 @@ public Fixture()
529
529
var configuration = TestHelpers . GetTestConfiguration ( ) ;
530
530
BlobConnectionString = configuration . GetWebJobsConnectionString ( ConnectionStringNames . Storage ) ;
531
531
532
- KeyVaultConnectionString = configuration . GetWebJobsConnectionString ( EnvironmentSettingNames . AzureWebJobsSecretStorageKeyVaultConnectionString ) ;
533
- KeyVaultName = configuration . GetWebJobsConnectionString ( EnvironmentSettingNames . AzureWebJobsSecretStorageKeyVaultName ) ;
534
-
535
- if ( KeyVaultConnectionString is not null && KeyVaultName is not null )
536
- {
537
- AzureServiceTokenProvider azureServiceTokenProvider = new AzureServiceTokenProvider ( KeyVaultConnectionString ) ;
538
- KeyVaultClient = new KeyVaultClient ( new KeyVaultClient . AuthenticationCallback ( azureServiceTokenProvider . KeyVaultTokenCallback ) ) ;
539
- }
540
-
541
532
Environment = new TestEnvironment ( ) ;
542
533
AzureStorageProvider = TestHelpers . GetAzureStorageProvider ( configuration ) ;
543
534
}
@@ -554,8 +545,6 @@ public Fixture()
554
545
555
546
public CloudBlobContainer BlobContainer { get ; private set ; }
556
547
557
- public KeyVaultClient KeyVaultClient { get ; private set ; }
558
-
559
548
public string KeyVaultName { get ; private set ; }
560
549
561
550
public string KeyVaultConnectionString { get ; private set ; }
@@ -588,11 +577,6 @@ public async Task TestInitialize(SecretsRepositoryType repositoryType, string se
588
577
await ClearAllBlobSecrets ( ) ;
589
578
ClearAllFileSecrets ( ) ;
590
579
591
- if ( KeyVaultClient != null )
592
- {
593
- await ClearAllKeyVaultSecrets ( ) ;
594
- }
595
-
596
580
LoggerProvider = new TestLoggerProvider ( ) ;
597
581
var loggerFactory = new LoggerFactory ( ) ;
598
582
loggerFactory . AddProvider ( LoggerProvider ) ;
@@ -626,7 +610,6 @@ public void Dispose()
626
610
// delete blob files
627
611
ClearAllBlobSecrets ( ) . ContinueWith ( t => { } ) ;
628
612
ClearAllFileSecrets ( ) ;
629
- ClearAllKeyVaultSecrets ( ) . ContinueWith ( t => { } ) ;
630
613
}
631
614
catch
632
615
{
@@ -663,9 +646,6 @@ public async Task WriteSecret(string functionNameOrHost, ScriptSecrets scriptSec
663
646
case SecretsRepositoryType . BlobStorageSas :
664
647
await WriteSecretsBlobAndUpdateSentinelFile ( functionNameOrHost , ScriptSecretSerializer . SerializeSecrets ( scriptSecret ) ) ;
665
648
break ;
666
- case SecretsRepositoryType . KeyVault :
667
- await WriteSecretsKeyVaultAndUpdateSectinelFile ( functionNameOrHost , scriptSecret ) ;
668
- break ;
669
649
default :
670
650
break ;
671
651
}
@@ -692,15 +672,6 @@ private async Task WriteSecretsBlobAndUpdateSentinelFile(string functionNameOrHo
692
672
}
693
673
}
694
674
695
- private async Task WriteSecretsKeyVaultAndUpdateSectinelFile ( string functionNameOrHost , ScriptSecrets secrets , bool createSentinelFile = true )
696
- {
697
- Dictionary < string , string > dictionary = KeyVaultSecretsRepository . GetDictionaryFromScriptSecrets ( secrets , functionNameOrHost ) ;
698
- foreach ( string key in dictionary . Keys )
699
- {
700
- await KeyVaultClient . SetSecretAsync ( GetKeyVaultBaseUrl ( ) , key , dictionary [ key ] ) ;
701
- }
702
- }
703
-
704
675
public async Task < ScriptSecrets > GetSecretText ( string functionNameOrHost , ScriptSecretsType type )
705
676
{
706
677
ScriptSecrets secrets = null ;
@@ -714,9 +685,6 @@ public async Task<ScriptSecrets> GetSecretText(string functionNameOrHost, Script
714
685
case SecretsRepositoryType . BlobStorageSas :
715
686
secrets = await GetSecretBlobText ( functionNameOrHost , type ) ;
716
687
break ;
717
- case SecretsRepositoryType . KeyVault :
718
- secrets = await GetSecretsFromKeyVault ( functionNameOrHost , type ) ;
719
- break ;
720
688
default :
721
689
break ;
722
690
}
@@ -734,33 +702,6 @@ private async Task<ScriptSecrets> GetSecretBlobText(string functionNameOrHost, S
734
702
return ScriptSecretSerializer . DeserializeSecrets ( type , blobText ) ;
735
703
}
736
704
737
- private async Task < ScriptSecrets > GetSecretsFromKeyVault ( string functionNameOrHost , ScriptSecretsType type )
738
- {
739
- var secretResults = await KeyVaultClient . GetSecretsAsync ( GetKeyVaultBaseUrl ( ) ) ;
740
- if ( type == ScriptSecretsType . Host )
741
- {
742
- SecretBundle masterBundle = await KeyVaultClient . GetSecretAsync ( GetKeyVaultBaseUrl ( ) , secretResults . FirstOrDefault ( x => x . Identifier . Name . StartsWith ( "host--master" ) ) . Identifier . Name ) ;
743
- SecretBundle functionKeyBundle = await KeyVaultClient . GetSecretAsync ( GetKeyVaultBaseUrl ( ) , secretResults . FirstOrDefault ( x => x . Identifier . Name . StartsWith ( "host--functionKey" ) ) . Identifier . Name ) ;
744
- SecretBundle systemKeyBundle = await KeyVaultClient . GetSecretAsync ( GetKeyVaultBaseUrl ( ) , secretResults . FirstOrDefault ( x => x . Identifier . Name . StartsWith ( "host--systemKey" ) ) . Identifier . Name ) ;
745
- HostSecrets hostSecrets = new HostSecrets ( )
746
- {
747
- FunctionKeys = new List < Key > ( ) { new Key ( GetSecretName ( functionKeyBundle . SecretIdentifier . Name ) , functionKeyBundle . Value ) } ,
748
- SystemKeys = new List < Key > ( ) { new Key ( GetSecretName ( systemKeyBundle . SecretIdentifier . Name ) , systemKeyBundle . Value ) }
749
- } ;
750
- hostSecrets . MasterKey = new Key ( "master" , masterBundle . Value ) ;
751
- return hostSecrets ;
752
- }
753
- else
754
- {
755
- SecretBundle functionKeyBundle = await KeyVaultClient . GetSecretAsync ( GetKeyVaultBaseUrl ( ) , secretResults . FirstOrDefault ( x => x . Identifier . Name . StartsWith ( "function--" ) ) . Identifier . Name ) ;
756
- FunctionSecrets functionSecrets = new FunctionSecrets ( )
757
- {
758
- Keys = new List < Key > ( ) { new Key ( GetSecretName ( functionKeyBundle . SecretIdentifier . Name ) , functionKeyBundle . Value ) }
759
- } ;
760
- return functionSecrets ;
761
- }
762
- }
763
-
764
705
public bool MarkerFileExists ( string functionNameOrHost )
765
706
{
766
707
return File . Exists ( SecretsFileOrSentinelPath ( functionNameOrHost ) ) ;
@@ -800,18 +741,6 @@ private async Task ClearAllBlobSecrets()
800
741
await BlobContainer . GetBlockBlobReference ( ( ( CloudBlockBlob ) blob ) . Name ) . DeleteIfExistsAsync ( ) ;
801
742
}
802
743
}
803
-
804
- private async Task ClearAllKeyVaultSecrets ( )
805
- {
806
- var secretsPages = await KeyVaultSecretsRepository . GetKeyVaultSecretsPagesAsync ( KeyVaultClient , GetKeyVaultBaseUrl ( ) ) ;
807
- foreach ( IPage < SecretItem > secretsPage in secretsPages )
808
- {
809
- foreach ( SecretItem item in secretsPage )
810
- {
811
- await KeyVaultClient . DeleteSecretAsync ( GetKeyVaultBaseUrl ( ) , item . Identifier . Name ) ;
812
- }
813
- }
814
- }
815
744
}
816
745
}
817
746
}
0 commit comments