Sitecore 10.2 Upgrade Guide

Sitecore 10.2 Upgrade Guide

Update from Sitecore 9.3 to 10.2

This post is to show how we moved from Sitecore 9.3 to 10.2 within a short timeframe of 3 months to go live. This is the approach we took to upgrade Sitecore from 9.3 to 10.2 in Azure.

Phase 1 – Sitecore XP Local Instance Setup

Created a new Sitecore 10.2 instance in our local virtual machines by downloading the Graphical setup package for XP Single from Sitecore Downloads

Installed Sitecore 10.2 using Sitecore 10.2 Setup.exe (takes about 15 mins and your local Sitecore 10.2 vanilla Instance will be up and running)

Backup the IIS folder (just in case)

Phase 2 – Code Migration

The code migration was pretty straightforward, we have made the following changes

Update the Nuget packages to Sitecore 10.2

Update the projects from .Net 4.7 to .Net 4.8

Update any dependencies as required

Update code where applicable (very minimal in our case)

Phase 3 – Deploying Code to Local Instance

We used TDS for serialization and creating packages for release.

Deploy the latest code to your local 10.2 instance, including any custom config patch files.

Deploy the Sitecore items using TDS Sync or through packages using Installation Wizard.

Copy content items from 9.3 Sitecore instance as a package.

Publish the site.

Verify that Sitecore 10.2 is up and running with all the content as expected.

Phase 4 – Sitecore 10.2 Vanilla Setup in Azure

Download Sitecore 10.2 Arm templates from GitHub using the URL https://github.com/Sitecore/Sitecore-Azure-Quickstart-Templates

You can use the ARM templates as is, but we had made minor changes to suit our requirements

Upload the arm templates to storage or git

Update the Params file with all the values

Copy the Sitecore license file in the same folder as the params file folder

Coveo the Certificate PFX file in the same folder as the params file folder

Save the below PowerShell script in the same folder as the params file folder

Run the PowerShell script below as Administration (update the highlighted values)


# Specify the parameters for the deployment
$ArmTemplateUrl = "RAW URL for azuredeploy.json"
$ArmParametersPath = ".\azuredeploy.parameters.json"
$licenseFilePath = ".\license.xml"

# Specify the certificate file path and password if you want to deploy Sitecore XP or XDB configurations
$certificateFilePath = ".\certificate.pfx"
$certificatePassword = "CertificatePassword"
$certificateBlob = $null

# read the contents of your Sitecore license file
$licenseFileContent = Get-Content -Raw -Encoding UTF8 -Path $licenseFilePath | Out-String

# read the contents of your authentication certificate
if ($certificateFilePath) {
  $certificateBlob = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($certificateFilePath))
}

#region Create Params Object
# license file needs to be secure string and adding the params as a hashtable is the only way to do it
$additionalParams = New-Object -TypeName Hashtable

$params = Get-Content $ArmParametersPath -Raw | ConvertFrom-Json

if ($params | Get-Member -Name parameters) {
  $params = $params.parameters
}

foreach($p in $params | Get-Member -MemberType *Property)
{
  $additionalParams.Add($p.Name, $params.$($p.Name).value)
}

$additionalParams.Set_Item('licenseXml',$licenseFileContent)

# Inject Certificate Blob and Password into the parameters
if ($certificateBlob) {
  $additionalParams.Set_Item('authCertificateBlob',$certificateBlob)
}
if ($certificatePassword) {
  $additionalParams.Set_Item('authCertificatePassword',$certificatePassword)
}
$Name = $additionalParams.Get_Item('deploymentId')
$location = $additionalParams.Get_Item('location')

$AzureSubscriptionId = "5fbe774a-cc2f-4042-b482-9cef9e80344a"

#endregion

