Configure Dynamics 365 and Azure Service Bus Integration (using TwoWay relay, Azure Aware Plugin and listener)

Let us pick up from where we left in the previous post and implement two way relaying through which we can get the response back from the listener.

https://nishantrana.me/2017/03/22/configure-dynamics-365-and-azure-service-bus-integration-using-oneway-relay-and-listener/

First let us update the Service Endpoint Registration, change the designation type to TwoWay, it would also ask to enter the SAS Key. Copy it from Azure and paste it.

Update the listener windows application created in the previous post to implement ITwoWayServiceEndpointPlugin

Use the below code to create the custom azure aware plugin.

Get the service endpoint id from the Properties window of the Service End Point registered.

Register the assembly and add the Post Create Synchronous Lead Step to it.

As we are using trace service to log the response, set All for Enable logging to plugin-trace log option from Administration – System Setting – Customization.

Start the listener windows application and to trigger the plugin, create the lead record

We can see the execute method being called from Azure Service bus on create of Lead record.

The message being returned from listener application to the plugin.

The newly created lead record.

The trace message within the plugin –

Plugin Trace log with the response received from the listener –

Hope it helps..

Configure Dynamics 365 and Azure Service Bus Integration (using OneWay relay and listener)

Continuing our previous post

https://nishantrana.me/2017/03/22/configure-dynamics-365-and-azure-service-bus-integration-through-queue-and-queueclient/

Here we’d add a new Shared Access Policy in the Azure Service Bus.

We can copy the connection string

Paste it in Service Endpoint registration dialog box of Plugin Registration tool

Change the designation type to OneWay, use https for the namespace address.

Register a step for creation of lead

Now we go and create a lead record, which triggers our plugin and creates a system job for it.

The system job fails as we do not have any active listener at the end point.

Now let us create a simple windows application which will act as listener.

Basically, we need to implement IServiceEndPointPlugin Interface, create a Service Host, define a new transportclientendpointbehaviour with shared access signature token provider, use WS2007HttpRelayBinding in our service end point.

Now run the listener application, and create a lead record in CRM.

We can see the break point hit in our listener application’ Execute method. Execute method is invoked whenever a message is posted to the service bus by Microsoft Dynamics 365.

System Job also shows the status as succeeded as we had our listener registered to the endpoint and running.

The helpful post

http://www.crmviking.com/2016/10/microsoft-crm-azure-service-bus-part-3.html

https://blogs.msdn.microsoft.com/swetagu/2016/04/12/crm-azure-service-endpoint-and-listener-deep-dive/

http://iunknownme.com/blog/2015/05/27/dynamics-crm-integration-using-azure-service-bus-part-i-using-service-bus-relays/

Hope it helps.

Configure Dynamics 365 and Azure Service Bus Integration (through Queue and QueueClient)

Let us configure Dynamics 365 and Azure Service Bus integration.

Here we would implement a basic scenario, every time a lead is created in CRM we’d pass this execution context information to the queue. The app then reads and shows the information.

As a first step, we need to register a service end point through plugin registration tool.

Here we need to provide the connection string

So, let us create SAS configured Azure service bus namespace and a queue in it.

Go to portal

https://portal.azure.com

Search for Service Bus, provide the required details and click on Create.

Next, we’d create a queue. Inside Service Bus go to Queues and click on plus button create a Queue

Next inside the queue we need to go to Shared Access Policy settings and click on Add button to add a new SAS Key

Next click on connection strings, followed by Add button to add a new SAS Key.

This creates the key. Now copy the connection string.

Paste the connection string in the Plugin Registration tool

It will auto populate all the details. Now click on Save.

This adds a new service end point

Now register a new step – Entity – Lead and Message – Create.

Now to trigger it let us create a lead record in CRM.

A corresponding System Job will have the status.

Back in our queue we can see 1 new message added to it.

To read the message, let us create a simple windows application.

Install the WindowsAzure.ServiceBus package.

The source code for the queue. Here the connection string will be the same which we had specified in the plugin registration tool. The message body is of type RemoteExecutionContext.

The output.

