Forum Discussion
SharePoint Online issues creating site collections via PnP code again...
Like mentioned by Süleyman Ayazalp, we did add workaround for this issue. Issue is in the oob CSOMs and it's being addressed, but we don't yet have exact date to get this solved. You can run into these issues if you provision site collection using app-only access and then try to access that site collection with Tenant object.
Fix is work in progress, but workarounds are also available
- If you use PnP extensions to create site collections - Update to latest PnP NuGet package
- If you use native CSOM APIs, remove any code accessing newly created site collection with Tenant object
If you are running into this issue and have opportunity to open officialy Premier Support case with Microsoft, that would be also appreciated. This is mainly for the sake of getting more details on the scale of the issue and who are suffering on that. We are working on a fix, but priorities are being always set by metrics based on officially reported issues.
I am using PnP Core 1702 release in two different production tenants. The problem seems to be solved after the PnP core update in one tenant but persists in the other tenant.
After digging into it I found a solution for my case as I am using PnP Partner Pack (1702 release). The SiteCollectionProvisioningJobHandler accesses the same Tenant instance after the site collection was created and fails with the exception: "Operation is not valid due to the current state of the object."
Instead of using the same instance (as Vesa mentioned), I create a new ClientContext and with that a new Tenant instance and provisioning works fine. I will create a pull request in the PnP Partner Pack repo with the work-around described.
Update (28-02-2017)
I found this to still fail occasionally. Also, when using a retry pattern with e.g. 10 retries and 10 seconds in between, it still fails. Best options seems currently to avoid working with the tenant object after creating a site collection.
- Venkata Ratnam VemulaMay 11, 2017Brass Contributor
Occassionally, it is failing with the following error:
Is there a permanent fix for this issue?
[Error] at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery() at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery() at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery() at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay) at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay) at Provisioning.Infrastructure.Jobs.Handlers.SiteCollectionProvisioningJobHandler.CreateSiteCollection(SiteCollectionProvisioningJob job) 0ms 2017-05-10 21:03:20.9868 [OfficeDevPnP.Core] [0] [Debug] AuthenticationManager:EnsureToken(siteUrl:https://abc.com/infrastructure-Prod,realm:f9914f5c-6fc2-4043-9c04-6ccec0b819f5,appId:b7f97e11-3746-4392-b871-e3f0dc5fd615,appSecret:PRIVATE) 0ms
- Venkata Ratnam VemulaMar 14, 2019Brass Contributor
Hi,
All of a sudden, the same issue started again after 20+ months. Its failing all the time. Is there any workaround or solution available?
Error:
Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay)
at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay)- Venkata Ratnam VemulaMar 19, 2019Brass Contributor
After 3 days, it started working fine again without us doing any fix. Hope, Microsoft has fixed something on its end.
-Venkat.