0

I want to create a new web application in SharePoint online Office 365, using windows power shell. I had created web application on SharePoint on-premises using windows power shell. I went through some links which I got but they are giving solution on how to create site collection in SharePoint online. We need to implement some CSOM code, and by that we can create site collections, site, list, library in SharePoint online using power shell. Any idea on how to create new SharePoint web-application in SharePoint online using power shell. Following are the links that I have went through,

http://www.sharepointfire.com/2016/01/create-new-web-sharepoint-online-powershell/

https://blogs.technet.microsoft.com/heyscriptingguy/2014/04/24/create-and-manage-sharepoint-online-sites-by-using-powershell/

https://technet.microsoft.com/en-us/library/fp161388.aspx

Any help would be appreciated.

3
  • New web application meaning abc.SharePoint.com , xyz.sharepoint.com ? Feb 10, 2017 at 11:16
  • Yes exactly that's what I want.. Feb 10, 2017 at 11:53
  • @gautam already answered. No , you can not do that. Feb 10, 2017 at 12:44

1 Answer 1

3

No you can't create a new "web application" in SPO. You can create a new Site collection only. It can be either under /sites or /teams path only.

There is only one "web application" and it is https://tenantname.sharepoint.com. It is also the root site collection.

To create new site collection you can run below powershell:

New-SPOSite -Url https://tenantname.sharepoint.com/sites/mysite -Owner [email protected] -StorageQuota 1000 -Title "My new site collection"

Reference - New-SPOSite

You also need to install the SharePoint online powershell to run this command.

Download link - SharePoint Online Management Shell

You can also do this via UI.

Go the admin center. You must have global admin or atleast sharepoint admin rights. Click on New > Private site collection. Fill up the details and it will create a new site collection.

Url of admin center:

https://tenantname-admin.sharepoint.com

enter image description here

Using CSOM:

Install SharePoint Server 2013 Client Components SDK

After that you can create site collections via console application after adding the necessary DLLs.

using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using System;
using System.Security;

namespace CreateSiteCollections
{
    class Program
    {
        static void Main(string[] args)
        {   
            //Open the Tenant Administration Context with the Tenant Admin Url
            using (ClientContext tenantContext = new ClientContext("https://yoursite-admin.sharepoint.com/"))
            {
                //Authenticate with a Tenant Administrator
                SecureString passWord = new SecureString();
                foreach (char c in "password".ToCharArray()) passWord.AppendChar(c);
                tenantContext.Credentials = new SharePointOnlineCredentials("[email protected]", passWord);

                var tenant = new Tenant(tenantContext);

                //Properties of the New SiteCollection
                var siteCreationProperties = new SiteCreationProperties();                
                //New SiteCollection Url
                siteCreationProperties.Url = "https://yoursite.sharepoint.com/sites/codesite";                
                //Title of the Root Site
                siteCreationProperties.Title = "Site Created from Code";     
                //Email of Owner
                siteCreationProperties.Owner = "[email protected]";                
                //Template of the Root Site. Using Team Site for now.
                siteCreationProperties.Template = "STS#0";     
                //Storage Limit in MB
                siteCreationProperties.StorageMaximumLevel = 100; 
                //UserCode Resource Points Allowed
                siteCreationProperties.UserCodeMaximumLevel = 50;

                //Create the SiteCollection
                SpoOperation spo = tenant.CreateSite(siteCreationProperties);

                tenantContext.Load(tenant);

                //We will need the IsComplete property to check if the provisioning of the Site Collection is complete.
                tenantContext.Load(spo, i => i.IsComplete);

                tenantContext.ExecuteQuery();

                //Check if provisioning of the SiteCollection is complete.
                while (!spo.IsComplete)
                {
                    //Wait for 30 seconds and then try again
                    System.Threading.Thread.Sleep(30000);
                    spo.RefreshLoad();
                    tenantContext.ExecuteQuery();
                } 
                Console.WriteLine("SiteCollection Created."); 
            }            
        }
    }
}

Code reference - Create site collections using CSOM

3
  • Okay, how can there be only one web application. I mean, I am not aware about the farm structure in office 365. So I am asking. Since as per my knowledge, there is one tenant admin who manages the web applications. And can create the same. How does the central admin work there in SharePoint online, that we can create only one web application. Feb 10, 2017 at 12:58
  • 1
    I am hazarding guess here, but i am pretty sure its accurate. The farm structure would be similar to that we have on standard on premise. However it has restrictions. So ,whenever an org buys SPO subscription, a "web application" is created and is tied to your subscription. So you can create only one webapp say tenantname.sharepoint.com , if you want another one like abc.sharepoint.com, you need to buy another subscription. It cant be associated with the old one. This is Microsoft defined way. Even the tenant admin/global admin cant create "web app", they can only create site collections. Feb 10, 2017 at 14:11
  • 1
    The entire infra is handled by Microsoft, so unlike our traditional central admin, here we have the admin-center somewhat similar but quite different. For example, you cant deploy wsp with dll or monitor & run timer jobs etc. Everything is handled by MS. Feb 10, 2017 at 14:12

Your Answer

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

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