-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong document for adding Azure authenticated NpgsqlDbContext #2081
Comments
same issue here |
Hey @davidfowl 👋 I see you've transferred this to docs from the Aspire repo, but I think this is actually an Aspire issue. The overload referred to was added to I'm not sure why, the overload is still there on the main branch: Although there seems to only be an extension for Apologies if I've misunderstood, this is just from me poking around, I don't 100% understand what I'm looking at here. But it looks like a problem on the Apsire side, not the docs side. cc: @aaronpowell |
Apologies, I was completely wrong. It is in fact still there in So definitely not a docs issue, and I guess adding it for EF Core is a feature request? |
@RamType0 @jjkopmels this is working for me: builder.AddNpgsqlDataSource(
ServiceConstants.APP_DATABASE, // I've got all my service names set as constants in a shared project
configureDataSourceBuilder: (dataSourceBuilder) =>
{
if (!string.IsNullOrEmpty(dataSourceBuilder.ConnectionStringBuilder.Password))
{
return;
}
dataSourceBuilder.UsePeriodicPasswordProvider(async (_, ct) =>
{
var credentials = new DefaultAzureCredential();
var token = await credentials.GetTokenAsync(
new TokenRequestContext([
"https://ossrdbms-aad.database.windows.net/.default"
]), ct);
return token.Token;
},
TimeSpan.FromHours(24),
TimeSpan.FromSeconds(10));
});
builder.Services.AddDbContext<ApplicationDbContext>((serviceProvider, options) =>
{
var dataSource = serviceProvider.GetRequiredService<NpgsqlDataSource>();
options.UseNpgsql(dataSource);
}); |
As of Aspire 9.0, Azure Database for PostgreSQL resources were updated to use Microsoft Entra ID by default.
Then, I start integration according to this article.
It says
but no such overload for AddNpgsqlDbContext exists.
The text was updated successfully, but these errors were encountered: