SharePoint Online issues creating site collections via PnP code again...

%3CLINGO-SUB%20id%3D%22lingo-sub-22887%22%20slang%3D%22en-US%22%3ESharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-22887%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20seeing%20issues%20when%20creating%20new%20sites%20via%20the%20PnP%20Core%20extension%20method%20AddSiteCollection.%20We%20are%20seeing%20this%20on%20several%20customer%26nbsp%3Btenants.%3C%2FP%3E%3CP%3ECan%20someone%20confirm%20that%20this%20is%20once%20again%20a%20SPO%20issue%20or%20has%20something%20changed%20in%20the%20PnP%20code%20that%20I%20am%20not%20aware%20of%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20issue%20does%20not%20occure%20all%20the%20time.%20It%20only%20fails%20about%2050%25%20of%20the%20times...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EMicrosoft.SharePoint.Client.ServerException%3A%20Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object%3C%2FSTRONG%3E.%20at%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream%20responseStream)%20at%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()%20at%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder%20sb)%20at%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()%20at%20Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()%20at%20Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()%20at%20Microsoft.SharePoint.Client.TenantExtensions.%3CSTRONG%3EGetSiteGuidByUrl%3C%2FSTRONG%3E(Tenant%20tenant%2C%20Uri%20siteFullUrl)%20at%20Microsoft.SharePoint.Client.TenantExtensions.%3CSTRONG%3EAddSiteCollection%3C%2FSTRONG%3E...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-22887%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-388524%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-388524%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F996%22%20target%3D%22_blank%22%3E%40Oliver%20Zeiser%3C%2FA%3E%3C%2FP%3E%3CP%3EAnother%20way%20to%20do%20it%20is%20to%20create%20and%20use%20a%20Web%20Service%20that%20is%20using%20SharePoint%20Powershell%20to%20create%20a%20site%20collection.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20using%20it%20with%20multiple%20site%20collections%20created%20on%20the%20same%20time%20without%20any%20problem.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-376621%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-376621%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F37647%22%20target%3D%22_blank%22%3E%40Venkata%20Ratnam%20Vemula%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%203%20days%2C%20it%20started%20working%20fine%20again%20without%20us%20doing%20any%20fix.%20Hope%2C%20Microsoft%20has%20fixed%20something%20on%20its%20end.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-Venkat.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-369445%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-369445%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EAll%20of%20a%20sudden%2C%20the%20same%20issue%20started%20again%20after%2020%2B%20months.%20Its%20failing%20all%20the%20time.%20Is%20there%20any%20workaround%20or%20solution%20available%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EError%3A%3C%2FP%3E%3CP%3EMicrosoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream%20responseStream)%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder%20sb)%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext%20clientContext%2C%20Int32%20retryCount%2C%20Int32%20delay)%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext%20clientContext%2C%20Int32%20retryCount%2C%20Int32%20delay)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-69155%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-69155%22%20slang%3D%22en-US%22%3E%3CP%3EOccassionally%2C%20it%20is%20failing%20with%20the%20following%20error%3A%3C%2FP%3E%3CP%3EIs%20there%20a%20permanent%20fix%20for%20this%20issue%3F%3C%2FP%3E%3CPRE%3E%5BError%5D%20%20%20%20at%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream%20responseStream)%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder%20sb)%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext%20clientContext%2C%20Int32%20retryCount%2C%20Int32%20delay)%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext%20clientContext%2C%20Int32%20retryCount%2C%20Int32%20delay)%0A%20%20%20at%20Provisioning.Infrastructure.Jobs.Handlers.SiteCollectionProvisioningJobHandler.CreateSiteCollection(SiteCollectionProvisioningJob%20job)%200ms%20%0A2017-05-10%2021%3A03%3A20.9868%20%5BOfficeDevPnP.Core%5D%20%5B0%5D%20%5BDebug%5D%20AuthenticationManager%3AEnsureToken(siteUrl%3Ahttps%3A%2F%2Fabc.com%2Finfrastructure-Prod%2Crealm%3Af9914f5c-6fc2-4043-9c04-6ccec0b819f5%2CappId%3Ab7f97e11-3746-4392-b871-e3f0dc5fd615%2CappSecret%3APRIVATE)%200ms%20%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47652%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47652%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20PnP%20Core%201702%20release%20in%20two%20different%20production%20tenants.%20The%20problem%20seems%20to%20be%20solved%20after%20the%20PnP%20core%20update%20in%20one%20tenant%20but%20persists%20in%20the%20other%20tenant.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20digging%20into%20it%20I%20found%20a%20solution%20for%20my%20case%20as%20I%20am%20using%20PnP%20Partner%20Pack%20(1702%20release).%20The%20SiteCollectionProvisioningJobHandler%20accesses%20the%20same%20Tenant%20instance%20after%20the%20site%20collection%20was%20created%20and%20fails%20with%20the%20exception%3A%20%22Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object.%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInstead%20of%20using%20the%20same%20instance%20(as%20Vesa%20mentioned)%2C%20I%20create%20a%20new%20ClientContext%20and%20with%20that%20a%20new%20Tenant%20instance%20and%20provisioning%20works%20fine.%20I%20will%20create%20a%20pull%20request%20in%20the%20PnP%20Partner%20Pack%20repo%20with%20the%20work-around%20described.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EUpdate%20(28-02-2017)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20found%20this%20to%20still%20fail%20occasionally.%20Also%2C%20when%20using%20a%20retry%20pattern%20with%20e.g.%2010%20retries%20and%2010%20seconds%20in%20between%2C%20it%20still%20fails.%20Best%20options%20seems%20currently%20to%20avoid%20working%20with%20the%20tenant%20object%20after%20creating%20a%20site%20collection.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-45613%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45613%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20Oliver.%20I%20have%20upgraded%20to%20latest%20PnP%20version%20and%20used%20the%20timeout%20function%20in%20CreateSiteCollection%20method%2C%20after%20which%20it%20started%20working%20fine.%20I%20am%20sharing%20the%20logic%20here%20hoping%20it%20will%20help%20someone.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Etenant.CreateSiteCollection(newSite%2C%20true%2C%20true%2C%20timeoutFunction%3A%20(operationMessage)%20%3D%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(operationMessage%20%3D%3D%20TenantOperationMessage.CreatingSiteCollection)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2FLog%20a%20message%20saying%20Site%20collection%20is%20still%20in%20%20progress%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20false%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-44823%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-44823%22%20slang%3D%22en-US%22%3EThis%20is%20very%20specific%20to%20our%20solution%2C%20so%20i%20can't%20simply%20share%20the%20code.%20But%20the%20best%20Workaround%20right%20now%20would%20be%20to%20upgrade%20to%20the%20latest%20PnP%20Nuget%20Package.%20If%20you%20do%20this%2C%20it%20will%20just%20work%2C%20unless%20you%20need%20the%20site%20ID%20for%20some%20reason.%3CBR%20%2F%3EThe%20problem%20is%20related%20to%20getting%20the%20site%20ID%20from%20the%20tenant%20object.%20Within%20the%20latest%20PnP%20core%20there%20is%20a%20try%20catch%20and%20it%20will%20return%20a%20Guid.Empty%20in%20case%20this%20error%20occures.%20If%20you%20don't%20care%20about%20the%20site%20id%2C%20everything%20is%20fine.%20Otherwise%20you%20would%20continue%20from%20there%20and%20get%20the%20site%20guid%20yourself.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-44815%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-44815%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Oliver%2C%3C%2FP%3E%3CP%3ECould%20you%20please%20share%20the%20workaround%20logic%20(Source%20code)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-42602%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-42602%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20there%20a%20workaround%20of%20fix%20for%20this%20issue%3FIts%20failing%2050%25.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-41849%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-41849%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F37647%22%20target%3D%22_blank%22%3E%40Venkata%20Ratnam%20Vemula%3C%2FA%3E%3CBR%20%2F%3EI%20got%20back%20the%20error%20after%20a%20few%20tries...%20Made%20ammendment%20to%20my%20previous%20post%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-41557%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-41557%22%20slang%3D%22en-US%22%3E%3CP%3EFrom%20which%20version%20did%20you%20update%3F%20What%20is%20the%20latest%20version%20you%20have%20updated%3F%3C%2FP%3E%3CP%3ECurrently%2C%20I%20am%20using%20v2.6.1608%20in%20which%20I%20am%20having%20the%20following%20issue.%20Do%20we%20need%20to%20take%20care%20of%20anything%20while%20updating%20to%20new%20PnP%20version%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%5BError%5D%20%20%20%20at%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream%20responseStream)%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder%20sb)%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext%20clientContext%2C%20Int32%20retryCount%2C%20Int32%20delay)%20in%20C%3A%5CCode%5Cpnp-sites-core-Aug%5CCore%5COfficeDevPnP.Core%5CAppModelExtensions%5CClientContextExtensions.cs%3Aline%2080%0A%20%20%20at%20Microsoft.SharePoint.Client.TenantExtensions.GetSiteGuidByUrl(Tenant%20tenant%2C%20Uri%20siteFullUrl)%20in%20C%3A%5CCode%5Cpnp-sites-core-Aug%5CCore%5COfficeDevPnP.Core%5CAppModelExtensions%5CTenantExtensions.cs%3Aline%20372%0A%20%20%20at%20Microsoft.SharePoint.Client.TenantExtensions.CreateSiteCollection(Tenant%20tenant%2C%20SiteEntity%20properties%2C%20Boolean%20removeFromRecycleBin%2C%20Boolean%20wait%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-41395%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-41395%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20helped%20me%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EIf%20you%20use%20PnP%20extensions%20to%20create%20site%20collections%20-%20Update%20to%20latest%20PnP%20NuGet%20package%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3EUpdate%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EIt%20seems%20after%20a%20few%20tries%20i%20still%20get%20this%20error%20after%20updating%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-41357%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-41357%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20gettting%20this%20error%20as%20well%20and%20all%20i%20am%20doing%20is%20seting%20the%20properies%20for%20the%20new%20site%20collection%20and%20using%20this%20code%20to%20attempt%20the%20creation.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Etenant.CreateSiteCollection(newSite%2C%20true%2C%20true)%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20do%20notice%20the%20site%20collection%20is%20created%20but%20it%20errors%20out%20at%20that%20specific%20line%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-40783%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-40783%22%20slang%3D%22en-US%22%3E%3CP%3EMaybe%20slightly%20off-topic%3A%20What%20is%20the%20best%20premier%20support%20offer%20to%20get%20support%20for%20code%20related%20things%20in%20SPO%3F%20There%20are%20several%20offers%20(%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fmicrosoftservices%2Fsupport.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fmicrosoftservices%2Fsupport.aspx%3C%2FA%3E)%20but%20none%20of%20them%20mentions%20SharePoint%20Online%20for%20developers.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-40728%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-40728%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20info%20Vesa.%20Customer%20has%20already%20opened%20a%20support%20case%20on%20this.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-40612%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-40612%22%20slang%3D%22en-US%22%3E%3CP%3ELike%20mentioned%20by%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9762%22%20target%3D%22_blank%22%3ES%C3%BCleyman%20Ayazalp%3C%2FA%3E%2C%20we%20did%20add%20workaround%20for%20this%20issue.%20Issue%20is%20in%20the%20oob%20CSOMs%20and%20it's%20being%20addressed%2C%20but%20we%20don't%20yet%20have%20exact%20date%20to%20get%20this%20solved.%20You%20can%20run%20into%20these%20issues%20if%20you%20provision%20site%20collection%20using%20app-only%20access%20and%20then%20try%20to%20access%20that%20site%20collection%20with%20Tenant%20object.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFix%20is%20work%20in%20progress%2C%20but%20workarounds%20are%20also%20available%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIf%20you%20use%20PnP%20extensions%20to%20create%20site%20collections%20-%20Update%20to%20latest%20PnP%20NuGet%20package%3C%2FLI%3E%0A%3CLI%3EIf%20you%20use%20native%20CSOM%20APIs%2C%20remove%20any%20code%20accessing%20newly%20created%20site%20collection%20with%20Tenant%20object%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20running%20into%20this%20issue%20and%20have%20opportunity%20to%20open%20officialy%20Premier%20Support%20case%20with%20Microsoft%2C%20that%20would%20be%20also%20appreciated.%20This%20is%20mainly%20for%20the%20sake%20of%20getting%20more%20details%20on%20the%20scale%20of%20the%20issue%20and%20who%20are%20suffering%20on%20that.%20We%20are%20working%20on%20a%20fix%2C%20but%20priorities%20are%20being%20always%20set%20by%20metrics%20based%20on%20officially%20reported%20issues.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-40361%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-40361%22%20slang%3D%22en-US%22%3E%3CP%3EI%20was%20just%20checking%20the%20PnP%20code%20for%20sitecollection%20creation%20(we%20are%20using%20the%20CreateSiteCollection%20tenant%20extension%20method%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Sites-Core%2Fblob%2Fmaster%2FCore%2FOfficeDevPnP.Core%2FAppModelExtensions%2FTenantExtensions.cs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Sites-Core%2Fblob%2Fmaster%2FCore%2FOfficeDevPnP.Core%2FAppModelExtensions%2FTenantExtensions.cs%3C%2FA%3E)%20and%20there%20seems%20to%20be%20a%20wait%20function%20to%20wait%20for%20the%20creation%20of%20the%20site%20collection%20but%20more%20interestingly%20there%20is%20also%20this%20comment%20which%20could%20explain%20the%20error%20you%20are%20receiving%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2F%2F%20Eat%20all%20exceptions%20cause%20there's%20currently%20(December%2016)%20an%20issue%20in%20the%20service%20that%20can%20make%20this%20call%20fail%20in%20combination%20with%20app-only%20usage%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-40118%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-40118%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20also%20seeing%20this%20issue.%20It's%20extremely%20frustrating%20as%20we%20are%20trying%20to%20deliver%20a%20robust%20provisioning%20solution%20to%20our%20customers%20but%20are%20impeded%20by%20this%20seemingly%20inconsistent%20issue.%20Most%20sites%20go%20through%20end-to-end%20no%20problem%2C%20but%20every%20now%20and%20then%20a%20site%20will%20bomb%20out.%20The%20site%20collection%20will%20still%20get%20created%20but%20the%20provisioning%20code%20will%20bomb%20out%20with%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%22Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object%22%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Eat%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3Etenant.CreateSiteCollection(newSite%2C%20true%2C%20true)%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20attempting%20to%20wrap%20this%20in%20some%20retry%20logic%20but%20we%20really%20shouldn't%20have%20to.%26nbsp%3B%3CEM%3EPlease%3C%2FEM%3E%20fix%20this%20Microsoft.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-40117%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-40117%22%20slang%3D%22en-US%22%3E%3CP%3ESame%20issue.%20Sporadic%20error%2C%20hard%20to%20repeat%2C%20too.%20Noticed%20it%20happening%20when%20the%20tenant%20load%2Fusage%20is%20higher.%20%26nbsp%3BWent%20and%20implemented%20the%20workaround%20with%20the%20loop.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-39581%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-39581%22%20slang%3D%22en-US%22%3E%3CP%3EWer%20are%20also%20still%26nbsp%3Bseeing%20this%20on%20many%20tenants.%20MS%20doesn't%20seem%20to%20care%20though.%20I%20guess%20they%20are%20busy%20figuring%20out%20new%20ways%20on%20how%20to%20prevent%20or%20break%26nbsp%3Bcustomizations%20%3B)%3C%2Fimg%3E%3C%2FP%3E%3CP%3EJust%20build%20your%20own%20retry%20logic.%20You%20will%20be%20better%20off%20trying%20to%20fix%20it%20yourself%20than%20hoping%20for%20MS%20to%20fix%20it.%20Since%20it%20is%20related%20to%20code%2C%20support%20tickets%26nbsp%3Bwon't%20help%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-39506%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-39506%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20experiencing%20the%20same%20behaviour%20in%20at%20least%20three%20tenants%20(haven't%20tested%20more%20at%20this%20point).%20I'm%20not%20using%20PnP%20extension%20methods%20for%20creation.%20The%20issue%20seems%20to%20come%20more%20often%20when%20creating%20multiple%20site%20collections%20in%20a%20row%2C%20using%20Azure%20continuous%20webjob.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-24942%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-24942%22%20slang%3D%22en-US%22%3E%3CP%3ESo%20here%20is%20a%20quick%20update%3A%20The%20issue%20still%20persists%20on%20many%20tenants%2C%20so%20let%20me%20provide%20some%20more%20info%20on%20this%20issue.%3C%2FP%3E%3CP%3EThe%20problem%20is%2C%20that%20the%20SpoOperation%20returns%20IsComplete%20even%20if%20the%20site%20is%20not%20really%20provisioned.%20Even%20worse%2C%20when%20getting%20the%20site%20status%20via%20Tenant.GetSitePropertiesByUrl%20it%20will%20report%20%22Active%22%20although%20the%20real%20status%20is%20still%20%22Creating%22.%20This%20is%20why%20the%20PnP%20CreateSite%20method%20fails%20when%20trying%20to%20get%20the%20site%20guid%2C%20since%20this%20one%20still%20does%20not%20exist.%3C%2FP%3E%3CP%3EOnly%20workaround%20I%20have%20found%20so%20far%20is%20to%20wait%20in%20a%20back-off%20try-catch%26nbsp%3Bloop%20for%20the%20site%20to%20be%20really%20provisioned.%3C%2FP%3E%3CP%3EIts%20a%20big%20pain%20since%20this%20basic%20feature%20in%20SPO%20shoud%20just%20work....%2C%20but%20maybe%20this%20helps%20someone....%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-23329%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-23329%22%20slang%3D%22en-US%22%3E%3CP%3EYup%20that%20is%20the%20same%20issue.%20I%20am%20seeing%20this%20at%20more%20than%2015%20customers.%20But%20many%20others%20are%20just%20working%20fine.%20And%26nbsp%3BI%20have%20the%20same%20code%20running%20there.%20So%20I%20guess%20only%20a%20few%20tenants%2Fsharepoint%20online%20farms%26nbsp%3Bhave%20this%20issue.%3C%2FP%3E%3CP%3EIt%20is%20a%20big%20pain%20that%20the%20key%20feature%20of%20sharepoint%20online%2C%20creating%20sitecollections%2C%20is%20not%20working%20reliable.%20I%20am%20still%20not%20quite%20sure%20if%20the%20issue%20only%20shows%20up%20with%20PnP%20library%20or%20also%20using%20ootb%20csom%20methods.%20I%20guess%20i'll%20have%20to%20check%20that%20first%20before%20opening%20one%20more%20support%20case....%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-23319%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-23319%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20facing%20the%20same%20issue.%20In%20my%20case%2C%20I%20am%20using%20Azure%20webjob%20to%20create%20the%20site.%20This%20error%20happens%20before%20applying%20the%20template.%3C%2FP%3E%3CP%3EHere%20is%20the%20stack%20trace%3A%3C%2FP%3E%3CP%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream%20responseStream)%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder%20sb)%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext%20clientContext%2C%20Int32%20retryCount%2C%20Int32%20delay)%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.TenantExtensions.GetSiteGuidByUrl(Tenant%20tenant%2C%20Uri%20siteFullUrl)%3CBR%20%2F%3Eat%20Microsoft.SharePoint.Client.TenantExtensions.CreateSiteCollection(Tenant%20tenant%2C%20SiteEntity%20properties%2C%20Boolean%20removeFromRecycleBin%2C%20Boolean%20wait)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-23061%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-23061%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20your%20response.%3C%2FP%3E%3CP%3EI%20am%20not%20using%20the%26nbsp%3Bprovisioning%20engine%2C%20just%20a%20simple%20csom%20call%20to%20create%20a%20blank%20team%20site.%20There%20are%20no%20other%20requests%20to%20this%20site%20during%20this%20time.%3C%2FP%3E%3CP%3EFor%20me%20this%20is%20clearly%20a%20bug%20in%20SPO%20or%20something%20changed%20and%20the%20PnP%20extension%20needs%20an%20update.%20But%20since%20there%20are%20probably%20many%20others%2C%20using%20this%20PnP%20extension%2C%20i%20was%20wondering%20if%20other%20people%20have%20also%26nbsp%3Bseen%20this%20and%20maybe%20opend%20support%20cases%20already%20and%20can%20provide%20some%20more%20information%20on%20this%20topic.%3C%2FP%3E%3CP%3ESo%20the%20way%20I%20understand%20this%2C%20there%20is%20nothing%20I%20can%20do%20about%20it%20from%20my%20code%20perspective.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-23052%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20issues%20creating%20site%20collections%20via%20PnP%20code%20again...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-23052%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F996%22%20target%3D%22_blank%22%3E%40Oliver%20Zeiser%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EIn%20general%20you%20get%20these%20error%20messages%20when%20multiple%20things%20update%20the%20same%20object.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20typically%20you%20could%20get%20this%20error%20when%20you%20create%20a%20site%20collection%20and%20while%20the%20site%20collection%20is%20being%20created%20it%20is%20also%20updated%20by%20another%20process.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20for%20example%20if%20you%20apply%20templates%20to%20a%20site%20twice%20at%20the%20same%20time.%20The%20context%20of%20the%20command%20giving%20the%20error%20is%20then%20not%20up%20to%20date%20any%20more%20as%20the%20context%20isn't%20updated%20with%20updates%20made%20by%20the%20other%20process.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20past%20I%20found%20this%20error%20when%20we%20had%20mutliple%20developers%20runninng%20powershell%20commands%20applying%20PnP%20templates%20to%20the%20same%20site.%20We%20then%20had%20to%20reconnect%20to%20the%20site%20to%20bring%20the%20context%20into%20sync.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20slightly%20less%20obvious%20variations%20of%20the%20same%20problem%20occur%20if%20your%20tmeplate%20include%20multiple%20copies%20of%20the%20same%20object%20(list%2C%20column%2C%20contenttype).%20So%20during%20a%20single%20application%20of%20a%20template%20an%20object%20is%20updated%20twice.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20easiest%20way%20to%20debug%20the%20issue%20I%20found%20is%20either%20with%20PowerShell%20apply%20a%20template%20after%20having%20enabled%20debug%20(Set-SPOTraceLog)%20or%20to%20step%20through%20the%20code%20and%20enable%20debug%20on%20the%20PnP.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHopefully%20the%20following%20two%20artciles%20will%20help%20you%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fveenstra.me.uk%2F2016%2F10%2F11%2Foffice-365-how-do-debug-pnp-powershell-commands%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fveenstra.me.uk%2F2016%2F10%2F11%2Foffice-365-how-do-debug-pnp-powershell-commands%2F%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fveenstra.me.uk%2F2016%2F07%2F29%2Foffice-365-sharepoint-how-to-debug-pnp-provisioning-engine%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fveenstra.me.uk%2F2016%2F07%2F29%2Foffice-365-sharepoint-how-to-debug-pnp-provisioning-engine%2F%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

