With the recent release of Dynamics 365 (v9), it is now possible to have Virtual Entities.  These are entities that are not stored in the CRM database, but rather get their data from an OData API.  This allows you to, for example, use on-premises data in Dynamics 365 without having to directly integrate it.

First, we must setup a new Virtual Entity Data Source.  To do this, go to Settings > Administration > Virtual Entity Data Source.  Create a new one and set your URL.


With the Data Source configured, we can now create the Virtual Entity.  Create a solution (or use an existing one), and add a new Entity.  Note that there is now a Virtual Entity checkbox that you can check.  You must also choose the Data Source that was configured in the previous step.


After you Save the entity, there will be two fields created: ID and Name.  Before you can use the entity, you must configure the External Name of each of these fields.


Once you are done with this, Save and Publish the entity.  You can now navigate to the entity and it will fetch the data directly from the OData API we provided!


If you followed my previous blog post, you will notice that these are the two sample products we hardcoded into the API.  This is a pretty exciting new feature that opens up a lot of possibilities!

Azure-aware plugins can be used to run custom business logic on-premises and have the responses returned to Dynamics 365. This allows you to access internal integrate Dynamics 365 with your internal line-of-business applications. For example, you can save an Order in CRM, have custom logic that creates the order in your on-premises ERP (Dynamics GP, NAV, AX, etc.) and returns the order number to CRM in real-time. We'll walk through that example below.

First, we will create the plugin that will send the information to the Azure Service Bus.  This is using my base Plugin class (which maybe I'll write about someday).

We can use the Plugin Registration tool to register this plugin on any message/entity we want.  First though, we must create a Service Endpoint.  To do this, copy the connection string for your Azure Service Bus.  Since we are creating a two-way plugin, set the Designation Type to TwoWay.  Also, you must change the protocol from sb to https.


After you register the Service Endpoint, go to the properties and copy the ServiceEndpointId.


With this, we can now register the plugin. Create a new step for create of salesorder. In the unsecure configuration, but the endpoint ID you copied above.

Next, we will create an endpoint plugin which will run some action and return a string to the plugin.

Next, we need to create an Azure WCF Relay which listens for messages to be posted to the Azure Service Bus and executes the endpoint plugin.  This code could be run from either a console application or a Windows Service.

In order for the ServiceHost to know where to connect, we must put this in the App.config:

All we need to do now is run the WCF Relay and create an order in CRM. We should see the Order ID get set once the order is saved!: