pnp / pnpframework

PnP Framework is a .NET library targeting Microsoft 365 containing the PnP Provisioning engine and a ton of other useful extensions
https://pnp.github.io/pnpframework/
MIT License
204 stars 141 forks source link

PnP.Framework ApplyProvisioningTemplate sometimes fails #616

Open mejohnm opened 2 years ago

mejohnm commented 2 years ago

We are having a strange problem which sometimes fails when applying a large template in C# code in an Azure Function App. The error is at the Site Header.

2022-03-03T15:48:49.543 [Information] ProvisioningAllNewJobs: 09/12 - Site Header 2022-03-03T15:49:08.536 [Error] Fehler in ProvisioningAllNewJobsSystem.Net.Http.HttpRequestException : An error occurred while sending the request. ---> System.IO.IOException : Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.. ---> System.Net.Sockets.SocketException : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.End of inner exceptionat System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error,CancellationToken cancellationToken)at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)at async System.Net.Security.SslStream.g__InternalFillBufferAsync|215_0TReadAdapterat System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async System.Net.Security.SslStream.ReadAsyncInternal[TReadAdapter](TReadAdapter adapter,Memory1 buffer)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request,CancellationToken cancellationToken)End of inner exceptionat async System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request,CancellationToken cancellationToken)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection,HttpRequestMessage request,Boolean doRequestAuth,CancellationToken cancellationToken)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request,Boolean doRequestAuth,CancellationToken cancellationToken)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async PnP.Framework.Http.RetryHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask,HttpRequestMessage request,CancellationTokenSource cts,Boolean disposeCts)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async PnP.Framework.Utilities.RESTUtilities.ExecutePostAsync(Web web,String endpoint,String payload,String cultureLanguageName)at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at PnP.Framework.Provisioning.ObjectHandlers.ObjectSiteHeaderSettings.ProvisionObjects(Web web,ProvisioningTemplate template,TokenParser parser,ProvisioningTemplateApplyingInformation applyingInformation)at PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyRemoteTemplate(Web web,ProvisioningTemplate template,ProvisioningTemplateApplyingInformation provisioningInfo,Boolean calledFromHierarchy,TokenParser tokenParser)at RCS.SharePoint.SharepointRepo.ApplyTemplate(String SiteUrl,ProvisioningTemplate template,ProvisioningTemplateApplyingInformation information) at E:\DBA\AzureApp\RCS.SharePoint\SharepointRepo.cs : 391at RCS.Provisioning.Repos.ProvisioningRepo.AssignTemplate(String ConcatenatedSitecollectionUri,ProvisioningParameters parameters) at E:\DBA\AzureApp\RCS.Provisioning\Repos\ProvisioningRepo.cs : 540at RCS.Provisioning.Repos.ProvisioningRepo.Provisioning(ProvisioningParameters parameters) at E:\DBA\AzureApp\RCS.Provisioning\Repos\ProvisioningRepo.cs : 135oningRepo.cs : 540at RCS.Provisioning.Repos.ProvisioningRepo.Provisioning(ProvisioningParameters parameters) at E:\DBA\AzureApp\RCS.Provisioning\Repos\ProvisioningRepo.cs : 135

Could this be happening because the template is too large? Again, it only happens sometimes.

patrikhellgren commented 2 years ago

@mejohnm What version of PnP.Framework are you using? I would say that you are probably not using version 1.8.0 or later since there was additional retry handling for SocketExceptions implemented in #528 and 1.8.0 is the first release containing that (not counting nightly releases). This has nothing to do with the size of the template but with a larger template the number of calls increase and thereby also the risk for SocketExceptions. See pnp/pnpcore#650 for more discussions regarding these issues.

mejohnm commented 2 years ago

@patrikhellgren Version 1.6.0

patrikhellgren commented 2 years ago

@mejohnm Great, so if you upgrade to version 1.8.0 you will see the issue go away.

mejohnm commented 2 years ago

@patrikhellgren Have done so. I will give it a few days of testing and then write back here. Thank you for the quick reply. This is my first Azure function app and it was a huge project. So I truly appreciate the help.

LockTar commented 5 months ago

I think this should be closed by now???