Using Dependency Injection and IOptions in Azure Functions

Azure, Backend Development, C#, Development
So, I created this Azure Function and because I have a lot of parameters that I would like to be able to use in dependency injection I did not want to go with the familiar way like this: var firstName = Environment.GetEnvironmentVariable("FirstName"); Instead I want to use the Options pattern as I would do when creating a "normal" appsettings file. However, Azure Function configurations only feature key-value pairs for configuration and do not support JSON configuration files. Luckily there is a way around this using a little peculiar syntax. Writing the code First, we create our options class: public class ParentOptions { public string FirstName { get; set; } public string LastName { get; set; } public ChildOptions ChildOptions { get; set; } } public class ChildOptions { public string…
Read More