✅ Storing connection string securely
I am developing a web API and I created my database first on azure. To create the models i used this command
Scaffold-DbContext "CONNECTION STRING" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Now I have my string right in the DBcontext.cs file. I don't want to keep the string in the code like that.
How can I store my string in a secure way?
3 Replies
The "usual" way would be... https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-8.0&tabs=windows
appsettings.json
Or env variable
Or Azure Key Vaultenv vars in production, user secrets during development
thou keyvault is also a great option, if you are already on the azure train