Monday, June 20, 2016

SharePoint Migration to Online (SPO-O365) from On-Premise SharePoint using Azure API as well as Powershell command.

Introduction

The step which is involved in Migrating to SharePoint Online (O365–SPO) from SharePoint Onprem or file share using PowerShell migration Azure APIs.
This involves the script which is helpful in creating SPO Migration Package from SharePoint Onprem Content using PowerShell Commands i.e. exporting the lists, document libraries, form libraries etc. of a site collection or a site.

Business case

Azure APIs are provided by Microsoft. These APIs can be used to save the overall licensing cost of migration tool. Effective Time utilization as well as Work fragmentation by using this API.

Targeted Audience

  • SharePoint Application Developers
  • SharePoint Administrator
  • SharePoint Architect

Technologies used

  • SharePoint onprem (SP2010/SP2013/MOSS-2007)
  • SharePoint Online (Office 365)
  • Online management PowerShell
  • Azure storage, blobs & containers
  • Require as access to Azure Management tool for creation of the Azure Blob’s

Pre-requisites

  • RDP to a WFE for SharePoint Onprem Server
  • Valid Office 365 subscription
  • Valid Microsoft Azure subscription
  • SharePoint Online management shell version 16.0.4017.1200 or above version. Download here More details at https://technet.microsoft.com/en-us/library/fp161372.aspx
  • windows PowerShell 3.0 and above version
  • SharePoint Admin Tenant account access is required.

Migration Steps for SharePoint Online (O365–SPO) from SharePoint Onprem


To keep things simple, let’s divide the entire process in few steps:
For migrating the content from SharePoint On-Premise to SharePoint Online includes five steps as below.
1. Create SPO Migration Package from SharePoint On-Prem Content.
2. Prepare Final SPO Migration Package.
3. Upload SPO Migration Package to Azure Blob Containers.
       4. Submit Migration Job.
       5. Check Migration Job Status (Optional).

Steps for SharePoint Online (O365–SPO) from SharePoint Onprem

Step 1 – Create SPO Migration Package

  1. Create SPO Migration Package from SharePoint On-Premise Content
  2. RDP to a WFE for On-Premise SharePoint Server
  3. Open SharePoint Management Shell as administrator
  4. Export the Web / Site Collection data using the below cmdlet
Export-SPWeb -Identity "http ://<On-PremSPSite>" -ItemUrl "/OnPremDocLib" -Path "C:

\SPOnPremExport" -NoFileCompression -IncludeVersions All

Example -
Export-SPWeb -Identity "http://stockxchange.stockland.com.au/OnlineForms" -ItemUrl /OnlineForms/Documents –Path "C:\Documents" -NoFileCompression -IncludeVersions All




                                                                Fig 1
Note1:
  • Make sure the drive have sufficient space to Export the data.

Note2:
  • In SPWeb put SharePoint 2010 site collection or subsite Url.
  • Item Url parameter has to be a relative path i.e. if absolute URL is http://SharePoint.avande.com/DocLib then –Item Url will be just “/ DocLib”
  • No File Compression is specified so output will be created in a folder and hence -Path is given without .cmp
  • At this time, SPO migration pipe is oriented for list and document library content only. Hence, Item Url is required.


Copy Data: Once you run the above command, it will generate the data files (shown in fig-3) which you need to copy to a folder on your machine which has SharePoint Online Management Shell installed.


                                                                                Fig 2

Step 2 – Prepare SPO Migration Package

Prerequisites:
  • Valid Office 365 subscription
  • Valid Microsoft Azure subscription
  • Install SharePoint Online management shell version 16.0.4017.1200 or above from here. More details at https://technet.microsoft.com/en-us/library/fp161372.aspx
  • Run SharePoint Online management shell as Administrator and connect SPO service using the below cmdlet. The user needs an Admin level access on the Admin Tenant.

Run the below command:-

Connect-SPOService -Url https:\\www.Sharepoint-admin.sharepoint.com



Example-

Connect-SPOService –Url https://sharepoint-admin.sharepoint.com


Prepare data / files to be migrated using below cmdlet

Run the below command:-


ConvertTo-SPOMigrationTargetedPackage -SourceFilesPath "C:\MigrationPackages\SPOTEMP" 
-SourcePackagePath "C:\MigrationPackages\SPOTEMP" 
-OutputPackagePath "C:\MigrationPackages\SPOMigrationPackage" 
-TargetWebUrl "https://<SPOSite>.sharepoint.com/" 
-TargetDocumentLibraryPath "SPOMigration"










  
Example-

ConvertTo-SPOMigrationTargetedPackage -SourceFilesPath "C:\Documents" -SourcePackagePath "C:\Documents" -OutputPackagePath " C:\SPODocuments” -TargetWebUrl "https://sharepoint.sharepoint.com/sites/Test/" -TargetDocumentLibraryPath "Documents"

                                                     
         
                                                             Fig 3

