The details of my issue are listed up in this StackOverflow question (please don´t make me repeat it here)
But basically get this error
Npgsql.PostgresException (0x80004005): 28P01: password authentication failed for user "***"
But if I create a clean EF core project (no abp.io) I´m able to connect to the server and apply migrations using my user/pass that doesn´t work with the abp.io migrator. This here is the code that is working from within a docker
So what do I need to do or add to make this work?
- ABP Framework version: v7.2.2
- UI Type: Blazor Server
- Database System: EF Core (PostgreSQL
7 Answer(s)
-
0
hi
You can configure the
ConnectionStrings
ofAbpDbConnectionOptions
. -
0
Hi maliming sorry I don´t understand what you are referring to?
I am able to get the connection string into my docker image and it is able to try to connect to the server (if I put e.g. a wrong server it reports that there is no such server etc.)
And from the AbpDbConnectionOptions code and its documentation I can´t see anything that could help me there.
But there is something in the abp.io framework interfering in the connection but what and why?
-
0
hi
If you are using the
MyProjectName.DbMigrator
you need to put your connection string toappsettings.json
.https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json#L3
If you already did that, you can write some logs when running the
DbMigrator
.eg:
print current connection string
.please share it if you have custom the code of
DbMigrator
Thanks
-
0
Ok that worked BUTI don´t want to have the database password hardcoded in the docker file/source control. That is not a a future solution!
I would think that the environment variable should take precedence over the appsettings.json file, correct? It seems like its getting part of the connection string at least since it tries to connect to the server (so it has read that part of the env connection string) but has problem with the password... I don´t get this..
And I don´t have any custom code at all in my DbMigrator.
So what do you recommend I do here?
-
0
I managed to make this work but only by using
Environment.GetEnvironmentVariable("ConnectionStrings:Default")
I tried to add
AddEnvironmentVariables()
to CreateHostBuilder but that didn´t take.So here is what I had to do.
docker run --rm \ -e ConnectionStrings:Default="$connection_string" \ ${{ env.DEV_AZURE_CONTAINER_REGISTRY }}/dbmigrator:${{ github.sha }}
and the StartAsync()
public async Task StartAsync(CancellationToken cancellationToken) { var envConnectionString = Environment.GetEnvironmentVariable("ConnectionStrings:Default"); if (!string.IsNullOrEmpty(envConnectionString)) { _configuration["ConnectionStrings:Default"] = envConnectionString; Log.Logger.Information("Using ConnectionStrings:Default from environmental variable"); } .... rest of the code.. } }
There was also one other issue and that is I was using a $ in my password and that doesn´t work because the docker run command is running in Linux using bash and then the $ is handled as a variable and it (and following letters) are skipped!
-
0
So this is a question of how to set and get environment variables. Thanks.
-
0
Yes that´s correct. I chose probably the only symbol that didn´t work.
But it would be great to know how to enable the env´s and I would even go so far to say that they should be enabled by default...