Migrate SharePoint On-Premises Content To SharePoint Online Using SPO API

SharePoint Point Online Migration PowerShell cmdlet is the another way of doing content migration without using a tool.

Below are steps for SharePoint Online PowerShell cmdlets to migrate the content. It requires minimal CSOM (Client-Side Object Model) call to avoid the threshold. It leverages temporary Azure Blob Storage container to hold the content and Azure Queue, which schedules parallel jobs.

Prerequisites to use the SPO Migration API.

Here are the steps for using SPO Migration PowerShell to upload your on-premises data into SharePoint Online.

Step1 - Export your document library content

This cmdlets export on-premises content to define folder structure.

Parameter

SiteUrl - Source site url ( i.e. https://dev.southasia.cloudapp.azure.com/sites/TeamSite)

ItemUrl - relative path of document library or list (i.e. /sites/teamsite/contentlib )

Path - folder structure path (C:\MigrationAPI\Contentlib)

Example 
  1. Export-SPWeb -Identity "<<SiteUrl>>" -ItemUrl "<<document library relative path>>" -Path "<<physical folder path>>" -NoFileCompression -IncludeVersions All

Step2 - Get your credentials into variables

  1. $username = "[email protected]"  
  2. $cred = Get-Credential $username  

Step3- Set Source Package & File Path

At initial stage source file & package is same as export path of document library

  1. $sourceFiles = "C:\MigrationAPI\Contentlib "  
  2. $sourcePackage=" C:\MigrationAPI\Contentlib "  

Note:- Source File & Source Package can be any path where you want to export the content. 

Step4- Set Output Package Path
  1. $outputPackagePath = "C:\MigrationAPI\outputPackagePath"  

Note:- Output Package can be any path where you want to generate the package files.  

Step5- Get target web & library 
  1. $targetWebUrl = "https://sharepointtimes.sharepoint.com/sites/teamsite"  
  2. $targetLibrary = "contentlib"  

Step6- Convert Package for your target site

This creates a content package from a backup folder. The New-SPOMigrationPackage command reads the list of content targeted by the source path and will generate XML to perform the migration.

The following parameters are required:-

source files: points to the content you want to migrate

source package: points to content you want to migrate

targetWebUrl: point to your destination web

targetLibrary: point to the document library inside the web.

OutputPackagePath: points to your Temporary folder

Example

This example shows how to convert a package to a target one by looking into the source.

  1. ConvertTo-SPOMigrationTargetedPackage -SourceFilesPath $sourceFiles -SourcePackagePath $sourceFiles -OutputPackagePath $outputPackagePath -TargetWebUrl $targetWebUrl -TargetDocumentLibraryPath $targetLibrary -Credentials $cred  

Step7- Set Azure Storage Path & Variable

$fileContainerName = "onlinefile01” (optional) - Its azure blog storgare file container name

$packageContainerName ="onlinepackage01" (optional) - Its azure blog storage package container name

$azureAccountName = "onlineazurestorage" - Its Azure Blog Storage account name

$azureAccountKey = “TQDKxHnHUDCG7uCjlfk646fzH5BV+mjjrocA9p6P0ENCJ2aHoY4+F6xOfdhnUslQ==" - Its Azure Blog Storage account access key

$azureAzureQueueName = "migrationqueue01" - (optional) - Its migration queue name

Step8- Set SharePoint Online Migration Package source

This cmdlets help to create a defined file & package container into azure blob storage as well as move the content from source file & output package path

The following parameters are required & optional,

sourceFiles: points to the content you want to migrate

sourcePackage: points to your Temporary folder

FileContainerName:- temporary file container to hold the content (optional)

PackageContainerName:- temporary package container to hold the package (optional)

AccountName:- Azure blog storage account name

AccountKey:- Azure blob storage account access key

AzureQueueName:- Azure storage queue name (optional)

Example

  1. $azurelocations=Set-SPOMigrationPackageAzureSource -SourceFilesPath $sourceFiles -SourcePackagePath $outputPackagePath -FileContainerName $fileContainerName -PackageContainerName $packageContainerName -AccountName $azureAccountName -AccountKey $azureAccountKey –Overwrite -AzureQueueName $azureAzureQueueName  

Step9- List down the Azure Storage File container, Package Container & Queue URI

  1. $azurelocations|fl  

Step10- Submit the Migration Job

This cmdlet help to generate the parallel queue to migrate the content from temporary storage to target web

There are three required parameter

TargetWebUrl:- target web URL where content needs to migrate

MigrationPackageAzureLocations:- above set variable

Example

  1. Submit-SPOMigrationJob -TargetWebUrl $targetWebUrl -MigrationPackageAzureLocations $azurelocations -Credentials $cred  

Step11- Monitoring the job status (Optional)

After the job is submitted, only Azure Migration Queue interacts to fetch and migrate the content to the target SharePoint Online Site. This process is timer-job based.

Example

This cmdlet gives the running job status. If it doesn’t return any value, that means the processing has been completed; else it shows "In Processing".

  1. Get-SPOMigrationJobStatus -TargetWebUrl $targetWebUrl -Credentials $cred