Skip to main content

Posts

Showing posts with the label Dependency Injection

Implementing Dependency Injection In Azure Functions

This article talks about how we can use dependency injection in Azure Functions. Dependency injection is a very well known design pattern that is used to implement IoC as provides you a facility to segregate object creation logic from its usage.  Prerequisites And Tools Used In order to implement dependency injection in Azure Function App, you need an active Azure subscription, Visual Studio (I’m using Visual Studio 2019), and working knowledge of the C# language.  Create Function App in Visual Studio The first step is to create a new project in Visual Studio of type Azure Functions: and select Http Trigger as shown below:  Add Classes For Dependency Injection Next, we need to add the service (classes) which we want to inject. For simplicity, we will create an interface and a class implementing that interface. This interface will have only one method named GetCurrentTime() and it will provide current time to the caller. Here are the definitions: public interface ICurrent...