Friday, November 27, 2020

Edit and Update Sitecore Cloud WebDeployment Package using Sitecore Azure Toolkit

Sometimes you will need to adjust the default web deploy packages provided to add new functionality or adjust existing functionality. 


You cannot edit these WebDeploy packages by just extracting.


You have to use "Sitecore Azure Toolkit" PowerShell module to update these packages.


Below I have inserted a script that I used to update existing WebDeploy package with adjusted settings and files.


Most of the content in the internet describing this process is not complete and hard for a beginner to understand.

Following was the only blog post that explained the process that I got the basic idea on what needs to be done.

http://www.chrissulham.com/modify-sitecore-install-framework-packages-for-azure-sql/


Unfortunately that blog page seems not available at the moment. Archive of that blog post can be found from below url.


https://web.archive.org/web/20191102122827/http://www.chrissulham.com/modify-sitecore-install-framework-packages-for-azure-sql/


Preparing Files to Update WebDeploy Package

Following is the structure of my "Sitecore 10.0.0 rev. 004346 (Cloud)_cd.scwdp" folder where I have following files to replace in original WebDeploy package. You can add the changed or new files into "C:\Work\ARMTemplates\Sitecore 10.0 XP Packages\XP\Generated\Sitecore 10.0.0 rev. 004346 (Cloud)_cd.scwdp" folder.


Since I'm only adding a new connection string to ConnectionStrings.config file by capturing the parameters values returned from azure deployment, I only have following two files.


/CopyToRoot/parameters.xml

/CopyToWebsite/App_Config/ConnectionStrings.config





More info on how to organise folder structure inside the new package files can be read from https://doc.sitecore.com/developers/sat/20/sitecore-azure-toolkit/en/the-structure-of-an-sccpl-transformation.html


Import and Running Script

Step 1: Download Sitecore Azure Toolkit

Download and unzip latest "Sitecore Azure Toolkit" from Sitecore to "C:\Work\ARMTemplates\Sitecore Azure Toolkit 2.5.0-r02519.1061" folder.


Step 2: Run following script 

In this script I'm trying to update the default Sitecore 10 XP Cloud WebDeploy package with the changes I did to include some extra connection string to ConnectionString.config file.

Clear-Host


##Import Az Module

Import-Module -Name Az


# This is the location of the local repoitory and will need to be updated to refect the location of where this script # is being run from.

$basePath = "C:\Work\ARMTemplates"


## Configuration

$SCSdkPSM1 = "$basePath\Sitecore Azure Toolkit 2.5.0-r02519.1061\tools\Sitecore.Cloud.Cmdlets.psm1"

$SCSdkDLL = "$basePath\Sitecore Azure Toolkit 2.5.0-r02519.1061\tools\Sitecore.Cloud.Cmdlets.dll"



## Initialize/import the modules

Import-Module $SCSdkPSM1 -Verbose

Import-Module $SCSdkDLL -Verbose



## Payload package generation

New-SCCargoPayload -Path 'C:\Work\ARMTemplates\Sitecore 10.0 XP Packages\XP\Generated\Sitecore 10.0.0 rev. 004346 (Cloud)_cd.scwdp' -Destination 'C:\Work\ARMTemplates\Sitecore 10.0 XP Packages\XP\Generated' -Verbose -Force



## Update WDP package generation

Update-SCWebDeployPackage -CargoPayloadPath 'C:\Work\ARMTemplates\Sitecore 10.0 XP Packages\XP\Generated\Sitecore 10.0.0 rev. 004346 (Cloud)_cd.scwdp.sccpl' -Path 'C:\Work\ARMTemplates\Sitecore 10.0 XP Packages\GeneratingNewWDPPackages\Generated\Sitecore 10.0.0 rev. 004346 (Cloud)_cd.scwdp.zip'



New-SCCargoPayload command will create .sccpl payload package

Update-SCWebDeployPackage command will update the scwdp.zip WebDeploy package



Following is the final results after running the above script

Sitecore 10.0.0 rev. 004346 (Cloud)_cd.scwdp folder             - New/Edited files

Sitecore 10.0.0 rev. 004346 (Cloud)_cd.scwdp.sccpl folder   - Payload package created from New-SCCargoPayload command

Sitecore 10.0.0 rev. 004346 (Cloud)_cd.scwdp.zip folder       - Final WebDeploy package created from Update-SCWebDeployPackage command




Extra Information:

https://www.credera.com/blog/technology-solutions/how-to-deploy-sitecore-to-azure-part-1-environment-setup/
https://doc.sitecore.com/developers/sat/20/sitecore-azure-toolkit/en/web-deploy-packages-for-a-module.html
https://blog.baslijten.com/sitecore-on-azure-create-custom-web-deploy-packages-using-the-sitecore-azure-toolkit/


No comments:

Post a Comment