Skip to main content

Azure Table Storage - Putting It All Together


Back - Azure > Azure Storage

The Requirement
Assuming that we already completed the 1.1 Create/Add Azure Table Storage Entity and 1.2 Get All Entities In Azure Table, We are now ready to refactor our simple CRUD operation in a single .dll file that we may reference in our Middle Tier ( Web Api ).

Consideration
This code base is proposed for the intention for understanding its usage, for production/release we might need to tweak it to meet the company policy, best practice and industry standards.

Refactor The Account Setup
In the previous implementations, we saw some repeatable code that we may refactor, We start by refactoringg the CloudStorageAccount instantiation in a static class.In the proposed code below, we also introduce an overload for the SetupAccount method , this will allow the reference library open for dynamic variables that may be used in the Middle tier ( in this case, Asp.Net Web API ).
Refactor The Add Operation Helper
In our code below only 2 methods that are accessible to the clients who referenced this .dll, The AppOperation method access modifier is decorated with internal which protect it from being used by other assemblies.We also decorated the Add.New method with overload for dynamic configuration at the client side.

Refactor The Get Operation Helper
Same as the Add Operation refactoring, we create an internal protected operation with 2 public method that is open to clients.

Consuming in WebAPI
We then may reference the library in our Web Api solution by calling it like below.
Conclusion
From the article we may conclude that we may place all the related CRUD operations in a data access layer and reference it in our WebApi for consumption.

Back - Azure > Azure Storage

Published on : 7-May-2018
Ref no : DDN-WPUB-000015

About Author

My photo
Wan Mohd Adzha MCPD,MCSD,MCSE
I am passionate about technology and of course love Durians. Certified by Microsoft as MCP Since 2011. Blogging from Malaysia

Comments