microsoft / PowerPlatform-DataverseServiceClient

Code Replica for Microsoft.PowerPlatform.Dataverse.Client and supporting nuget packages.
MIT License
281 stars 51 forks source link

ExecuteTransactionRequest from Azure Function [2022-12-08T13:08:25.341Z] Error: The request channel timed out attempting to send after 00:04:00 #343

Closed twiga2013 closed 1 year ago

twiga2013 commented 1 year ago

Hi I am using

  1. Azure Function 4.10
  2. .NET 6
  3. Microsoft.PowerPlatform.Dataverse.Client 1.0.9
  4. Microsoft Dynamics 365 2022 release wave 2 enabled

When using ExecuteTransactionRequest and have 2300 records in a transaction I am getting the following. Is there any limitation of how many records you can have in an ExecuteTransactionRequest?

[2022-12-08T13:08:25.341Z] Error: The request channel timed out attempting to send after 00:04:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

[2022-12-08T13:08:25.343Z] HelpLink Url: Not Provided [2022-12-08T13:08:25.344Z] Stack Trace: at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) [2022-12-08T13:08:25.345Z] at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) [2022-12-08T13:08:25.346Z] at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) [2022-12-08T13:08:25.347Z] at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.b__0(IAsyncResult asyncResult) [2022-12-08T13:08:25.348Z] --- End of stack trace from previous location --- [2022-12-08T13:08:25.349Z] at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient.Command_ExecuteAsyncImpl(OrganizationRequest req, String errorStringCheck, CancellationToken cancellationToken, Boolean bypassPluginExecution) [2022-12-08T13:08:25.350Z] ====================================================================================================================== [2022-12-08T13:08:25.355Z] Inner Exception Level 1 : [2022-12-08T13:08:25.356Z] Source: System.Private.ServiceModel [2022-12-08T13:08:25.357Z] Method: MoveNext [2022-12-08T13:08:25.357Z] DateUTC: 12/8/2022 [2022-12-08T13:08:25.358Z] TimeUTC: 1:08:25 PM

MattB-msft commented 1 year ago

There is not a {practical} limitation that most folks will hit. However, there is a limitation to the amount of time the network will keep the connection alive.

You can increase the timeout by setting the MaxConnectionTimeout property on the ServiceClient before you create the connection. But you should do that with caution.

Without understanding what your trying to do, I cannot really guide here aside from the general statement that if your doing data imports you should review this doc

twiga2013 commented 1 year ago

Hi @MattB-msft

Its a pretty straight forward use case. I have an existing parent record in dynamics where I am receiving data for its related tables from an external service.

  1. Table A related To Table B related To Table C related To Table D related To

Creating records in Table B, Table C and Table D in one transaction.

MattB-msft commented 1 year ago

Got it, if the relationship is Table A 1:N B 1:N C 1:N D , then I would suggest you actually create the hierarchy as a single operation. For example,
Use the pac modelbuilder build command to build the entity model for A, B, C, and D, which will also create the relationship references as part of the model.
Then populate the entity + its relationships, that is the EntityRelationship node on the entity object.

Then batch them in (execute multiple) in groups that ride under the 4 min threshold, using Multi-threading to expand the import horizontally.

Take some time to read though this article: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/api-limits#how-to-maximize-throughput