We are seeing issues when creating new sites via the PnP Core extension method AddSiteCollection. We are seeing this on several customer tenants.

Can someone confirm that this is once again a SPO issue or has something changed in the PnP code that I am not aware of?

 

The issue does not occure all the time. It only fails about 50% of the times...

 

Microsoft.SharePoint.Client.ServerException: Operation is not valid due to the current state of the object. 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.TenantExtensions.GetSiteGuidByUrl(Tenant tenant, Uri siteFullUrl) at Microsoft.SharePoint.Client.TenantExtensions.AddSiteCollection...

26 Replies
Highlighted

@Oliver Zeiser,

In general you get these error messages when multiple things update the same object.

 

So typically you could get this error when you create a site collection and while the site collection is being created it is also updated by another process.

 

So for example if you apply templates to a site twice at the same time. The context of the command giving the error is then not up to date any more as the context isn't updated with updates made by the other process.

 

In the past I found this error when we had mutliple developers runninng powershell commands applying PnP templates to the same site. We then had to reconnect to the site to bring the context into sync.

 

The slightly less obvious variations of the same problem occur if your tmeplate include multiple copies of the same object (list, column, contenttype). So during a single application of a template an object is updated twice.

 

The easiest way to debug the issue I found is either with PowerShell apply a template after having enabled debug (Set-SPOTraceLog) or to step through the code and enable debug on the PnP.

 

