How To Save Dataverse Capacity Cost by using Virtual Entities

Ever since Microsoft introduced the new Capacity modelย forย Dynamics 365, customers have been forced to rethink what to store, how to store, and where to store their data.ย 

While there are many ways to answer those questions, weย will stick with using Virtual Tables (entities).โ€ฏLetsย get started with virtual tables!

Virtual Tables:ย 

Virtual tables or entities provide usย an easy wayย to integrate data withย Dataverse withoutย storingย or consuming theย capacityย ofย Dataverse.ย 

Recently Microsoft enabled doing Create, Update and Delete operations as well in addition to theย Readย operation. This opens a lot of avenues in terms of usage and implementation.ย 

Limitations:ย 

For our case, we willย assumeย AdventureWorks sample database, and in this blog post, I willย show how easy it is to set up Customers as a Virtual Table (entity) inย Dataverse.ย 

As a first step, I haveย alreadyย provisionedย theย AdventureWorksย sample database in Azure. Next,ย we willย be implementing a Custom Virtual Table providerย that willย support operations.ย 

Read Operation:ย 

Let usย get our SQL query in shape first. We want to show the following columns inย Dataverse:ย 

  1. Customer Idย 
  2. Titleย 
  3. First Nameย 
  4. Last Nameย 
  5. Company Nameย 
  6. Emailย Addressย 
  7. Phoneย 

That willย look like this:ย 

SELECT [CustomerID]ย 

โ€ฏ โ€ฏ โ€ฏโ€ฏ,[Title]ย 

โ€ฏ โ€ฏ โ€ฏโ€ฏ,[FirstName]ย 

โ€ฏ โ€ฏ โ€ฏโ€ฏ,[LastName]ย 

โ€ฏ โ€ฏ โ€ฏโ€ฏ,[CompanyName]ย 

โ€ฏ โ€ฏ โ€ฏโ€ฏ,[EmailAddress]ย 

โ€ฏ โ€ฏ โ€ฏโ€ฏ,[Phone]ย 

โ€ฏ โ€ฏ โ€ฏโ€ฏ,[rowguid]ย 

โ€ฏโ€ฏFROM [SalesLT].[Customer]ย 

Plug-in Setup:ย 

Weย willย define our SQL connection helper class:ย 

This will be used to connect to our Azure SQL database. A better approach would be to utilize Environment Variables with a low privileged/read-only SQL account.ย 

Another approach would be to implement OData provider and return that data via an API call.ย 

Firstly, letย usย implement the retrieve plug-in:ย 

Finally, letย usย implement the retrieve multiple plug-in:

A couple of pointersย regardingย security, an OData API-based approach as the provider where the external system canย provideย permissions would be desirable. Azureย ADย can be used toย define roles against the application identity, and users can then be assigned those roles.ย 

Conclusion:ย 

And there you have it. With just a simple custom provider plug-in implementation, customers display inย Dataverseย without consuming any storage capacity. A similar approach can be utilized for other objects, especially those that are purely read-only objects.ย