Continuing our exploration of Sitecore as PaaS based on Azure Web App services, I wanted to talk how to integrate the CI/CD part in this blog, and specifically the Deployment part.
Currently in our On-Premise setup, we have been using Bitbucket (Code repositoty) + Jenkins (CI) + Proget (Package repository) + Octopus Deploy (for deploying Code and Sitecore items). Sitecore items were deployed triggering TDS services on Sitecore server through Octopus tentacle.
While exploring Sitecore on Azure PaaS services, we wanted to minimize the changes to the CI/CD pipeline as it has been in a matured state. All the above mentioned CI/CD tools are going to be deployed as IaaS setup. As part of this did not see any challenges for any of these tools how they used to work in On-Premise vs on Cloud with Azure PaaS, except with Octopus Deploy. In the case of Azure Web Apps – there is no concept of Octopus tentacles, but Octopus provides in-built support for deployment to Azure Web App. This will help in our code deployment (binaries, configuration), but I was looking for solution for deployment of Sitecore Items (primarily through Sitecore update package). I did not find any straight forward solution on this, while found some instances of Octopus + Unicorn based deployment. But we wanted to stick to our current packaging setup and way of deploying Sitecore items. Towards this I stitched together a solution and below steps provides some details around that.
- As first step to use Octopus to Deploy to Azure Web App, we need to configure the Azure Account in Octopus as explained here. I used Service Principal account based configuration in this case.
- As a next step Create the Environment in Octopus
- Create Project in Octopus
- Then Create the Azure Web App deployment step as explained from step 3
- Pick the Sitecore items package (Sitecore items update package, packaged in a Nuget package) that you need to deploy
- Pick your Azure Account and Azure Web App to where the package need to be deployed
- Now with this steps so far when it gets executed, it will deploy the Nuget package tp the Sitecore setup, and extracts the Sitecore update package to the specific folder you specified. Now the challenge is how do we install this package on Sitecore. In the On-premise case, we trigger the TDS service on the target Sitecore server through Octopus tentacle, but there is no such option here. So I was exploring the alternate way to trigger the Update installation package on Sitecore setup. Fortunately on this TDS had provided an alternate way. In this case we can deploy a Sitecore update items package to specific folder and then trigger the StartSitecorePackageDeployer.aspx, which will then then pick the package and installs it.
- Note: By default when we install this TDS Package deployer, the StartSitecorePackageDeployer.aspx gets installed in /sitecore/admin folder which while we can access fine without login in On-premise, in Web Apps scenario this will prompt for Sitecore login, hence we need to move this aspx to website root folder
- Now that we have TDS service (StartSitecorePackageDeployer.aspx) which we can trigger to install the Sitecore update items package, next question is how can trigger this from Octopus. The option is of course to use PowerShell script. We can remotely trigger this using Invoke-WebRequest PowerShell command. This will successfully install the update item package the on the target Sitecore server.
- In some cases you might want do some additional processing after the installation of items package, like you might want to read the status of the log generated by StartSitecorePackageDeployer and do some processing. In this case the PowerShell will need to triggered on the Sitecore server itself and not remotely. With On-premise setup this is feasible as with Octopus tentacle we can execute the PowerShell command on the target server, However with no tentacle option, the script is triggered on the Octopus server and not the target server
- In this case option is use to Azure Web Jobs. We can create Azure Web Job like following steps mentioned here
- We can then trigger this Web Job from Octopus using PowerShell like below
Get-AzureRmSubscription -SubscriptionId $SubbscriptionsId | Select-AzureRmSubscription Invoke-AzureRmResourceAction -ResourceGroupName $ResourceGroupName -ResourceType microsoft.web/sites/TriggeredWebJobs -ResourceName $SiteName/$WebJobName -Action run -ApiVersion $Apiversion -Force
I will continue share my further exploration of Sitecore setup on Azure PaaS.