Hopefully the following two artciles will help you:

 

https://veenstra.me.uk/2016/10/11/office-365-how-do-debug-pnp-powershell-commands/

 

https://veenstra.me.uk/2016/07/29/office-365-sharepoint-how-to-debug-pnp-provisioning-engine/

 

Highlighted

Thank you for your response.

I am not using the provisioning engine, just a simple csom call to create a blank team site. There are no other requests to this site during this time.

For me this is clearly a bug in SPO or something changed and the PnP extension needs an update. But since there are probably many others, using this PnP extension, i was wondering if other people have also seen this and maybe opend support cases already and can provide some more information on this topic.

So the way I understand this, there is nothing I can do about it from my code perspective.

Highlighted

I am facing the same issue. In my case, I am using Azure webjob to create the site. This error happens before applying the template.

Here is the stack trace:

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.TenantExtensions.GetSiteGuidByUrl(Tenant tenant, Uri siteFullUrl)
at Microsoft.SharePoint.Client.TenantExtensions.CreateSiteCollection(Tenant tenant, SiteEntity properties, Boolean removeFromRecycleBin, Boolean wait)

Highlighted

Yup that is the same issue. I am seeing this at more than 15 customers. But many others are just working fine. And I have the same code running there. So I guess only a few tenants/sharepoint online farms have this issue.