There are six required parameters to enter

  • TargetwebURL: The fully qualified web URL of a web that is the expected target of the import operation. This URL will be used as the web address part of the base URL in the package metadata.
  • SourceFilesPath: The directory location where the package’s source content files exist.
  • SourcePackagePath: The directory location where the package’s source metadata files exist.
  • OutputPackagePath: The directory location where the transformed package metadata files will be saved. If the directory does not exist, then it will be created.
  • TargetDocumentLibraryPath: The web relative document library that is the expected target of the import operation. This URL will be used as the document library part of the URL in the package metadata. The document library must already exist at the specified target web URL as it will be contacted during transformation to determine appropriate values for the package metadata transformation.
  • Credentials: Optional credentials of a site collection administrator to use to connect to the site collection. The credentials should supply the username in UPN format (e.g. user@company.onmicrosoft.com). If this property is not set, the current tenant admin credentials from the session’s previous call to Connect-SPOService will be used to connect to the site collection.



                                                                      Fig-4

Note:-Copy the all .xml files as show in Fig.6 into from source file path to OutputPackagePath




                                                                      Fig-5

Step 3 – Upload SPO Migration Package to Azure Blob Containers

How to create storage account on Azure?

  • Follow the below steps to get Storage Account Name and two container names inside it. If you already have a storage account, you could use the same
  • Login to Azure Portal via https://manage.windowsazure.com or https://portal.azure.com
  • Browse to Storage > Create a new storage account e.g. nO365mig
  • In newly created storage account create two containers e.g. migration-files, migration-package

Prepare to upload the prepared data / files to Azure Blob Containers using below cmdlet

Run the below command:-

$azurelocations = Set-SPOMigrationPackageAzureSource -SourceFilesPath 
"C:\MigrationPackages\SPOTEMP" -SourcePackagePath "C:\MigrationPackages\SPOMigrationPackage
" -FileContainerName migration-files -PackageContainerName migration-package 
-AccountName nO365mig -AccountKey "REAPLCE_WITH_YOUR_AZURE_STORAGE_ACCOUNT_ACCESS_KEY" 
–Overwrite  -AzureQueueName migrationqueue

Example-

$azurelocations = Set-SPOMigrationPackageAzureSource -SourceFilesPath " C:\Documents" -SourcePackagePath "C:\SPODocuments" -FileContainerName migration-files2 -PackageContainerName migration-package2 -AccountName sam365mig -AccountKey " Jo3szIp5qqtDQ1gMuhkpn436i1yJeYkchdjRNIqMxsYEWkhIkX4XRnrmY4+c2HGHlvUAE11L4gcDcYWyAwGyCw==" –Overwrite  -AzureQueueName migrationqueue



                                                               Fig-6

Step 4 – Submit Migration Job on Online Tenant site or subsite

After uploading the files as well as packages to azure now we have to submit the data to our tenant or online site.

Submit Migration Job to transfer data from Source <to> Azure Blob Containers <to> SPO Site Collection using below cmdlet

Run the below command:-

Submit-SPOMigrationJob -TargetWebUrl "https ://<SPOSite>.sharepoint.com/" 
-MigrationPackageAzureLocations $azurelocations


Example-
Submit-SPOMigrationJob -TargetWebUrl "https://sharepoint.sharepoint.com/sites/Test/" -MigrationPackageAzureLocations $azurelocations



                                                                            Fig-7


Step 5 (Optional) – Check Migration Job Status

Check migration job (to transfer data from Azure Blob Containers to SPO Site Collection) status using below cmdlet.

Run the below command:-

Get-SPOMigrationJobStatus -TargetWebUrl https://sharepoint-admin.sharepoint.com


                                                                                 Fig-8

Note
  1. Queue Status: Data been not picked to process. Wait sometime to go under process.
  2. Processing Status: Data will processing from Azure to tenant site.
  3. No Status: If job is successfully completed then it will not show any status.


Showing data has been migrated successfully as below:-



                                                                  Fig-10

Step 6 (Optional) – Remove Migration Job

In case if the migration job is stuck or if it needs to be removed for any reason you could use the below cmdlet (Note: This will work only if the job is not already completed)

Using below command we can easily remove the pending jobs:-


Run the below command:-

Remove-SPOMigrationJob -JobId e79c5022-3aa1-446c-a8e6-2431063706fa -TargetWebUrl 
https://sharepoint.sharepoint.com



Benefits/value adds

  • While migration from SharePoint onprem to SharePoint online i.e.  Office 365 using Azure API is very efficient because it doesn’t require any migration tool having too much costing.
  • No third party tool was used for migration as well as reporting. 
  • Effective Time utilization by using this API as well as Work fragmentation.


Conclusion

I wish your migration has gone very smoothly. If it does not, then feel welcome to contact me via the comments section below. I will try to reply within a short time.

13 comments:

  1. I have to migrate from MOSS 2007 to SharePoint Online keeping the metadata. There is no custom work. Whats the best way?

    ReplyDelete
    Replies
    1. Export the metadata in csv and you can re-apply metadata in the above azure API command.

      Delete
  2. Can this method be used to migrate Site collections or Sites?

    ReplyDelete
  3. Facing below issue, while migrating list, please help on it:

    Package must have heirarchy of migration objects from the root object up to a parent web object ..

    ReplyDelete
    Replies
    1. That might beacuse the target list path you provided is not right
      It should start with "Lists/"

      Delete
  4. Try
    TargetDocumentLibraryPath "Lists/ListName"

    ReplyDelete
  5. I have followed your process and able to migrate files but files which are migrated are only .dat files. can you help me to solve this issue

    ReplyDelete
  6. Provide me your issue. I will help

    ReplyDelete