Office 365 – CSOM – Issue with clientContext.CreateSiteAsync(CommunicationSiteCollectionCreationInformation) – method exited without site collection creation and resolution :)

Hi All,

Today, new issue and solution :). This time issue is with CreateSiteAsync () method of ClientContext class and solution 🙂

Background: In one of our Office 365 / SharePoint Online project we need to create around 300 communication sites. So we have prepared one CSV file with details like Title, URL, Owner and so on. We have written CSOM code as follows

//Code to read .CSV file and then looping for each item / site for creating site collection

//Sample code to create sites using CSOM

Issue: But problem with above code is application get exit on the line – clientContext.CreateSiteAsync(cs); without any exception. Site is also not get created.

This code was working some days before and suddenly stop working. After bit googling we notice that ClientContext.CreateAsync() is in beta and can behave differently.

Solution: So no clue and then in one of the MS documentation found ClientContextExtensions class and then we tried CreateSiteAsync() method of this class as

The above code worked like a charm 🙂 All our sites created successfully.



Thanks for reading 🙂

Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more.

If you have any suggestion / feedback / doubt, you are most welcome.

Stay tuned on Knowledge-Junction, will come up with more such articles.

This site uses Akismet to reduce spam. Learn how your comment data is processed.