It is a big pain that the key feature of sharepoint online, creating sitecollections, is not working reliable. I am still not quite sure if the issue only shows up with PnP library or also using ootb csom methods. I guess i'll have to check that first before opening one more support case....

Highlighted

So here is a quick update: The issue still persists on many tenants, so let me provide some more info on this issue.

The problem is, that the SpoOperation returns IsComplete even if the site is not really provisioned. Even worse, when getting the site status via Tenant.GetSitePropertiesByUrl it will report "Active" although the real status is still "Creating". This is why the PnP CreateSite method fails when trying to get the site guid, since this one still does not exist.

Only workaround I have found so far is to wait in a back-off try-catch loop for the site to be really provisioned.

Its a big pain since this basic feature in SPO shoud just work...., but maybe this helps someone....

Highlighted

I'm experiencing the same behaviour in at least three tenants (haven't tested more at this point). I'm not using PnP extension methods for creation. The issue seems to come more often when creating multiple site collections in a row, using Azure continuous webjob.

Highlighted

Wer are also still seeing this on many tenants. MS doesn't seem to care though. I guess they are busy figuring out new ways on how to prevent or break customizations ;)

Just build your own retry logic. You will be better off trying to fix it yourself than hoping for MS to fix it. Since it is related to code, support tickets won't help you.

