Using Autofac for Azure Table Storage with C# ASP.Net Core MVC 3.0
Azure Table Storage DI
Using Azure Table Storage is a very cost effective way to run a cloud hosted database in Microsoft Azure. The question is, how to we manage the DI.
Enter “Autofac”
We’ve of course all heard of Autofac, so I won’t explain the benefits of their framework.
Implementation Steps
- Create our data model.
- Create our CRUD repository and inject an Azure CloudTable into the constructor.
- Create our CRUD service layer and inject the repository into the constructor.
- Implement a module to configure Azure Table Storage using Autofac’s DI layer, in four steps -
- Create an Azure Storage Account:
- Configure our service layer and our Azure Cloud Table:
- Configure our repository to use our Azure Cloud Table:
- Configure Startup.cs file to use the Azure Table Storage Autofac module we’ve built.
- Configure Program.cs file to use Autofac.
- Utilise our CRUD service at the controller level in ASP.Net MVC Core 3.0.
- View our Azure Table Storage NoSQL database to verify our implementation.
Enjoy!