✅ Reading Secret.json
Hi, I want to read my secrets.json file, I set it but it doesnt work
my secrets.json:
31 Replies
still doest work ;/
What error is it giving you?
Seeing as you mention "secrets.json" did you add it?
Guess my question should be, how are you interacting with the json ?
i didnt add
@3R1C
but when I added give me return:
I am using .net webapi and secrets manager
secrets file is located in .microsoft/usersecrets not in project folder
Safe storage of app secrets in development in ASP.NET Core
Learn how to store and retrieve sensitive information during the development of an ASP.NET Core app.
I already used this and I still dont know What I am meant to do
is your secret identifier in your csproj?
I have my <UserSecretsId>id</UserSecretsId> in csproj
when i enter in cmd
dotnet user-secrets list
shows me my secrets
okay good
can you show me the content of your secrets file, verbatim?
ie exactly like it is
here
After :
i got
Plantaka:SMTPMail = mail...
give me a sec to reproduce
works fine here.
this is a brand new .net 7 webapp with
dotnet user-secrets init
and dotnet user-secrets set "Platanka:connStr" "1234"
mhm I used
and change value, and in Docker compose my WebApi returns:
.. docker compose?
yes
yeah no shit it doesnt work with docker compose my dude
this is literally only for local development
hmm , How can i put secrets in compose?
env vars
Platanka__connStr
would be the name you'd give it to make it work for that path
note the double underscoreOkey thank you , I need try it
this works fine
still doesnt work
are you trying via docker compose again?
you need to set the env vars inside the compose file in that case
iam using docker compose up --build
yea probably
not yea probably. thats exactly what you must do
Okey, thank you for your time
Now is working. Thank you again for gaining new experiences!
I used in docker-compose.yml file:
.env:
program.cs:
and its Works
yes
thats how you do secrets in non-dev environments
user-secrets
is specifically for local dev, aka via visual studiooAlright
(or
dotnet run
or via rider etc)
$closeUse the /close command to mark a forum thread as answered