Part 2: Redeploying sitecore without provision infrastructure

In the first part of this series, we provisioned a brand new out-of-the-box Sitecore 9 on Azure PAAS with the help of ARM templates.

Our next step is to make sure, we can redeploy the applications with the help of those templates. Why?

  • We want a clean deployment everytime we add code.
  • We want to get rid of files previously deployed, but no longer in codebase.
  • We want the procedure to be automated and repeatable


Please find the scripts and templates in this zip-file.

Nested Templates

Since Sitecore 9, the ARM templates delivered by Sitecore have been splitted.

There is an azuredeploy.json file on the toplevel making calls to nested template files.

In this “nested” directory, you can find a series of ARM templates starting with “infrastructure” and a series of ARM templates starting with “application”. During our initial provisioning, all these nested templates where called from the toplevel azuredeploy.json template.

The “infrastructure” templates are responsible for creating the necessary resource in Azure. This consists of app service plans, app services, sql servers, databases, application insights for logging and a search service.

The “application” templates provide the actual deployment of the sitecore solution on to these resources. They use the packages downloaded from that contain sitecore and it’s databases.

To redeploy sitecore cm and cd server, we simply need to run the nested/application.json file directly instead of the entire azuroedeploy.json file.

Parameter File

Since we are calling application.json directly, we need to pass some additional parameters. The reason behind this, is that in the original provision, parameters where passed from the infrastructure templates over the azuredeploy template into the application template.

Let’s copy the original file deployment\Environments\Development\azuredeploy.parameters.json to azuredeploy.redeploy.parameters.json and adapt the new file.

Adding additional parameters

There are 2 additional parameters to pass along:

  • SqlServerFqdn
    • This parameter contains the name of the sqlserver created in azure
    • <<deployment-name>>
  • disablePrefetchCachingMsDeployPackageUrl (since sitecore 9.0.1)
    • An additional package delivered by sitecore by default

These additional parameters can be passed along by creating a new parameter file with these extra params, or by passing is directly through the scripts parameters.

Removing obsolete parameters

Our initial parameter file also contains parameters, the application.json template is not expecting, and will give an error on, so we need to remove those parameters:

  • xcRefDataMsDeployPackageUrl
  • xcCollectMsDeployPackageUrl
  • xcSearchMsDeployPackageUrl
  • maOpsMsDeployPackageUrl
  • maRepMsDeployPackageUrl
  • exmCmMsDeployPackageUrl
  • authCertificateBlob
  • authCertificatePassword
  • sitecoreSKU


With our new parameter file in place we can start creating a redeploy script.

This script is exactly the same as the one created to provision our environment, but now calls the application.json template, with the new parameters file.

The download package contains 2 files:

  • scripts/provision-deploy/deploy-xp1-dev.ps1
    • Make sure to adapt these parameters inside the script:
      • $DeploymentId = “OLS-DEV”
      • $SubscriptionId = “your subscription id”
      • $SqlServerFqdn = “[deploymentID]”
    • This script will call the deploy-application function
  • scripts/functions/deploy-application.ps1
    • Make sure to check the install location of AzureToolkit

Run the script to redeploy your sitecore. (but do it on a sandbox environment)

Strip the database

We have now a script to redeploy our sitecore and strip our own code from it. The only issue with this is, that it will also redeploy your databases and thus remove all your sitecore items and data. Obviously, this is not what we want.

In order to prevent this, we need to strip the database setup from the packages provided by sitecore and create new packages without the database setup included.

A script to create such a package can be found in scripts/utilities/strip-db.ps1

All credits for this script go to Rob Habraken.

The script is fairly easy to use:

  1. Open the original scwdp zip package from sitecore
  2. Extract the parameters.xml file from the zip package
  3. Open the strip-db script
    • adapt the location of the scwdb zip file
    • adapt the location of the paramters.xml file
  4. Run the script

Et voila! You have your scwdp zip file without the database reset included.

Upload these new packages to your azure blob storage.

Finaly, we just need to adapt our azuredeploy.redeploy.parameters.json to reference the new scwdp packages.

Next Steps

We can now provision and redeploy our Sitecore 9 in Azure Paas.

Over the next blogposts in this series we will discuss these subject:

3 thoughts on “Part 2: Redeploying sitecore without provision infrastructure

    1. SJ says:

      I downloaded file but couldn’t find nested directory so couldn’t get what is explained after Nested Template

  1. Baxter Lane says:

    Did you ever update your scripts to use the AZ module instead of AzureRM?

    I had to manually do that, to make step one work

    I am on 9.3 though, not 9.0


Leave a Reply to source android Cancel reply

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