This sample demonstrates how to import and export operations on search settings via a CSOM console application.
- Office 365 Multi-Tenant (MT)
|Core.SearchSettingsPortability||Brian Michely (Microsoft)|
|1.0||June 30, 2014||Initial release|
THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
"Search Portability" supports transferring the following items:
- Results sources
- Query rules
- Result types
- Custom ranking models
You can transfer settings between a tenant, site collections or sites. This can be done via the SharePoint UI, or via CSOM, which is the basis for this sample. This sample is a simple console application that prompts for the following arguments:
- Type of operation to perform (Import | Export)
- Path for settings file (where to save for export, or where to import from)
- Url of SharePoint Online site
- User name (ex: email@example.com)
The code will attempt to authenticate via the SharePointOnlineCredentials object which provides credentials to access SharePoint Online resources
context.Credentials = new SharePointOnlineCredentials(userName, password); context.Load(context.Web, w => w.Title); context.ExecuteQuery();
Once authenticated, the add-in will use CSOM to either Import or Export by calling the appropriate method. The methods use the SearchConfigurationPortability and SeachObjectOwner objects and the code executes either the ExportSearchSettings method or ImportSearchSettings method to perform the action requested by the user in the console.
Example of the Import method The end result from an export is a search settings .xml file that can be use elsewhere by performing the import shown above.