Dynamics CRM--> Azure Blob Storage--> 40 MB file upload gives Timeout Error. Custom Plugin on...
In Dynamics CRM Online, We have Custom Solution build which stores Large file as block-blobs on Azure Blob Storage.
When I try to upload File of 40 MB I get Timeout Error. Error Log below.
What I have read is that
Uploading a block blob that is no more than 256 MB (64 MB for
requests using REST versions before 2016-05-31) can be a single write
operation using Put Blob. However, uploading a larger blob requires
some more effort. Break it down in blocks of max 4 or 100MB depending
on the REST API version that you use.
Edit: I did some more brainstorming with some Trail and Error. What I found out is that from CRM using (c#) Plugin I could easily send File upto 80 MB and this is good amount. Anyhow CRM has restriction of file size upto 128MB.
With regard to my particular problem, i also found out that main issue is caused by HTML Page, which is used as Drag and Drop for adding File to CRM and then in turn to Azure Blob.
Summary: RESTAPI for Azure is not the problem, it more lies on Dynamics CRM Side. We have to respect Timeout with efficient way to extracting Bytes from File and uploading it to Azure.
As mentioned above 256 MB file should not break it down but still I get Timeout.
Here is the method I believe is causing the Issue.
public HttpWebRequest CreateRESTRequest(string method, string resource, byte requestBody, SortedList<string, string> headers = null,
string ifMatch = "", string md5 = "")
{
DateTime now = DateTime.UtcNow;
string uri = Endpoint + resource;
HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest;
request.Method = method;
request.ContentLength = 0;
request.Headers.Add("x-ms-date", now.ToString("R", System.Globalization.CultureInfo.InvariantCulture));
request.Headers.Add("x-ms-version", "2017-04-17");
if (IsTableStorage)
{
request.ContentType = "application/atom+xml";
request.Headers.Add("DataServiceVersion", "1.0;NetFx");
request.Headers.Add("MaxDataServiceVersion", "1.0;NetFx");
}
if (headers != null)
{
foreach (KeyValuePair<string, string> header in headers)
{
// This control requires that we set the ContentType through its property.
if (header.Key.Equals("Content-Type", StringComparison.InvariantCultureIgnoreCase))
{
request.ContentType = header.Value;
}
else
{
request.Headers.Add(header.Key, header.Value);
}
}
}
if (requestBody?.Length > 0)
{
request.Headers.Add("Accept-Charset", "UTF-8");
request.ContentLength = requestBody.Length;
}
request.Headers.Add("Authorization", AuthorizationHeader(method, now, request, ifMatch, md5));
if (requestBody?.Length > 0)
{
request.GetRequestStream().Write(requestBody, 0, requestBody.Length);
request.GetRequestStream().Close();
}
return request;
}
Uploading Test File.pptx failed Reason: "The plug-in execution failed because no Sandbox Hosts are currently available. Please check that you have a Sandbox server configured and that it is running.rnSystem.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:03:30'. ---> System.IO.IOException: The write operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:03:30'. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machinern at System.Net.Sockets.Socket.Send(Byte buffer, Int32 offset, Int32 size, SocketFlags socketFlags)rn at System.ServiceModel.Channels.SocketConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn --- End of inner exception stack trace ---rn at System.ServiceModel.Channels.SocketConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager bufferManager)rn at System.ServiceModel.Channels.BufferedConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.ConnectionStream.Write(Byte buffer, Int32 offset, Int32 count)rn at System.Net.Security.NegotiateStream.StartWriting(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn at System.Net.Security.NegotiateStream.ProcessWrite(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn --- End of inner exception stack trace ---rn at System.Net.Security.NegotiateStream.ProcessWrite(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn at System.Net.Security.NegotiateStream.Write(Byte buffer, Int32 offset, Int32 count)rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn --- End of inner exception stack trace ---rnrnServer stack trace: rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)rn at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSendCore(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.TransportDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)rn at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object ins, Object outs, TimeSpan timeout)rn at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)rn at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)rnrnException rethrown at [0]: rn at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)rn at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)rn at Microsoft.Crm.Sandbox.ISandboxHost.ExecuteAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, String assemblyContents, Boolean returnTraceInfo)rn at Microsoft.Crm.Sandbox.SandboxPlugin.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo)rn at Microsoft.Crm.Sandbox.SandboxCodeUnit.ExecuteInternal(SandboxClient client, IExecutionContext context, SandboxTraceContext sandboxTraceContext, SandboxCallTracker callTracker, Guid parentExecutionId, String assemblyContents, Boolean& isSafeToRetry, Boolean& executeDone)rn at Microsoft.Crm.Sandbox.SandboxCodeUnit.<>c__DisplayClass24_0.<Execute>b__0(): Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #D2641555"
c# azure-storage-blobs dynamics-crm-online azure-blob-storage
add a comment |
In Dynamics CRM Online, We have Custom Solution build which stores Large file as block-blobs on Azure Blob Storage.
When I try to upload File of 40 MB I get Timeout Error. Error Log below.
What I have read is that
Uploading a block blob that is no more than 256 MB (64 MB for
requests using REST versions before 2016-05-31) can be a single write
operation using Put Blob. However, uploading a larger blob requires
some more effort. Break it down in blocks of max 4 or 100MB depending
on the REST API version that you use.
Edit: I did some more brainstorming with some Trail and Error. What I found out is that from CRM using (c#) Plugin I could easily send File upto 80 MB and this is good amount. Anyhow CRM has restriction of file size upto 128MB.
With regard to my particular problem, i also found out that main issue is caused by HTML Page, which is used as Drag and Drop for adding File to CRM and then in turn to Azure Blob.
Summary: RESTAPI for Azure is not the problem, it more lies on Dynamics CRM Side. We have to respect Timeout with efficient way to extracting Bytes from File and uploading it to Azure.
As mentioned above 256 MB file should not break it down but still I get Timeout.
Here is the method I believe is causing the Issue.
public HttpWebRequest CreateRESTRequest(string method, string resource, byte requestBody, SortedList<string, string> headers = null,
string ifMatch = "", string md5 = "")
{
DateTime now = DateTime.UtcNow;
string uri = Endpoint + resource;
HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest;
request.Method = method;
request.ContentLength = 0;
request.Headers.Add("x-ms-date", now.ToString("R", System.Globalization.CultureInfo.InvariantCulture));
request.Headers.Add("x-ms-version", "2017-04-17");
if (IsTableStorage)
{
request.ContentType = "application/atom+xml";
request.Headers.Add("DataServiceVersion", "1.0;NetFx");
request.Headers.Add("MaxDataServiceVersion", "1.0;NetFx");
}
if (headers != null)
{
foreach (KeyValuePair<string, string> header in headers)
{
// This control requires that we set the ContentType through its property.
if (header.Key.Equals("Content-Type", StringComparison.InvariantCultureIgnoreCase))
{
request.ContentType = header.Value;
}
else
{
request.Headers.Add(header.Key, header.Value);
}
}
}
if (requestBody?.Length > 0)
{
request.Headers.Add("Accept-Charset", "UTF-8");
request.ContentLength = requestBody.Length;
}
request.Headers.Add("Authorization", AuthorizationHeader(method, now, request, ifMatch, md5));
if (requestBody?.Length > 0)
{
request.GetRequestStream().Write(requestBody, 0, requestBody.Length);
request.GetRequestStream().Close();
}
return request;
}
Uploading Test File.pptx failed Reason: "The plug-in execution failed because no Sandbox Hosts are currently available. Please check that you have a Sandbox server configured and that it is running.rnSystem.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:03:30'. ---> System.IO.IOException: The write operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:03:30'. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machinern at System.Net.Sockets.Socket.Send(Byte buffer, Int32 offset, Int32 size, SocketFlags socketFlags)rn at System.ServiceModel.Channels.SocketConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn --- End of inner exception stack trace ---rn at System.ServiceModel.Channels.SocketConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager bufferManager)rn at System.ServiceModel.Channels.BufferedConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.ConnectionStream.Write(Byte buffer, Int32 offset, Int32 count)rn at System.Net.Security.NegotiateStream.StartWriting(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn at System.Net.Security.NegotiateStream.ProcessWrite(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn --- End of inner exception stack trace ---rn at System.Net.Security.NegotiateStream.ProcessWrite(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn at System.Net.Security.NegotiateStream.Write(Byte buffer, Int32 offset, Int32 count)rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn --- End of inner exception stack trace ---rnrnServer stack trace: rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)rn at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSendCore(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.TransportDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)rn at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object ins, Object outs, TimeSpan timeout)rn at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)rn at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)rnrnException rethrown at [0]: rn at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)rn at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)rn at Microsoft.Crm.Sandbox.ISandboxHost.ExecuteAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, String assemblyContents, Boolean returnTraceInfo)rn at Microsoft.Crm.Sandbox.SandboxPlugin.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo)rn at Microsoft.Crm.Sandbox.SandboxCodeUnit.ExecuteInternal(SandboxClient client, IExecutionContext context, SandboxTraceContext sandboxTraceContext, SandboxCallTracker callTracker, Guid parentExecutionId, String assemblyContents, Boolean& isSafeToRetry, Boolean& executeDone)rn at Microsoft.Crm.Sandbox.SandboxCodeUnit.<>c__DisplayClass24_0.<Execute>b__0(): Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #D2641555"
c# azure-storage-blobs dynamics-crm-online azure-blob-storage
It does not make sens that a 40MB file take a while to upload... Have you tried using the .NET blob storage SDK or using Microsoft or Logic app ? Flow and Logic App have built-in connectors to D365 and Blob storage
– Thomas
Nov 23 at 4:44
Using :NET blob storage SDK is seamless and easy way, as the methods from SDK does most of the work of creating chunks and uploading and combining. But I am using Plugin (c#) code from Dynamics CRM and if i use External dll I need to Merge them and then I loose the functionality of Debugging, hence RESTAPI is the way.
– AnkUser
Dec 18 at 10:51
1
My D365 colleagues uses to offload this kind of work to azure functions.
– Thomas
Dec 18 at 20:04
@Thomas absolutely agreed. This is a perfect use-case for Azure Functions!
– Josh Painter
Dec 18 at 22:54
add a comment |
In Dynamics CRM Online, We have Custom Solution build which stores Large file as block-blobs on Azure Blob Storage.
When I try to upload File of 40 MB I get Timeout Error. Error Log below.
What I have read is that
Uploading a block blob that is no more than 256 MB (64 MB for
requests using REST versions before 2016-05-31) can be a single write
operation using Put Blob. However, uploading a larger blob requires
some more effort. Break it down in blocks of max 4 or 100MB depending
on the REST API version that you use.
Edit: I did some more brainstorming with some Trail and Error. What I found out is that from CRM using (c#) Plugin I could easily send File upto 80 MB and this is good amount. Anyhow CRM has restriction of file size upto 128MB.
With regard to my particular problem, i also found out that main issue is caused by HTML Page, which is used as Drag and Drop for adding File to CRM and then in turn to Azure Blob.
Summary: RESTAPI for Azure is not the problem, it more lies on Dynamics CRM Side. We have to respect Timeout with efficient way to extracting Bytes from File and uploading it to Azure.
As mentioned above 256 MB file should not break it down but still I get Timeout.
Here is the method I believe is causing the Issue.
public HttpWebRequest CreateRESTRequest(string method, string resource, byte requestBody, SortedList<string, string> headers = null,
string ifMatch = "", string md5 = "")
{
DateTime now = DateTime.UtcNow;
string uri = Endpoint + resource;
HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest;
request.Method = method;
request.ContentLength = 0;
request.Headers.Add("x-ms-date", now.ToString("R", System.Globalization.CultureInfo.InvariantCulture));
request.Headers.Add("x-ms-version", "2017-04-17");
if (IsTableStorage)
{
request.ContentType = "application/atom+xml";
request.Headers.Add("DataServiceVersion", "1.0;NetFx");
request.Headers.Add("MaxDataServiceVersion", "1.0;NetFx");
}
if (headers != null)
{
foreach (KeyValuePair<string, string> header in headers)
{
// This control requires that we set the ContentType through its property.
if (header.Key.Equals("Content-Type", StringComparison.InvariantCultureIgnoreCase))
{
request.ContentType = header.Value;
}
else
{
request.Headers.Add(header.Key, header.Value);
}
}
}
if (requestBody?.Length > 0)
{
request.Headers.Add("Accept-Charset", "UTF-8");
request.ContentLength = requestBody.Length;
}
request.Headers.Add("Authorization", AuthorizationHeader(method, now, request, ifMatch, md5));
if (requestBody?.Length > 0)
{
request.GetRequestStream().Write(requestBody, 0, requestBody.Length);
request.GetRequestStream().Close();
}
return request;
}
Uploading Test File.pptx failed Reason: "The plug-in execution failed because no Sandbox Hosts are currently available. Please check that you have a Sandbox server configured and that it is running.rnSystem.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:03:30'. ---> System.IO.IOException: The write operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:03:30'. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machinern at System.Net.Sockets.Socket.Send(Byte buffer, Int32 offset, Int32 size, SocketFlags socketFlags)rn at System.ServiceModel.Channels.SocketConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn --- End of inner exception stack trace ---rn at System.ServiceModel.Channels.SocketConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager bufferManager)rn at System.ServiceModel.Channels.BufferedConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.ConnectionStream.Write(Byte buffer, Int32 offset, Int32 count)rn at System.Net.Security.NegotiateStream.StartWriting(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn at System.Net.Security.NegotiateStream.ProcessWrite(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn --- End of inner exception stack trace ---rn at System.Net.Security.NegotiateStream.ProcessWrite(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn at System.Net.Security.NegotiateStream.Write(Byte buffer, Int32 offset, Int32 count)rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn --- End of inner exception stack trace ---rnrnServer stack trace: rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)rn at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSendCore(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.TransportDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)rn at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object ins, Object outs, TimeSpan timeout)rn at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)rn at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)rnrnException rethrown at [0]: rn at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)rn at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)rn at Microsoft.Crm.Sandbox.ISandboxHost.ExecuteAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, String assemblyContents, Boolean returnTraceInfo)rn at Microsoft.Crm.Sandbox.SandboxPlugin.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo)rn at Microsoft.Crm.Sandbox.SandboxCodeUnit.ExecuteInternal(SandboxClient client, IExecutionContext context, SandboxTraceContext sandboxTraceContext, SandboxCallTracker callTracker, Guid parentExecutionId, String assemblyContents, Boolean& isSafeToRetry, Boolean& executeDone)rn at Microsoft.Crm.Sandbox.SandboxCodeUnit.<>c__DisplayClass24_0.<Execute>b__0(): Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #D2641555"
c# azure-storage-blobs dynamics-crm-online azure-blob-storage
In Dynamics CRM Online, We have Custom Solution build which stores Large file as block-blobs on Azure Blob Storage.
When I try to upload File of 40 MB I get Timeout Error. Error Log below.
What I have read is that
Uploading a block blob that is no more than 256 MB (64 MB for
requests using REST versions before 2016-05-31) can be a single write
operation using Put Blob. However, uploading a larger blob requires
some more effort. Break it down in blocks of max 4 or 100MB depending
on the REST API version that you use.
Edit: I did some more brainstorming with some Trail and Error. What I found out is that from CRM using (c#) Plugin I could easily send File upto 80 MB and this is good amount. Anyhow CRM has restriction of file size upto 128MB.
With regard to my particular problem, i also found out that main issue is caused by HTML Page, which is used as Drag and Drop for adding File to CRM and then in turn to Azure Blob.
Summary: RESTAPI for Azure is not the problem, it more lies on Dynamics CRM Side. We have to respect Timeout with efficient way to extracting Bytes from File and uploading it to Azure.
As mentioned above 256 MB file should not break it down but still I get Timeout.
Here is the method I believe is causing the Issue.
public HttpWebRequest CreateRESTRequest(string method, string resource, byte requestBody, SortedList<string, string> headers = null,
string ifMatch = "", string md5 = "")
{
DateTime now = DateTime.UtcNow;
string uri = Endpoint + resource;
HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest;
request.Method = method;
request.ContentLength = 0;
request.Headers.Add("x-ms-date", now.ToString("R", System.Globalization.CultureInfo.InvariantCulture));
request.Headers.Add("x-ms-version", "2017-04-17");
if (IsTableStorage)
{
request.ContentType = "application/atom+xml";
request.Headers.Add("DataServiceVersion", "1.0;NetFx");
request.Headers.Add("MaxDataServiceVersion", "1.0;NetFx");
}
if (headers != null)
{
foreach (KeyValuePair<string, string> header in headers)
{
// This control requires that we set the ContentType through its property.
if (header.Key.Equals("Content-Type", StringComparison.InvariantCultureIgnoreCase))
{
request.ContentType = header.Value;
}
else
{
request.Headers.Add(header.Key, header.Value);
}
}
}
if (requestBody?.Length > 0)
{
request.Headers.Add("Accept-Charset", "UTF-8");
request.ContentLength = requestBody.Length;
}
request.Headers.Add("Authorization", AuthorizationHeader(method, now, request, ifMatch, md5));
if (requestBody?.Length > 0)
{
request.GetRequestStream().Write(requestBody, 0, requestBody.Length);
request.GetRequestStream().Close();
}
return request;
}
Uploading Test File.pptx failed Reason: "The plug-in execution failed because no Sandbox Hosts are currently available. Please check that you have a Sandbox server configured and that it is running.rnSystem.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:03:30'. ---> System.IO.IOException: The write operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:03:30'. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machinern at System.Net.Sockets.Socket.Send(Byte buffer, Int32 offset, Int32 size, SocketFlags socketFlags)rn at System.ServiceModel.Channels.SocketConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn --- End of inner exception stack trace ---rn at System.ServiceModel.Channels.SocketConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager bufferManager)rn at System.ServiceModel.Channels.BufferedConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.ConnectionStream.Write(Byte buffer, Int32 offset, Int32 count)rn at System.Net.Security.NegotiateStream.StartWriting(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn at System.Net.Security.NegotiateStream.ProcessWrite(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn --- End of inner exception stack trace ---rn at System.Net.Security.NegotiateStream.ProcessWrite(Byte buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)rn at System.Net.Security.NegotiateStream.Write(Byte buffer, Int32 offset, Int32 count)rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn --- End of inner exception stack trace ---rnrnServer stack trace: rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)rn at System.ServiceModel.Channels.StreamConnection.Write(Byte buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)rn at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSendCore(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.TransportDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)rn at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)rn at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object ins, Object outs, TimeSpan timeout)rn at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)rn at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)rnrnException rethrown at [0]: rn at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)rn at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)rn at Microsoft.Crm.Sandbox.ISandboxHost.ExecuteAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, String assemblyContents, Boolean returnTraceInfo)rn at Microsoft.Crm.Sandbox.SandboxPlugin.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo)rn at Microsoft.Crm.Sandbox.SandboxCodeUnit.ExecuteInternal(SandboxClient client, IExecutionContext context, SandboxTraceContext sandboxTraceContext, SandboxCallTracker callTracker, Guid parentExecutionId, String assemblyContents, Boolean& isSafeToRetry, Boolean& executeDone)rn at Microsoft.Crm.Sandbox.SandboxCodeUnit.<>c__DisplayClass24_0.<Execute>b__0(): Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #D2641555"
c# azure-storage-blobs dynamics-crm-online azure-blob-storage
c# azure-storage-blobs dynamics-crm-online azure-blob-storage
edited Dec 18 at 10:56
asked Nov 22 at 12:11
AnkUser
1299
1299
It does not make sens that a 40MB file take a while to upload... Have you tried using the .NET blob storage SDK or using Microsoft or Logic app ? Flow and Logic App have built-in connectors to D365 and Blob storage
– Thomas
Nov 23 at 4:44
Using :NET blob storage SDK is seamless and easy way, as the methods from SDK does most of the work of creating chunks and uploading and combining. But I am using Plugin (c#) code from Dynamics CRM and if i use External dll I need to Merge them and then I loose the functionality of Debugging, hence RESTAPI is the way.
– AnkUser
Dec 18 at 10:51
1
My D365 colleagues uses to offload this kind of work to azure functions.
– Thomas
Dec 18 at 20:04
@Thomas absolutely agreed. This is a perfect use-case for Azure Functions!
– Josh Painter
Dec 18 at 22:54
add a comment |
It does not make sens that a 40MB file take a while to upload... Have you tried using the .NET blob storage SDK or using Microsoft or Logic app ? Flow and Logic App have built-in connectors to D365 and Blob storage
– Thomas
Nov 23 at 4:44
Using :NET blob storage SDK is seamless and easy way, as the methods from SDK does most of the work of creating chunks and uploading and combining. But I am using Plugin (c#) code from Dynamics CRM and if i use External dll I need to Merge them and then I loose the functionality of Debugging, hence RESTAPI is the way.
– AnkUser
Dec 18 at 10:51
1
My D365 colleagues uses to offload this kind of work to azure functions.
– Thomas
Dec 18 at 20:04
@Thomas absolutely agreed. This is a perfect use-case for Azure Functions!
– Josh Painter
Dec 18 at 22:54
It does not make sens that a 40MB file take a while to upload... Have you tried using the .NET blob storage SDK or using Microsoft or Logic app ? Flow and Logic App have built-in connectors to D365 and Blob storage
– Thomas
Nov 23 at 4:44
It does not make sens that a 40MB file take a while to upload... Have you tried using the .NET blob storage SDK or using Microsoft or Logic app ? Flow and Logic App have built-in connectors to D365 and Blob storage
– Thomas
Nov 23 at 4:44
Using :NET blob storage SDK is seamless and easy way, as the methods from SDK does most of the work of creating chunks and uploading and combining. But I am using Plugin (c#) code from Dynamics CRM and if i use External dll I need to Merge them and then I loose the functionality of Debugging, hence RESTAPI is the way.
– AnkUser
Dec 18 at 10:51
Using :NET blob storage SDK is seamless and easy way, as the methods from SDK does most of the work of creating chunks and uploading and combining. But I am using Plugin (c#) code from Dynamics CRM and if i use External dll I need to Merge them and then I loose the functionality of Debugging, hence RESTAPI is the way.
– AnkUser
Dec 18 at 10:51
1
1
My D365 colleagues uses to offload this kind of work to azure functions.
– Thomas
Dec 18 at 20:04
My D365 colleagues uses to offload this kind of work to azure functions.
– Thomas
Dec 18 at 20:04
@Thomas absolutely agreed. This is a perfect use-case for Azure Functions!
– Josh Painter
Dec 18 at 22:54
@Thomas absolutely agreed. This is a perfect use-case for Azure Functions!
– Josh Painter
Dec 18 at 22:54
add a comment |
1 Answer
1
active
oldest
votes
The maximum time that a plug-in may run in Dynamics 365 is 3 minutes. If your plug-in might take longer than that, it is recommended that your plug-in trigger a queue or reach out to some external service that will run the code without a timeout.
- Your plug-in fires and passes a record id to an external service or queue.
- Your external code fires and reads the record from Dynamics and uploads the file to Azure.
This way the plug-in will execute quickly.
I have edited my question Description. It is more of a efficient way of extracting Bytes from Document.
– AnkUser
Dec 18 at 10:57
This will be the most efficient method. I know it is convenient to put this code inside the plugin itself, but the problem is that long-running code of any kind should not be put in async plugins or custom workflow activities. If the code takes more than a few seconds to execute, you run the risk of backing up system jobs in the async service. Even though the async service is multi-threaded, if all the threads are running long tasks, then your other workflows have to wait. Don't make the async service work hard - have it offload the hard work to external processes.
– Josh Painter
Dec 18 at 22:53
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53430756%2fdynamics-crm-azure-blob-storage-40-mb-file-upload-gives-timeout-error-cus%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The maximum time that a plug-in may run in Dynamics 365 is 3 minutes. If your plug-in might take longer than that, it is recommended that your plug-in trigger a queue or reach out to some external service that will run the code without a timeout.
- Your plug-in fires and passes a record id to an external service or queue.
- Your external code fires and reads the record from Dynamics and uploads the file to Azure.
This way the plug-in will execute quickly.
I have edited my question Description. It is more of a efficient way of extracting Bytes from Document.
– AnkUser
Dec 18 at 10:57
This will be the most efficient method. I know it is convenient to put this code inside the plugin itself, but the problem is that long-running code of any kind should not be put in async plugins or custom workflow activities. If the code takes more than a few seconds to execute, you run the risk of backing up system jobs in the async service. Even though the async service is multi-threaded, if all the threads are running long tasks, then your other workflows have to wait. Don't make the async service work hard - have it offload the hard work to external processes.
– Josh Painter
Dec 18 at 22:53
add a comment |
The maximum time that a plug-in may run in Dynamics 365 is 3 minutes. If your plug-in might take longer than that, it is recommended that your plug-in trigger a queue or reach out to some external service that will run the code without a timeout.
- Your plug-in fires and passes a record id to an external service or queue.
- Your external code fires and reads the record from Dynamics and uploads the file to Azure.
This way the plug-in will execute quickly.
I have edited my question Description. It is more of a efficient way of extracting Bytes from Document.
– AnkUser
Dec 18 at 10:57
This will be the most efficient method. I know it is convenient to put this code inside the plugin itself, but the problem is that long-running code of any kind should not be put in async plugins or custom workflow activities. If the code takes more than a few seconds to execute, you run the risk of backing up system jobs in the async service. Even though the async service is multi-threaded, if all the threads are running long tasks, then your other workflows have to wait. Don't make the async service work hard - have it offload the hard work to external processes.
– Josh Painter
Dec 18 at 22:53
add a comment |
The maximum time that a plug-in may run in Dynamics 365 is 3 minutes. If your plug-in might take longer than that, it is recommended that your plug-in trigger a queue or reach out to some external service that will run the code without a timeout.
- Your plug-in fires and passes a record id to an external service or queue.
- Your external code fires and reads the record from Dynamics and uploads the file to Azure.
This way the plug-in will execute quickly.
The maximum time that a plug-in may run in Dynamics 365 is 3 minutes. If your plug-in might take longer than that, it is recommended that your plug-in trigger a queue or reach out to some external service that will run the code without a timeout.
- Your plug-in fires and passes a record id to an external service or queue.
- Your external code fires and reads the record from Dynamics and uploads the file to Azure.
This way the plug-in will execute quickly.
answered Nov 22 at 17:05
Josh Painter
3,6861523
3,6861523
I have edited my question Description. It is more of a efficient way of extracting Bytes from Document.
– AnkUser
Dec 18 at 10:57
This will be the most efficient method. I know it is convenient to put this code inside the plugin itself, but the problem is that long-running code of any kind should not be put in async plugins or custom workflow activities. If the code takes more than a few seconds to execute, you run the risk of backing up system jobs in the async service. Even though the async service is multi-threaded, if all the threads are running long tasks, then your other workflows have to wait. Don't make the async service work hard - have it offload the hard work to external processes.
– Josh Painter
Dec 18 at 22:53
add a comment |
I have edited my question Description. It is more of a efficient way of extracting Bytes from Document.
– AnkUser
Dec 18 at 10:57
This will be the most efficient method. I know it is convenient to put this code inside the plugin itself, but the problem is that long-running code of any kind should not be put in async plugins or custom workflow activities. If the code takes more than a few seconds to execute, you run the risk of backing up system jobs in the async service. Even though the async service is multi-threaded, if all the threads are running long tasks, then your other workflows have to wait. Don't make the async service work hard - have it offload the hard work to external processes.
– Josh Painter
Dec 18 at 22:53
I have edited my question Description. It is more of a efficient way of extracting Bytes from Document.
– AnkUser
Dec 18 at 10:57
I have edited my question Description. It is more of a efficient way of extracting Bytes from Document.
– AnkUser
Dec 18 at 10:57
This will be the most efficient method. I know it is convenient to put this code inside the plugin itself, but the problem is that long-running code of any kind should not be put in async plugins or custom workflow activities. If the code takes more than a few seconds to execute, you run the risk of backing up system jobs in the async service. Even though the async service is multi-threaded, if all the threads are running long tasks, then your other workflows have to wait. Don't make the async service work hard - have it offload the hard work to external processes.
– Josh Painter
Dec 18 at 22:53
This will be the most efficient method. I know it is convenient to put this code inside the plugin itself, but the problem is that long-running code of any kind should not be put in async plugins or custom workflow activities. If the code takes more than a few seconds to execute, you run the risk of backing up system jobs in the async service. Even though the async service is multi-threaded, if all the threads are running long tasks, then your other workflows have to wait. Don't make the async service work hard - have it offload the hard work to external processes.
– Josh Painter
Dec 18 at 22:53
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53430756%2fdynamics-crm-azure-blob-storage-40-mb-file-upload-gives-timeout-error-cus%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It does not make sens that a 40MB file take a while to upload... Have you tried using the .NET blob storage SDK or using Microsoft or Logic app ? Flow and Logic App have built-in connectors to D365 and Blob storage
– Thomas
Nov 23 at 4:44
Using :NET blob storage SDK is seamless and easy way, as the methods from SDK does most of the work of creating chunks and uploading and combining. But I am using Plugin (c#) code from Dynamics CRM and if i use External dll I need to Merge them and then I loose the functionality of Debugging, hence RESTAPI is the way.
– AnkUser
Dec 18 at 10:51
1
My D365 colleagues uses to offload this kind of work to azure functions.
– Thomas
Dec 18 at 20:04
@Thomas absolutely agreed. This is a perfect use-case for Azure Functions!
– Josh Painter
Dec 18 at 22:54