-
Hi everyone 🙂, I was trying to replace one of my workloads using the following example: https://github.com/dotnet/aspire-samples/tree/main/samples/DatabaseContainers and adapted some of the scripts in the example for my requirements. My requirements:
Following a few articles online I changed the script to use a persistent SA password, to specify a port for the container (this to avoid conflict with other containers), and pass specific environment variables (these are used in the database initialization script). References:
This is how I adapted the program class on the Aspire App Host:
This approach doesn't work 😢 Data persistence works, but I am not able to run the scripts anymore. By looking at the logs on the SQL Server instance, I can see that the scripts timed out. The problem can be possibly:
Did anyone have a similar issue? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
I think that I solved it by tweaking my initialization. I changed it from:
to:
🤔 why it works this way |
Beta Was this translation helpful? Give feedback.
-
For anyone stumbling upon this problem in the future. It's likely that your old password was stored in your data volume. One more way to solve this is to find the data volume that was created by Aspire for your SQL Server and delete it. Warning: this will, of course, wipe all your local test data, so proceed with caution. More info: |
Beta Was this translation helpful? Give feedback.
-
Ok, so I spent quite a while trying to figure this one out. And it's ...weird. While removing the data volume worked for me -- it only worked once. Now, the way Aspire makes sure the password remains the same across app starts is that it stores a user secret in dotnet user-secrets with the sql password. You can see it by running I tried setting the secret manually as per docs, removing volumes, making the secrets file readonly and renaming volumes to different things. But the only thing that eventually helped was removing the user secret for Aspire to set it again. Then drop the volume in Docker. After that it stopped overwriting the secret and started using the one it set for all consequent runs.
Hope this helps somebody solve this weird issue. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I have this problem too but running in a devcontainer. When I rebuild the devcontainer the SQL container starts reporting Login failed because a new random password was generated by Aspire. What I can't understand is, where is this old password stored? When I rebuild the devcontainer everything is wiped (nothing should be stored on my local machine...). If I manually edit the secrets.json in the usersecrets store to the old password before I rebuilt, it starts working. |
Beta Was this translation helpful? Give feedback.
I think that I solved it by tweaking my initialization.
I changed it from:
to:
🤔 why it works this way