Requests to this API should contain at least 100 documents, where each document is not null or empty error while configuring Topic Analysis using Text Analytics in Dynamics 365

Hi,

Recently while trying to configure Topic Analysis in Dynamics 365

https://nishantrana.me/2017/03/24/configure-case-topic-analysis-using-cognitive-services-text-analytics-preview-in-dynamics-365-online/

we got the below error for the failed record.

Error Message:{“code”:”BadRequest”,”message”:”Invalid request”,”innerError”:{“code”:”InvalidRequestContent”,”message”:”Requests to this API should contain at least 100 documents, where each document is not null or empty”,”minimumNumberOfDocuments”:100}}

This was because we had very few case records in our CRM organization < 30. We created few more records to increase the count to be more then 100 and re run the build. This time it got succeeded.

Hope it helps..

Configure Case Topic Analysis using Cognitive Services Text Analytics (Preview) in Dynamics 365 (online)

Text Analytics Preview feature is currently available for instances in US region. Topic analysis can be used to automatically identify topics that occurs in cases.

To enable the preview, go to System Settings – Preview tab and select Yes for Text Analytics Preview.

Click OK to confirm.

Next go to Administration and click on Azure Machine Learning Text Analytics Service configuration to configure the service.

Here we would need the Azure service URL and the Azure Account Key to configure it.

To do so, go to Azure Portal

https://portal.azure.com

Search for Cognitive Service Accounts

Click on Add and Specify required information.

Select Text Analytics API as API Type.

Click on create to create the service account.

Copy the Endpoint of the created Cognitive service account which will be used as Azure Service URL in CRM.

Similarly select Keys, and copy one of the Key which will be used as Azure Service Key in CRM.

Specify the values in the Text Analytics Connection record.

Click on Test Connection to test the connection.

After successful test, click on Activate to activate the connection.

Next let us create a Topic Model which will be used to identify topics occurring in the cases.

Go to Service Management – Automatic Case Topics Analysis Settings

Create a new Topic model record

Create a related Topic Model Configuration record.

It auto populates the Topic Determination Fields which we can edit\add.

Specify the configuration record created in the Configuration lookup of Topic model record.

Click on Test to the configuration.

Build Execution History tab shows the status of the test run.

The build can be scheduled.

Once we have tested the configuration we can then activate the model.

Once Activated, we can them manually trigger the build using Build button

We can check the status of the build in the build execution history tab. Below record shows the build to be succeeded, duration it took i.e. 6 minutes, number of records it synchronized i.e. 159 and topics identified as 9.

To see it in action, go to Active Cases view and select Case Topics chart which lists the topics.

Hope it helps..

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.

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..

Scheduling a Web Job (console application) using Azure Scheduler

Let us a create a simple console application that writes Hello World to the console which we would be scheduling using Azure Scheduler.

Have kept the example simple so that we can understand the configuration part.

Right click on the project and Publish it as Azure WebJob

We will set the mode as “Run On Demand”

For the pubish target we have selected Microsoft Azure App Service web app under which this Web Job will run.

Select the App Service or configure a new one, we have selected the existing App Service below

Click on Validate to check the connection, if everything is fine Click Next and Publish the web role.

Our TriggeredWebJob inside CRMAzureWebJob App Service

We can run it on Demand by clicking on Run.

Clicking on Logs

Will provide the details of the Web Jobs

Now to schedule the Web Job we need to create a Scheduler Job, for this go to Scheduler Job Collections and click on Add

Create a new Job inside Job Collection and provide the required details like Name, Pricing Tier, Resource Group etc.

Next step is to configure the Action settings, wherein we will trigger our Web Job.

For this we need to define Action as Https, Method as Post and the URL

Format of the URL should be like –

https://{userName}:{password}@{WebAppName}.scm.azurewebsites.net/api/triggeredwebjobs/{WebJobName}/run

To get the above details open the Web Job properties


Replace the appropriate values

https://$CRMAzureWebJob:hyNboz8Skys3yrQ2MkpYnseXr7Kborq82JhEX09B32ExtjiYkxxgwejqsH@crmazurewebjob.scm.azurewebsites.net/api/triggeredwebjobs/TriggeredWebJob/run

Last step is to schedule it

Here we have selected it to run immediately, every 2 minutes for total of 10 occurrences.


Finally click on Create which will create the job


We can monitor our Job



Going back to our Web Job Logs we can see it ran 3 times with interval of 2 minutes till that point


The other option to schedule a Web Job without using Azure Scheduler is to use the Cron Job but this requires minimum Basic tier subscription. Basically, the Web App must be configured for “Always On”, which requires a Basic or Standard plan.

http://patrickdesjardins.com/blog/azure-webjobs-using-cronjobs

http://blog.amitapple.com/post/2015/06/scheduling-azure-webjobs/#.WNCQKDt9600

And in Free tier

https://www.schaeflein.net/azure-webjobs-free-tier/

Hope it helps..