Using JSON and User Secrets configuration with Azure Functions

Cesar Codes
Jul 7 · 1 min read

In my last post, I talked about how we can extend the FunctionsStartup class and override its Configure method to register services. In this post, I’ll share how to go about using User Secrets and JSON file configuration.

If you want to use User Secrets, you must first add the Microsoft.Extensions.Configuration.UserSecretspackage from NuGet. This should also add a GUID in your project file. At this point, you can utilize User Secrets through Visual Studio or the .NET Cli as you normally would. One thing to note is that the code sample below calls the AddUserSecrets() method. If you’re not going to use user secrets, skip this step and remove the call to the method (line 16).

For utilizing a JSON file, you want to go ahead and create the JSON file and the code sample below should work.

Happy Coding!

Cesar

Cesar Codes

Written by

I experiment with code and talk about it.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade