Showing posts with label Site collections. Show all posts
Showing posts with label Site collections. Show all posts

Saturday 4 July 2015

Provisioing Site Collections on-prem using the Tenant Admin API

Problem: Ability to provision Site Collections without using Server Side code.  Use CSOM and the Tenant Admin APIs.  This is a follow on the post: Provisioning Site Collections using CSOM (read it 1st).  Thanks to Sachin Khade, Frank M (check) and Alex N R (check) has given me his time to understand this: https://sachinkhade.wordpress.com/
I have reduced the Tenant Admin process into the least amount of steps that works.


The steps are:
Perform on an existing Web Application
Run the PS Script below:
  1. Create SC using a team site site template STS#0
  2. Set the AdministratorSite Type = TenantAdministrator
  3. Add ProxyLibrary that add the TenantAdmin dll
  4. Attach the Proxy to the existing Web Application
  5. Enable SelfServiceCreation on the Web Application
  6. IISReset
  • Using the C# console create new site collections using the Tenant Admin API
PS Script

========
# The first section contains the variables you need to specify based on your needs
$webapp =  get-spwebapplication http://radimaging.co.uk:555 # My Web application (already exists)
$url = "http://radimaging.co.uk:555/sites/msotenantcontext" # Tenant Admin Site Collection used for provisioing (does not exist)
$WebsiteName = "Tenant Admin"
$WebsiteDesc = "Tenant Admin Site"
# better to use the site template "tenantadmin#0" using the team site site template "sts#0" causes
# an error msg (SubscriptionId can't be null), both work but you get less admin options # for provisioning.
$Template = "STS#0" 
$PrimaryLogin = "radimaging\psmith"
$PrimaryDisplay = "Paul smith"
$PrimaryEmail = paul.smith@radimaging.com
# Create a site collection and top level website
New-SPSite -Url $url -Name $WebsiteName –Description $WebsiteDesc -Template $Template -OwnerAlias $PrimaryLogin –OwnerEmail $PrimaryEmail
$web = Get-SPWeb $url
$web.CreateDefaultAssociatedGroups($web.site.owner,$web.site.secondaryowner,"")
$web.Dispose()


#Set the TenantAdmin SC
$site = get-spsite -Identity $url
$site.AdministrationSiteType = [Microsoft.SharePoint.SPAdministrationSiteType]::TenantAdministration
$newProxyLibrary = New-Object "Microsoft.SharePoint.Administration.SPClientCallableProxyLibrary"
$newProxyLibrary.AssemblyName = "Microsoft.Online.SharePoint.Dedicated.TenantAdmin.ServerStub, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
$newProxyLibrary.SupportAppAuthentication = $true
$webapp.ClientCallableSettings.ProxyLibraries.Add($newProxyLibrary)
$webapp.SelfServiceSiteCreationEnabled=$True
$webapp.Update()
Write-Host "Successfully added TenantAdmin ServerStub to ClientCallableProxyLibrary."
# Reset the memory of the web application
Write-Host "IISReset..."   
Restart-Service W3SVC,WAS -force
Write-Host "IISReset complete."


As always check out this post from Vesa Vuronen:
https://blogs.msdn.microsoft.com/vesku/2014/06/09/provisioning-site-collections-using-sp-app-model-in-on-premises-with-just-csom/

Sunday 31 May 2015

Provisioing Site Collections using CSOM - Tenant Admin API

Overview:  This post looks at provisioning site collections using CSOM.  You can also provision site collections for SharePoint using PowerShell or any Server side object model. 
Points to Note:
Programmatically you can provisioning new site collections using CSOM using 2 approached namely:
  1. Tenant Admin API
  2. Http Post method (mimic the SharePoint UI for creating a site collection)
Note: Neither approach allows you to specify the Content Database to connect to, you shall need to manage the CDB you site collection goes into using the round robin site collection OOTB method for on-prem SP. 
Note: Tenant Admin API does not allow the Quota template to be specified.  See the FAQ section in this post.
Note: Tenant Admin API requires the April 2014 SP CU or later
Note: the Search Service Application needs to be configured to handle multi-tenancy to work correctly.  As do other the Service Applications using partitions to support multi-tenancy.  If you already have existing running farm, the change is a considerable effort.  The SA need to be created in partition mode and cannot be amended after creation (you will need to re-create the service Application).
Note: Using the Tenant Admin API for SC creation - you don't get the usual SP groups such as owner, contributor and visitor - you need to manually create them.
Note: I don't believe you can use the Publishing Site Template using the Tenant Admin API.
The Tenant Admin Site Collection can reside on the same or another Web Application where the site collections shall be provisioned.  Each Tenant Admin Site Collection (has it's own site template 'tenantadmin#0') has a SubscriptionId (Subscription Group) and when using the Tenant Site collection to create a new site collection, the new site collection is given the SubscriptionId for the group i.e. you can't specify the SubscriptionId declaratively).

Outline of steps to setup the Tenant Admin API:
  1. Service Application need to be configured in partition mode (important SSA are: search, UPA, MMS, BCS, SSS, there are more).
  2. Enabling remote site collection creation using CSOM on the Web Application
  3. Enable AdministrationSiteType property from a site collection to "TenantAdministration"
  4. Enable SelfServiceSiteCreationEnabled on the Web Application
  5. Set Up Tenant Admin for Multi Tenancy/setup subscription
More Information:
Multi-tenancy/Site subscriber explained by Bill Baer
Spencer Harbar's Rational Guide to Multi-tenancy is a useful resource
General guidance for hosters in SharePoint Server 2013 provides insight into Multi-Tenancy
https://technet.microsoft.com/en-us/library/dn659286.aspx
Scenarios where multi-tenancy potentially shall be used:
  1. O365/SharePoint Online
  2. SPO-D
  3. Hosting companies
  4. Government implementations such as G-Cloud
  5. Large Enterprise (only with extreme requirements)
Notes on HNSC using Tenant Admin API:
  • When creating a host name site collection with managed paths e.g. http://acme.com/sites/daffy, you need to create the corresponding root hnsc for the routing to work i.e. http://acme.com.
  • Creating a hnsc with a path is consider creating a hnsc not a path based site collection or a combination of the naming.
  • The manage path /sites/ which is already created works as it is already setup.  If you want another managed path you need to configure this separately.
Quota Limits:
Quota max storage size and code points are parameters in the CSOM Tenant Admin API, they don't set these values and you cannot set the quota templates using CSOM.  You only 2 options at this point in time is to use the UI and apply a template, not really an option for customers with hundreds, thousands or tens of thousands of site collections or you use PowerShell/ the Server side object model.

Permissions:
To be able to provision a new site collection, the account used to provision shall need to have contribute rights (it feels low and simple to me but that is the min) or higher on the Tenant Admin Site Collection.

Troubleshooting Tenant Admin Site Collection Provisioning:  Update 2017-06-28
I had tremendous problems with site collections not being completely created using CSOM and the tenant admin API on a new server that was provisioned by our engineering department.  There are a couple of IIS and farm setting you will want to review should you get this issue and our amazing team figured this out so it is not my credit.  Gonzalo, Uzzey and Anthony with thanks!


Change IIS timeouts on the WFE's and SP farm configs, this made the site collections provision completely correctly.

Tuesday 10 January 2012

Migrate MOSS site collection to SP2010

Problem: A common upgrade scenario I get in the role as a solutions architect is to move a site collection from a MOSS site to SP2010.
Initial Hypothesis: Do a side-by-side upgrade. Leave the existing site collection (or lock) it until the upgrade has the site collection on the new infrastructure. Don't go straight to production and I recommend doing the full upgrade on a standalone VM dev machine before even getting to test or production; this ensure the process works, is test and is repeatable.

Resolution: My suggested approach is to backup the content database containing the site collection, perform a “preupgradecheck and migrate it onto SP2010 on a dev machine. Next perform a backup of the site collection using CA or PS> as shown here Create the Installation Plan document that deploys the wsp’s and restore the site collection.  You can now move where the site collection to an existing content database.

More Info:
http://technet.microsoft.com/en-us/library/ee748617.aspx
http://blog.sharepointsite.co.uk/search?updated-max=2012-01-02T05:21:00Z&max-results=7

Saturday 2 October 2010

Powershell to Move a Site Collection to a new Content Database

Problem: I have several site collections inside a single content database.  The content database is growing rapidly.  Backup and restore is fairly slow and SQL can start slowing down if the db is large enough.

Hypothesis: Create at least additional content db, move specific site collections to the new Content database.  I was surprised that moving site collections to content databases is not in the Central Admin (CA) UI.

Resolution: Create an additional content database either using PowerShell (PS) or the UI namely:
1.> CA > Application Management > Manage Content Databases > Add a Content Database (I called my content database "WSS_Content_Empty").
2.> Move the Site collection to the new content database using PS
3.> Check the database has been moved in CA

More Info:
http://technet.microsoft.com/en-us/library/cc825328.aspx

Set New Content Database using CA Only:
  1. UI only option to achieve the same result would be to create the new content database using CA as shown above. 
  2. Next using CA go to "Manage Content Databases", select the old/existing content database and set it to offline (This means that you can't add new content databases, existing site collections are still available).
  3. Adding a new Site Collection will now use the new/next content database that is ready/online.   
End of Post

Backup and Restore Powershell commands:
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
cls
Backup-SPSite -Identity 'http://my.demo.dev/sites/kbtest' -Path C:\Projects\Backup\test.bak -Force -NoSiteLock -UseSqlSnapshot -Verbose
Restore-SPSite -Identity 'http://my.demo.dev/sites/newkbtest' -Path C:\Projects\Backup\test.bak -Force -Verbose