public static ConfigurationManager UseAzureKeyVault(this ConfigurationManager manager, AzureKeyVaultSettingsProviderOptions options) { // RegisterSetting(AzureKeyVaultDefaults.DefaultAzureADClientSecretKey, converter: CryptoHelper.DecryptEnvelop); options.ConfigurationManager = manager; manager.AddSettingsProvider(new AzureKeyVaultSettingsProvider(options), options.LoadingOrder); return(manager); }
public void TestMethod1() { //Add the following to your DI as a singleton. var config = new ConfigurationManager(new AppSettingsProvider()); var options = new AzureKeyVaultSettingsProviderOptions { ConfigurationManager = config, //Used to get the clientid,secret and uri of vault. SecretConverter = CryptoHelper.DecryptEnvelop }; config.AddSettingsProvider(new AzureKeyVaultSettingsProvider(options)); config.RegisterAzureKeyVaultSecret("sendgrid_secret"); //In your application do IoC.Resolve<ConfigurationManager>(); var secret = config.GetSetting <SecretBundle>("sendgrid_secret"); var a = config.GetAzureKeyVaultSecret("sendgrid_secret"); //And there is your secret taht you can use. }