dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.79k stars 441 forks source link

Wrong Credentials for AzurePostgresFlexibleServer #6284

Open osyyyS opened 1 week ago

osyyyS commented 1 week ago

Is there an existing issue for this?

Describe the bug

I have a simple API with that uses a Postgres Database with .PublishAsAzurePostgresFlexibleServer(). When I publish my App Host to Azure, it creates a Key Vault with a connectionstring. However, the username inside the connectionstring is wrong. I can fix it by changing the connection string manually, but the next time I deploy the application. It gets changed back to the wrong one. There might be an easy fix that I missed since I'm new to aspire, but I could find it.

This is my AppHost:

var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgresserver")
  .WithDataVolume()
  .PublishAsAzurePostgresFlexibleServer();

var db = postgres.AddDatabase("db");

var server = builder.AddProject<Server>("server")
  .WithReference(db)
  .WithExternalHttpEndpoints();

builder.Build().Run();

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

Unhandled exception. Npgsql.PostgresException (0x80004005): 28P01: password authentication failed for user "***"

.NET Version info

8.0.401

Anything else?

aspire 8.2.0/8.0.100 VS 17.12.35323.107

davidfowl commented 6 days ago

What's the username and what is the expected username?

mitchdenny commented 5 days ago

@osyyyS based on your description I suspect that you have a local config.json file which contains the old username. Take a look in .azure/<envname>/config.json - this is probably the username that it keeps getting reset back to?

mitchdenny commented 5 days ago

Moving to backlog as I am now pretty confident this is not a blocking issue for 9.0.