我正在使用 DefaultCredential 连接以从 azure keyvault 构建配置。
var secretClient = new SecretClient(new Uri($"https://{keyvaultName}.vault.azure.net/"),
new DefaultAzureCredential(true)
);
IConfigurationRoot configuration = null;
configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json")
.AddEnvironmentVariables()
.AddAzureKeyVault(secretClient, new PrefixKeyVaultSecretManager(environment))
.AddUserSecrets<Program>().Build();
这在早期工作,但现在交互式浏览器身份验证失败。选择帐户后,它会重定向回 localhost 并抛出错误(“localhost sent an invalid response”)我正在使用 "Azure.Identity" Version="1.4.1" 。我还尝试了最新的 beta 包(1.5.0-beta.4)。还有 Azure.Security.KeyVault.Secrets" Version="4.2.0"