Hope it helps..

Dynamics CRM, Web Job and Azure scheduler

Let us built upon our previous example where we created a Hello World console application, hosted it as web job in Azure App Service and then scheduled it using Azure Scheduler.

Scheduling a Web Job (console application) using Azure Scheduler

Here we will basically update the code in Console Application to use CRM’s assemblies.

Just for simplicity we’d create a lead record in our app and then schedule it to run every 2 minute for total of 5 occurrences.

In real world, obviously, we’d have different scenarios like checking for the status of records and send mail every 24 hour or so, or delete records periodically etc.

We have added the required CRM assemblies

The code to create lead record.

Publishing the updated code.

Running it.

Checking the logs.

Inside CRM it creates the lead record

Now let us re visit our Azure Job Scheduler, update the schedule to run 5 times with interval of 2 minutes.

Click on Run now to run the Job.

We can check the history of the Scheduler Job once it completes –

Logs of the Web Job –

5 Records created in CRM with interval of 2 minutes.

Hope it helps..

Configuring Data Export Service in Microsoft Dynamics 365

*Updated 19 Sep – 2018 : Check out this powerful tool DBSync’s CRM connector, which could be used for bi-directional seamless integration of all the popular Application and Database with Microsoft Dynamcis 365- https://www.mydbsync.com/product/microsoft-dynamics-365-crm-integration

Data Export Service is an add-on that allows replicating CRM Online Data to Azure SQL Database.

The below video by expert Scott Durow is the best resource to learn about it

https://www.youtube.com/watch?v=txms2Yvn6Vc

Below are the steps we need to follow to configure it.

  • Go to Settings – Dynamics Marketplace

  • Search for Dynamics 365 Export Service

  • Click on GET IT NOW

  • Click on Agree

  • This will install the Data Export Service solution

  • Back in CRM – Go to Settings – Data Export. (Pop up window will open up a page for Data Export Authentication, so we need to enable pop up)

  • Click on New to create a new Data Export File.

Basically, here we need the Key Vault URL here which stores the database connection string securely.

Clicking on the information icon opens up the dialog box with the below PowerShell script, which needs value for variables like subscription id, key vault name, secret name, tenant id etc.

i.e.

So as a first step here we need to configure Azure Active Directory (if Office 365 and Azure Tenant are separate)

https://docs.microsoft.com/en-us/azure/billing/billing-add-office-365-tenant-to-azure-subscription

  • Next step is to create Azure SQL database. Search for SQL databases in All Resources and click on Add

  • Specify the required information and click Create.

Next we need to create a User that will be used to configure Data Export Service and has appropriate rights in the database

Here the user has been assigned db owner role

 

For the minimum rights required check the below article

https://technet.microsoft.com/en-us/library/mt744592.aspx

Now let us replace the below placeholders one by one

  • Subscription ID
  • Key Vault Name – NishantDemoKeyVault
  • Secret Name – DataExport
  • Resource Group – DemoRG
  • Location – East US
  • Connection String

  • Organization ID List

KeyVault record created in Azure à

  • Going back to our Export Profile wizard, we need to paste the Key Vault URL

  • Click on Validate

  • Select the entity or entities for which profile needs to be created

  • Select any relationships 

  • Next click on Create and Activate

This creates the profile record in CRM

  • Once Initial Sync Status shows as completed we can see the tables created in the Azure Database.

The records synchronized –

Let us delete the below selected lead records –

Delete Log table will hold the information of the deleted lead records

To create export profile for a custom entity, (say for e.g. entity named Test in our case)

We need to enable Change Tracking in it.

Get all the details here

http://develop1.net/public/post/Dynamic365-Data-Export-Service.aspx

https://technet.microsoft.com/library/a70feedc-12b9-4a2d-baf0-f489cdcc177d

Hope this helps..

Create a simple logic app with Dynamics 365 connector

Let us create a simple logic app that on create of a contact record in CRM creates the same contact in Gmail.

Log in to the azure portal.

https://portal.azure.com/#create/hub

Select New Logic App

Specify Name, Resource Group and Location for the logic app.