try
{

#region Validate Resouce Group Name

Write-Host "Validating Resource Group Name..."
#if(!($Name -cmatch '^(?!.*--)[a-z0-9]{2}(|([a-z0-9\-]{0,37})[a-z0-9])$'))
#{
# Write-Error "Name should only contain lowercase letters, digits or dashes,
# dash cannot be used in the first two or final character,
# it cannot contain consecutive dashes and is limited between 2 and 40 characters in length!"

# Break;
#}

#endregion

Write-Host "Setting Azure PowerShell session context..."

#region Use Manual Login
try
{
Login-AzureRmAccount -SubscriptionId $AzureSubscriptionId
}
catch
{
Write-Host "inside catch"
}
#endregion

  Write-Host "Check if resource group already exists..."
$notPresent = Get-AzureRmResourceGroup -Name $Name -ev notPresent -ea 0

if (!$notPresent)
{
New-AzureRmResourceGroup -Name $Name -Location $location
}

Write-Host "Starting ARM deployment..."        
    New-AzureRmResourceGroupDeployment `
-Name $Name `
-ResourceGroupName $Name `
-TemplateUri $ArmTemplateUrl `
-TemplateParameterObject $additionalParams `
# -DeploymentDebugLogLevel All -Debug -Verbose
}
catch
{
Write-Error $_.Exception.Message
Break
}
Write-Host "Deployment Complete."

Depending on the resources selected, installation can take anywhere between 45 mins to 2 hours.

Once the deployment is complete. Verify the Sitecore 10.2 vanilla instance is up and running.

Phase 5 – Upgrade 9.3 to 10.2 (Databases)

Now that the vanilla instance of 10.2 is up and running, it’s time to upgrade the database from 9.3 to 10.2

Copy the 9.3 production databases to the 10.2 resource group using the database scripts below (use a different name from the 10.2 vanilla database names).

Open SQL Server Management Studio and connect to the 10.2 database server

Run the below commands using master database (update highlighted values)

CREATE DATABASE [CopiedDatabase-core-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-core-db];
CREATE DATABASE [CopiedDatabase-exmmaster-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-exmmaster-db];
CREATE DATABASE [CopiedDatabase-forms-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-forms-db];
CREATE DATABASE [CopiedDatabase-ma-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-ma-db];
CREATE DATABASE [CopiedDatabase-master-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-master-db];
CREATE DATABASE [CopiedDatabase-pools-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-pools-db];
CREATE DATABASE [CopiedDatabase-processingenginestorage-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-processingenginestorage-db];
CREATE DATABASE [CopiedDatabase-processingenginetasks-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-processingenginetasks-db];
CREATE DATABASE [CopiedDatabase-refdata-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-refdata-db];
CREATE DATABASE [CopiedDatabase-reporting-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-reporting-db];
CREATE DATABASE [CopiedDatabase-shard0-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-shard0-db];
CREATE DATABASE [CopiedDatabase-shard1-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-shard1-db];
CREATE DATABASE [CopiedDatabase-smm-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-smm-db];
CREATE DATABASE [CopiedDatabase-tasks-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-tasks-db];
CREATE DATABASE [CopiedDatabase-web-db] AS COPY OF [ProdDatabaseServerName].[ProdDatabase-web-db];

Run the below script to verify copying of databases is done. if the script returns 0 results, then copying of databases is now complete

select * from sys.dm_database_copies

Update authorization on all databases to SqlAdminUser (user defined for SQLUser in ARM templates param file)

ALTER AUTHORIZATION ON DATABASE::[CopiedDatabaseName] to [SqlAdminUserName];

Run the Sitecore 10.2 Upgrade scripts from 9.,3 to 10.2. The following scripts are applicable for the 9.3 to 10.2 upgrade

CMS_core

CMS_core_master_web_9x

CMS_master.sql

CMS_security.sql

CMS_web.sql

SXP_collection_GrantPermissions.sql(Run on both Shard0 and Shard1 databases)

SXP_collection_Part1.sql (Run on both Shard0 and Shard1 databases)

SXP_collection_Part2.sql (Run on both Shard0 and Shard1 databases)

SXP_experienceforms_filestorage.sql

SXP_experienceforms_storage.sql

SXP_marketingautomation.sql

SXP_processing_engine_tasks.sql

SXP_reporting.sql

SXP_reporting_migrate_experience_optimization_data.sql

Clear the Queues from Core, Web, and Master databases using the following script

delete from PublishQueue
delete from EventQueue
delete from History

Rename 10.2 Vanilla Databases to keep it as backup using the following scripts

ALTER Database [10.2VanillaDatabase-core-db] MODIFY NAME = [10.2VanillaDatabase-core-db-backup]
ALTER Database [10.2VanillaDatabase-exmmaster-db] MODIFY NAME = [10.2VanillaDatabase-exmmaster-db-backup]
ALTER Database [10.2VanillaDatabase-forms-db] MODIFY NAME = [10.2VanillaDatabase-forms-db-backup]
ALTER Database [10.2VanillaDatabase-ma-db] MODIFY NAME = [10.2VanillaDatabase-ma-db-backup]
ALTER Database [10.2VanillaDatabase-master-db] MODIFY NAME = [10.2VanillaDatabase-master-db-backup]
ALTER Database [10.2VanillaDatabase-pools-db] MODIFY NAME = [10.2VanillaDatabase-pools-db-backup]
ALTER Database [10.2VanillaDatabase-processingenginestorage-db]  MODIFY NAME = [10.2VanillaDatabase-processingenginestorage-db-backup]
ALTER Database [10.2VanillaDatabase-processingenginetasks-db]  MODIFY NAME = [10.2VanillaDatabase-processingenginetasks-db-backup]
ALTER Database [10.2VanillaDatabase-refdata-db] MODIFY NAME = [10.2VanillaDatabase-refdata-db-backup]
ALTER Database [10.2VanillaDatabase-reporting-db] MODIFY NAME = [10.2VanillaDatabase-reporting-db-backup]
ALTER Database [10.2VanillaDatabase-shard0-db] MODIFY NAME = [10.2VanillaDatabase-shard0-db-backup]
ALTER Database [10.2VanillaDatabase-shard1-db] MODIFY NAME = [10.2VanillaDatabase-shard1-db-backup]
ALTER Database [10.2VanillaDatabase-smm-db] MODIFY NAME = [10.2VanillaDatabase-smm-db-backup]
ALTER Database [10.2VanillaDatabase-tasks-db] MODIFY NAME = [10.2VanillaDatabase-tasks-db-backup]
ALTER Database [10.2VanillaDatabase-web-db] MODIFY NAME = [10.2VanillaDatabase-web-db-backup]

Rename 9.3 Copied databases to 10.2 Vanilla database names using the script below.

ALTER Database [CopiedDatabase-audit-db] MODIFY NAME = [10.2VanillaDatabase-audit-db]
ALTER Database [CopiedDatabase-core-db]  MODIFY NAME = [10.2VanillaDatabase-core-db]
ALTER Database [CopiedDatabase-exmmaster-db] MODIFY NAME = [10.2VanillaDatabase-exmmaster-db]
ALTER Database [CopiedDatabase-forms-db] MODIFY NAME = [10.2VanillaDatabase-forms-db]
ALTER Database [CopiedDatabase-ma-db] MODIFY NAME = [10.2VanillaDatabase-ma-db]
ALTER Database [CopiedDatabase-master-db]  MODIFY NAME = [10.2VanillaDatabase-master-db]
ALTER Database [CopiedDatabase-pools-db] MODIFY NAME = [10.2VanillaDatabase-pools-db]
ALTER Database [CopiedDatabase-processingenginestorage-db] MODIFY NAME = [10.2VanillaDatabase-processingenginestorage-db]
ALTER Database [CopiedDatabase-processingenginetasks-db]  MODIFY NAME = [10.2VanillaDatabase-processingenginetasks-db]
ALTER Database [CopiedDatabase-refdata-db]  MODIFY NAME = [10.2VanillaDatabase-refdata-db]
ALTER Database [CopiedDatabase-reporting-db] MODIFY NAME = [10.2VanillaDatabase-reporting-db]
ALTER Database [CopiedDatabase-shard0-db] MODIFY NAME = [10.2VanillaDatabase-shard0-db]
ALTER Database [CopiedDatabase-shard1-db] MODIFY NAME = [10.2VanillaDatabase-shard1-db]
ALTER Database [CopiedDatabase-smm-db]  MODIFY NAME = [10.2VanillaDatabase-smm-db]
ALTER Database [CopiedDatabase-tasks-db] MODIFY NAME = [10.2VanillaDatabase-tasks-db]
ALTER Database [CopiedDatabase-web-db] MODIFY NAME = [10.2VanillaDatabase-web-db]

Update the shard0 database mapping using the script below

update [__ShardManagement].[ShardsLocal]
set ServerName = '10.2SQLServerName', DatabaseName = '10.2VanillaDatabase-shard0-db'

Update the shard1 database mapping using the script below

update [__ShardManagement].[ShardsLocal]
set ServerName = '10.2SQLServerName', DatabaseName = '10.2VanillaDatabase-shard1-db'

Update the SMMdatabase mapping to use the right Shard databases using the script below

update [__ShardManagement].[ShardsGlobal]
  set ServerName = '10.2SQLServerName', DatabaseName = '10.2VanillaDatabase-shard0-db'
  where ShardId in ('E969A18C-F922-46D3-A51E-FADC58373FCA', 'F4AB4DD7-514C-49BC-B28A-BE611531D3F5','F7362703-E517-4A86-9577-14C9C365A3F8')

update [__ShardManagement].[ShardsGlobal]
  set ServerName = '10.2SQLServerName', DatabaseName = '10.2VanillaDatabase-shard1-db'
  where ShardId not in ('E969A18C-F922-46D3-A51E-FADC58373FCA', 'F4AB4DD7-514C-49BC-B28A-BE611531D3F5','F7362703-E517-4A86-9577-14C9C365A3F8')

Update the user passwords (get passwords from connection string files of Sitecore 10.2 vanilla instance) on all the databases using the script below

Alter user UserName with PASSWORD = 'Password', DEFAULT_SCHEMA=[dbo];

With this, databases are migrated from 9.3 to 10.2

Phase 6 – Deployment and Validation

Restart all the web apps in 10.2

Verify Sitecore 10.2 instance is up and running and you can see all the content items from 9.3 in 10.2

Deploy the latest code to 10.2 (using whatever method you use for deployment, E.g, DevOps).

Verify Sitecore 10.2 instance is up and running and you can see all the content items in10.2.

Publish the Site

Rebuild link databases

Clean up databases

Deploy marketing definitions

Rebuild all indexes using index manager

Rebuild XDB indexes in XCSearch WebApp using Kudu

You are all done, your new 10.2 environment is now upgraded from 9.3.

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *