コード例 #1
0
        // Extension method that configures KeyVault config provider using MSI Auth
        public static void ConfigureKeyvaultMSI(this IConfigurationBuilder config, string keyvaulturl, string aadappid)
        {
            if (string.IsNullOrEmpty(keyvaulturl) || string.IsNullOrEmpty(aadappid))
            {
                throw new ArgumentException("missing keyvault URI or aadappid");
            }

            config.AddAKVwithMSIAuth(keyvaulturl, aadappid);

            //TODO: if this worked we'd use it but there is a dependency failure
            //var azureServiceTokenProvider = new AzureServiceTokenProvider();
            //var keyVaultClient = new createkvclientformsi

            //config.AddAzureKeyVault(
            //    //TODO store kv name in config
            //    //$"https://{builtConfig["KeyVaultName"]}.vault.azure.net/",
            //    keyvaultbase,
            //    keyVaultClient,
            //    new DefaultKeyVaultSecretManager());
        }