Select Blank Logic App

Select “When a record is created” as Trigger.

Sign in to Dynamics 365 Instance.

Select the Organization name and Entity as Contact.

Select Add an action and the New Step

Choose Google Contacts as the Service

Sign in to your Gmail account to be connected

Allow permission to Logic App to access Gmail

Configure Full Name and Primary Email (Dynamic content) as the values for the contact record to be created in Gmail.

Save and Run the app.

Create the new contact record in CRM that triggers the logic app.

On Successful run à

We can see the contact record created in Gmail.

Find all the details here

https://docs.microsoft.com/en-us/azure/connectors/connectors-create-api-crmonline

Hope it helps..

Partner Field Service Portal in Dynamics 365.

Dynamics 365 comes with Partner Field Service portal which helps Partners manage work order, service request, assets, invoices, opportunities etc. from within the portal.

Go to Administrator Center, select Portal and click on Manage.

Select Manage Dynamics 365 Instance

Click on Update Dynamics 365 Instance

Select Partner as Audience and Partner Field Service as the portal to be deployed

Once installed this is how Partner Portal looks like

Below are the different menu options that comes OOB.

Partner Program

Opportunities

Customers

Field Service

Below are the Entity Forms associated to the Partner Portal Web site created in CRM.

Below are the Entity Lists associated to the Partner Portal Web site created in CRM.

Around 121 Entity Permission records are added by the Partner Portal

Web Roles specific to Partner Portal.

Below are some of the permission for the Partner Admin web role.

Once the portal is setup next step would be to Become a Partner. Click on Begin Here.

Update the profile and click on submit.

Within CRM, the admin user needs to run the Approve Partner Application workflow on the corresponding portal contact user record.

After workflow succeeds we can assign appropriate web roles to the portal contact user.

The portal user can create customer contacts record

The portal user can raise Service Requests from within the portal.

Can manage Work Orders.

Can manage Opportunities.

The portal has the Dashboard that shows the details around the opportunity and the cases.

Hope it helps..

Edit Primary Navigation in Portal in Dynamics 365

For updating the Navigation, login to the portal with the user having Administrator web role.

Hover over the Navigation and select Edit

This opens up the dialog box, here we can edit or insert a new navigation link. To add new navigation link click on “+”

We can either specify any existing page within portal or can point to any external URL and can also show up image + text or image only.

This adds the new navigation link

Similarly, we can add new child links or move a link as child link which then appears as drop down. Here we have moved the new Search Home link inside Support by dragging.

The updated navigation looks like below

Hope it helps..

Manage Dynamics 365 Portal Instance

Suppose we have Community Portal configured in our Dynamics 365 Instance.

Now we would like to have Custom Portal instead of Community Portal associated to our instance.

To configure this, we need go to Admin Centre à Select Portal and Click on Manage

Then select Manage Dynamic 365 CRM Instance and then Update Dynamics 365 Instance

From there we can select the Portal Audience and corresponding Portal to be deployed.

This will install the corresponding portal solution to our CRM Instance.

Now our portal URL will show up the Custom Portal instead of Community Portal.

To switch back to community portal, we can select Portal Details and Update Portal Binding to point it to website we want it to bind to.

Suppose we have Employee self-service portal deployed to our instance and we would like to update binding to it.

Below we select Employee self-service as the web site record and click on Update.

Once update is done, opening the Base Portal URL will open up Employee self-service portal instead of Custom Portal now.

Hope it helps..

Site Settings records specific to Registration in Portal (Dynamics 365)

In Portal, we have few Site Setting records that defines the registration behavior.

By default, if user clicks on Sign In page, we see the below options i.e. Sign In, Register and Redeem Invitation as well as Sign in with an external account.

If we want to disable Local Login then we can set the below Authentication/Registration/LocalLoginEnabled value as false.

This hides the Sign in with Local Account option.

For disabling the Registration option we can set the below site setting record as false.

This hides the Registration tabs from the sign in page

Setting both the above site settings as false, presents the user with the only option of using Azure AD for signing in to the portal.

Hope it helps..