Skip to content
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

Create a persistent password shouldn't point to sample method #672

Closed
davidfowl opened this issue Apr 14, 2024 · 8 comments · Fixed by #760
Closed

Create a persistent password shouldn't point to sample method #672

davidfowl opened this issue Apr 14, 2024 · 8 comments · Fixed by #760
Assignees
Labels
database Content related to database. docs-experience Indicates issues that are about the learn.microsoft.com experience or design [org][type][category] documentation Improvements or additions to documentation dotnet-aspire/prod Pri0 Indicates issues or PRs that are critical priority 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@davidfowl
Copy link
Member

davidfowl commented Apr 14, 2024

https://github.com/dotnet/docs-aspire/blob/main/docs/fundamentals/persist-data-volumes.md#create-a-persistent-password

Creating a persistent password should show how to set the parameter value and not show these helper extension methods.

Instead, we should show how to set parameter values named appropriately:

We should document all of the resources that generate passwords, and we should talk about the parameter names for those generated passwords. We should also show how you can set the passwords without changing any code.

  • Postgres
  • SqlServer
  • MySql
  • RabbitMq

For example:

var builder = DistributedApplication.CreateBuilder(args);

var db = builder.AddSqlServer("sql").AddDatabase("db");

builder.AddProject<Projects.WebApplication10>("api")
       .WithExternalHttpEndpoints()
       .WithReference(db);

builder.Build().Run();

You can set a persistent password for sqlserver by setting the parameter value in user secrets in the AppHost project:

dotnet user-secrets add Parameters:sql-password {somepassword}

This will override the auto generated password used by the sql server resources above. The pattern for auto generated password parameters is Parameters:{resourcename}-password.

cc @eerhardt


Associated WorkItem - 250486

@eerhardt
Copy link
Member

I believe @DamianEdwards's intention with this code was that when you don't dotnet user-secrets add ... and just run the app you get an error. People were confused and thought that the app was broken. So the thinking was to "just make it work".

@davidfowl
Copy link
Member Author

Sure but we shouldn't document it, that's a sample. We should just tell people to set the user secret.

@theo-albers
Copy link

theo-albers commented Apr 15, 2024

We should document all of the resources that generate passwords, and we should talk about the parameter names for those generated passwords.

Would it be possible to dump the used environment variables to the console via a config switch *)? That way you wouldn't have to document it, disconnected from the code.

*) dump the name with a brief description, not the actual values.

@davidfowl
Copy link
Member Author

I think that's an unrelated feature request.

@tmds
Copy link
Member

tmds commented Apr 24, 2024

I found this issue while looking for any issues about the Create a persistent password section.

Currently this section shows some code and it's not clear how Aspire would be using the samplepassword value.

@rmarinho
Copy link
Member

Yeah I hitted this myself doing the eShop workshop to get familiar with aspire. I did tried to add as Parameter but then it said it didn't found it on my settings.

@IEvangelist IEvangelist self-assigned this Apr 26, 2024
@IEvangelist IEvangelist added documentation Improvements or additions to documentation 🗺️ reQUEST Triggers an issue to be imported into Quest. Pri0 Indicates issues or PRs that are critical priority database Content related to database. docs-experience Indicates issues that are about the learn.microsoft.com experience or design [org][type][category] dotnet-aspire/prod and removed ⌚ Not Triaged Not triaged labels Apr 26, 2024
IEvangelist added a commit to IEvangelist/docs-aspire that referenced this issue Apr 26, 2024
IEvangelist added a commit that referenced this issue Apr 26, 2024
* Local snippets, and updates to address #672

* Tweaks

* Fix ids

* Fix indents
@github-project-automation github-project-automation bot moved this from 🔖 Ready to ✅ Done in dotnet/docs April 2024 sprint Apr 26, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Apr 30, 2024
@rudivs
Copy link

rudivs commented May 1, 2024

Just to mention, the correct command to set the persistent password is:

dotnet user-secrets set Parameters:sql-password {somepassword}

If you don't have user secrets configured yet, you first need to run:

dotnet user-secrets init

@davidfowl
Copy link
Member Author

Good call out. The apphost should have a user secrets id set from preview 5 onwards (so it should be init-ed already).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Content related to database. docs-experience Indicates issues that are about the learn.microsoft.com experience or design [org][type][category] documentation Improvements or additions to documentation dotnet-aspire/prod Pri0 Indicates issues or PRs that are critical priority 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

8 participants