Highlighted

Same issue. Sporadic error, hard to repeat, too. Noticed it happening when the tenant load/usage is higher.  Went and implemented the workaround with the loop.

Highlighted

We are also seeing this issue. It's extremely frustrating as we are trying to deliver a robust provisioning solution to our customers but are impeded by this seemingly inconsistent issue. Most sites go through end-to-end no problem, but every now and then a site will bomb out. The site collection will still get created but the provisioning code will bomb out with:

 

"Operation is not valid due to the current state of the object"

at 

tenant.CreateSiteCollection(newSite, true, true);

 

We are attempting to wrap this in some retry logic but we really shouldn't have to. Please fix this Microsoft.

Highlighted

I was just checking the PnP code for sitecollection creation (we are using the CreateSiteCollection tenant extension method: https://github.com/SharePoint/PnP-Sites-Core/blob/master/Core/OfficeDevPnP.Core/AppModelExtensions/T...) and there seems to be a wait function to wait for the creation of the site collection but more interestingly there is also this comment which could explain the error you are receiving:

 

// Eat all exceptions cause there's currently (December 16) an issue in the service that can make this call fail in combination with app-only usage

 

 

Highlighted

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.

Highlighted

Thanks for the info Vesa. Customer has already opened a support case on this.

Highlighted

Maybe slightly off-topic: What is the best premier support offer to get support for code related things in SPO? There are several offers (https://www.microsoft.com/en-us/microsoftservices/support.aspx) but none of them mentions SharePoint Online for developers.

Highlighted

I am gettting this error as well and all i am doing is seting the properies for the new site collection and using this code to attempt the creation. 

 

tenant.CreateSiteCollection(newSite, true, true);

 

I do notice the site collection is created but it errors out at that specific line

Highlighted

This helped me

 

  • If you use PnP extensions to create site collections - Update to latest PnP NuGet package

Update

It seems after a few tries i still get this error after updating

 

Highlighted

From which version did you update? What is the latest version you have updated?

Currently, I am using v2.6.1608 in which I am having the following issue. Do we need to take care of anything while updating to new PnP version?

 

[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) in C:\Code\pnp-sites-core-Aug\Core\OfficeDevPnP.Core\AppModelExtensions\ClientContextExtensions.cs:line 80
   at Microsoft.SharePoint.Client.TenantExtensions.GetSiteGuidByUrl(Tenant tenant, Uri siteFullUrl) in C:\Code\pnp-sites-core-Aug\Core\OfficeDevPnP.Core\AppModelExtensions\TenantExtensions.cs:line 372
   at Microsoft.SharePoint.Client.TenantExtensions.CreateSiteCollection(Tenant tenant, SiteEntity properties, Boolean removeFromRecycleBin, Boolean wait

 

Highlighted
@Venkata Ratnam Vemula
I got back the error after a few tries... Made ammendment to my previous post
Highlighted

Is there a workaround of fix for this issue?Its failing 50%.

Highlighted

Hi Oliver,

Could you please share the workaround logic (Source code)