How can you inject your service inside an Azure Function body? In other words, how you can leverage the power of dependency injection in your Azure Functions?
Fortunately, the Azure Functions SDK 1.0.28 (and later versions) has the same dependency injection support that you can use in ASP.NET Core.
To use this dependency injection in your Azure Function, you have to go through the following steps:
- Convert your Azure Function class from a static class to a normal class:
public class MortgageFunctions
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req,
[Table("executionsTable", Connection = "StorageAccount")] ICollector<ExecutionRow> outputTable,