Hi I am trying to get an app done to provision a Site Collection.

The vision is to allow the user to enter important details and then click a button and have the Site Collection created automatically.

I have had a look at the following (very excellent) posts:



but these mention that Site provisioning via the App model can only be done for Office 365.

So, I tried to modify the code of the app in Link 1, to be used within a High trust provider hosted app.


        var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

        using(var clientContext = spContext.CreateAppOnlyClientContextForSPHost())
            var tenant = new Tenant(clientContext);
            webUrl = String.Format("{0}{1}", BasePath, Url);
            var properties = new SiteCreationProperties()
                Url = webUrl,
                Owner = sAdministrator,
                Title = sTitle,
                Template = sSiteTemplate,
                StorageMaximumLevel = iStorageMaximum,
                UserCodeMaximumLevel = dUserCodeMaximum
            SpoOperation op = tenant.CreateSite(properties);
            clientContext.Load(op, i => i.IsComplete);

            //check if site creation operation is complete
            while (!op.IsComplete)
                //wait 30seconds and try again

When executing the lines:

SpoOperation op = tenant.CreateSite(properties); clientContext.Load(tenant); clientContext.Load(op, i => i.IsComplete); clientContext.ExecuteQuery(); , the following error is thrown:

Cannot find stub for type with id "{268004ae-ef6b-4e9b-8425-127220d84719}". The specified server may not support APIs used in this operation.

Any ideas what this might be caused by?

I think this is either a problem in my environmental setup, or that site collection creation can only be done for an Office 365 site?

1 Answer 1


Up until April 2014 Cumulative Update for the SharePoint 2013 release only Office 365 and SP Online supported the provisioning of site collections remotely using CSOM extensions (part of the Windows PowerShell for SharePoint Online package). This set of functionalities was not available for on-premises (or Office365-Dedicated).

With April 2014 Cumulative Update for the SharePoint 2013 the capability of remote provisioning of site collections was introduced to on-premises farm.


There are some pre-requirements to enable site collection provisioning with CSOM in on-premises farm. Reasoning for these steps is that we’ve tried to ensure minimum difference between on-premises and Office365 development patterns and there was no point introducing new CSOM API which are specifically for the on-premises after the introduction of site collection creation capability to the Offic365. Here’s the required steps one by one. Notice that the PowerShell scripts are also included in the downloadable sample code.

  1. Install April 2014 Cumulative Update for the SharePoint 2013 to your SharePoint 2013 farm Check Stefan Goßner’s blog post for detailed links and additional insights
  2. Enable remote site collection creation using just CSOM by running specific PowerShell script available here
  3. Download the Windows PowerShell for SharePoint Online and install that to your remote development environment where you write your CSOM code This contains 15 version of the objects which are also needed with SP2013 on-premises. These are located in the Microsoft.Online.SharePoint.Client.Tenant.dll assembly, which is by default installed to C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell folder. Latest version is from May 2014, but the previous released version from 2012 does also work. since we have not introduced any real changes on the client side of the code.
  4. Enable AdministrationSiteType property from one site collection in your on-premises farm which will be acting like a admin site for site collection creation. This could be for example root site in the root site collection of the application where you create the new site collections.

Please follow Provisioning site collections using SP App model in on-premises with just CSOM post for a more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.