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!
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?
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?
I have few ideas for Suite functionality
Make it possible to
I think that Suite has lot of possibilities to be a even grater tool than its now!
I would also allow users to comment on the documentation at the bottom! Just like you are able to do in the Microsoft docs. This will help users add more information that helps others faster and you to update the docs.
How about fixing the search?
Try e.g. searching for Tiered and it will not return the Tired information I needed from the Suite creation window. I had to manually search and find it here.
I would add a ChatGPT/OpenAPI search option to the search so we can get better assistance! I would probably also let OpenAI loose on your support/github questions and ask it to create missing information documents for you. This would be money and time well spent.
btw there are lots of other examples of the search coming up short. I was searching for information on appsettings.secrets.json and can´t find any. I could get some info when searching the github issues and found this here so I know its ok to check it into git...