Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Using the PAAS Portal Secrets in local development

Vote:
 

 

Hey all, maybe I am just missing where this was documented, but I am going to start making use of the App Settings Secrets blade on the PAAS Portal.

I know that these ONLY apply to the running envorinment for which they are deployed, that's to say I shouldn't expect to have access to those secrets during local development.

So that is my question, when I am developing code that I plan to later use the App Settings Secrets, how do I setup my local to proivde values from somewhere? 

Do I just put them in Visual Studio's Debug settings?

 

#336613
Feb 10, 2025 17:21
Vote:
 

Take a look at this https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-9.0&tabs=windows

#336614
Feb 10, 2025 17:55
Vote:
 

To my understanding, PaaS portal allows you to add secrets which will add or override any setting added in appsettings.json. You should be able to acess those settings using IConfiguration interface. 

There are couple of options:

1) if you want settings file to be part of the project, add specific appsettings.something.json and apply it on app startup while checking if the development environment is used.
2) if you don't want to commit as a separate file to the repository and make them visible only to you, then you can use User Secrets.

Anyhow, app secrets added from PaaS Portal should override any existing key added to appsettings.json or appsettings.environment.json.

Links:
Add app settings and connection strings
Safe storage of app secrets in development in ASP.NET Core | Microsoft Learn

#336646
Feb 11, 2025 12:53
Vote:
 

 

Yeah, Milos, this is the right answer after working with the system yesterday afternoon. 

From reading comments in the forums, where I got confused is that .Net in general supports the idea of the IOptions pattern for injecting settings from AppSettings.json into services and the like.

While it also supports just getting them straight out of the Configuration object.

Once I got ahold of that infromation, it all made sense!

#336647
Feb 11, 2025 12:57
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.