asp.net 'IConfigurationBuilder'不包含'AddAzureAppConfiguration'的定义

dluptydi  于 2022-12-01  发布在  .NET
关注(0)|答案(2)|浏览(149)

尝试在Program.cs中使用Azure密钥保管库设置Azure应用程序配置,并遇到以下错误:
'IConfigurationBuilder'不包含'AddAzureAppConfiguration'的定义

public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        webBuilder.ConfigureAppConfiguration((hostingContext, config) =>
        {
            var settings = config.Build();

            config.AddAzureAppConfiguration(options =>
            {
                options.Connect(settings["ConnectionStrings:AppConfig"])
                        .ConfigureKeyVault(kv =>
                        {
                            kv.SetCredential(new DefaultAzureCredential());
                        });
            });
        })
        .UseStartup<Startup>());
cgfeq70w

cgfeq70w1#

添加以下软件包修复了它:

dotnet add package Microsoft.Azure.AppConfiguration.AspNetCore
mnemlml8

mnemlml82#

或者更好:

dotnet add package Microsoft.Extensions.Configuration.AzureAppConfiguration

相关问题