Use a clean fluent API to create functions with all the boilerplate taken care of and runtime support for authorization and dependency injection.
public class FunctionAppConfiguration : IFunctionAppConfiguration
{
public void Build(IFunctionHostBuilder builder)
{
builder
.Setup((serviceCollection, commandRegistry) =>
{
serviceCollection
.AddLogging()
.AddNotificationServices(commandRegistry)
.AddExpensesService(commandRegistry)
.AddInvoiceServices(commandRegistry);
})
.Authorization(authorization => authorization.TokenValidator())
.AddFluentValidation()
.Functions(functions => functions
.HttpRoute("v1/Invoice", route => route
.HttpFunction(AuthorizationTypeEnum.TokenValidation, HttpMethod.Get)
)
.ServiceBus("serviceBusConnection", serviceBus => serviceBus
.SubscriptionFunction("emaildispatchtopic", "emaildispatchsubscription"))
.Storage("storageConnectionString", storage => storage
.BlobFunction("expenses/{name}"))
);
}
}
Eliminate the tedious repetitive boilerplate leading to less code, fewer defects, improved consistency, better separation of concerns and more flexibility.
Take advantage of the mediator pattern and underlying mediation framework to keep your codebase clean, super-DRY, and loosely coupled.