Azure PAAS for your Sitecore Dev environment with Power Shell

As I have previously blogged about Sitecore 8.2 on Azure PAAS  I decided that it was arrived the right moment for me to provision my Sitecore Dev environment on an Azure WebApp…

The main reason for doing it is to keep all the environments as similar as possible and deploy my code easily from VisualStudio OnLine and simplify my build & CI pipeline for my Dev environment having a production environment PAAS…

In regard having all the environments as similar as possible,  it could be a bit expensive with a cloud consumption based model…  and you can be tempted, as I have been, to have a much simpler configuration without the Sitecore Analytics in the Dev environment.


My ideal configuration for the Dev environment is as simple as possible to keep the cost down and be able to validate my code, to do that what I really need is just one WebApp to use as CM/CD and the standard SQL databases Master, Core, Web, in addition to this you may consider to keep the Insight Analytics on to monitor the environment and notify if any error occur.

Having played a bit with the Sitecore Azure toolkit and the Sitecore Arm Templates, I realised that any of the scripts was helping me to achieve my ideal Dev environment since all the scripts provision Azure Search and Redis cache provider and so I decided to get hands dirty with PowerShell.

After few attempts to change the scripts, I decided to go for an alternative approach:

  1. Take CM scripts and the CM web deploy packages, pretty standard…
  2. Remove all the Configs that relate to Azure Search in the CM package and repackage the webdeploy and upload on Azure Storage
  3. Make a power shell script to remove: Azure Search, Redis Cache Provider, CD WebApp
  4. Happy days with a cheap Sitecore dev environment running on an Azure WebApp

Changing the CM web deployment package is a trivial task just unzip the CA package and change the configs as you wish, in my case disabling these ones and enabling the equivalent ones for Lucene…

  • Sitecore.ContentSearch.Azure.DefaultIndexConfiguration
  • Sitecore.ContentSearch.Azure.Index.Core
  • Sitecore.ContentSearch.Azure.Index.Master
  • Social/Sitecore.Social.Azure.Index.Master
  • Sitecore.Social.Azure.IndexConfiguration
  • Sitecore.ListManagement.Azure.Index.List
  • Sitecore.ListManagement.Azure.IndexConfiguration
  • Sitecore.Marketing.Azure.Index.Master
  • Sitecore.Marketing.Azure.IndexConfiguration
  • Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Azure.Index.Master
  • Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Azure.IndexConfiguration

In regard the power shell script, it is also very simple since it use just Azure Resource manager commands and it looks like that…


$Name = "DevResGroup";

$redisserviceName = "$Name-redis";		
$searchserviceName = "$Name-as";
$cdserviceName =  "$Name-cd";
$cdPlanserviceName =  "$Name-cd-hp";

 #Deleting Redis Cache
Remove-AzureRmRedisCache -Name $redisserviceName -ResourceGroupName $Name
 #Get Search service and store it in $resource
$resource = Get-AzureRmResource `
    -ResourceType "Microsoft.Search/searchServices" `
    -ResourceGroupName $Name `
    -ResourceName $searchserviceName `
    -ApiVersion 2015-08-19
#Deleting your service will delete all indexes and data in the service
$resource | Remove-AzureRmResource

#Deleting your CD WebApp
Remove-AzureRmWebApp -Name $cdserviceName -ResourceGroupName $Name

#Deleting your CD WebApp Service Plan
Remove-AzureRmAppServicePlan  -Name  $cdPlanserviceName -ResourceGroupName $Name

Sitecore 8.2 on Azure PAAS

As you have probably already heard, Sitecore 8.2 is “finally” fully suporting Azure PAAS

In practical terms since the Update 1 version Sitecore is shipping the full platform on Azure to run in PAAS mode and it is officially supporting it.


New building blocks of your PAAS deployment model will be:

  • Content Delivery servers on Web Apps (Azure App Service) – it means autoscaling + Application Insight
  • Azure Redis Cache for Session State Provider
  • Azure Search as distributed Search Provider
  • XDB – is still not fully supported in native PAAS mode, but you can provision it on MLAB or in IAAS mode on your VM – Note that Document DB x Mongo is not supported
  • SQL Azure – Master -Core-Web + reporting DB
  • Content Management as a different Azure App Service
  • Processing & Reporting as a different Web Apps or consolidated in the CM role

What has drastically changed? – Logs management now it is part of Application Insight, support for Azure Redis for the Session State Provider, Azure Search is now recommended instead of SOLR.

How do I deploy Sitecore on Azure?

Sitecore reccomend you also the Sizes to run Sitecore on PAAS

My personal recommendation having played with it is to go definitively with Update 3 or a following version and not to use the Azure Market Place to provision your production environment.


SQL Azure and Sitecore Retryer

If you are deploying Sitecore on Azure and you are using SQL Azure, you should know that you could experience some connectivity issue between your Sitecore instance and your database…

Therefore it is strongly recommended to enable a retry mechanism on Sitecore data provider to recover these intermittent connectivity issues.

This is the default configuration that you will find in your web config, and what you need to do is to switch disabled to false….

you can either keep the logging enabled/disabled to log these connectivity issues and change the interval setting, but I would recommend to keep the default value…

<retryer disabled="true" type="Sitecore.Data.DataProviders.Retryer, Sitecore.Kernel">
      <param desc="Number of tries">6</param>
      <param desc="Interval between tries">00:00:00.500</param>
      <param desc="Log each exception (should be used for debug only)">true</param>

Sitecore on Azure

When it come to deploy Sitecore on the cloud and more specifically to Azure there are several approaches and alternatives.

The biggest decision is to go with a PAAS or IAAS or decide for an Hybrid approach



In order to deploy Sitecore on PAAS you need to ensure that your license allow you to do it:

There are 2 way to achieve it:

Azure Module

This is recommended if you have to deploy environments across multiple datacenters easily


You can convert your web application in VS to a cloud service in order to deploy it, this guideline explain the steps


  • Less infrastructure (no windows update, security fix etc)
  • Easier to configure Auto Scaling
  • Easier to provision dedicated environments


  • Less control on when an instance got recycled
  • Less knowledge and experience in the team and worldwide
  • Not supporting some of the Sitecore Modules in the market place
  • Increasing the complexity level to monitor the infrastructure


  • Cold deployment, it could be achieved having a staging infrastructure to switch the traffic during the deployment. Having all the CD the same config, you would have only one publishing target.
  • Less control on Indexes
  • Provisioning time of a single instance could take long time
  • Continuous Delivery instrumentation is a bit more difficult
  • Verify if logs can be stored on the Application log or use an azure storage account or custom appender


You deploy Sitecore on Azure VM


  • Allows more complex and tailored deployments scenario
  • Easier to instrument Continuous Delivery
  • Support multiple targets and simplify cold deployments
  • Lower the complexity level of the solution
  • Easier to switch to Amazon / other cloud provider


  • More infrastructure to worry about windows update, security fix etc
  • Provisioning of new environments could take longer
  • Higher overall cost (TBC)


IAAS with SQL AZURE and XDB Cloud

This approach it is an hybrid approach between PAAS and IAAS.

We are envisioning the use of VM for hosting the Sitecore Instances and the use of SQL Azure for the databases and Cloud XDB service for the analytics (a decision if we want to use Sitecore analytics and the best infrastructure to use has still not be taken and it will be considered later on)

Sitecore recommend to deploy the database tier on SQL Azure V12 using Standard or Premium tiers for better performances


  • Allows more complex and tailored deployments
  • Easier to instrument Continuous Delivery
  • Support multiple targets and cold deployments
  • Lower the complexity level of the solution
  • Lower the cost and maintenance of SQL
  • Lower the cost and maintenance of XDB for analytics
  • Easier to switch to Amazon / other cloud provider


  • Still need VM with IIS to deploy Sitecore

Hybrid scenario

It is fairly common an hybrid scenario deployment where CM are hosted on premises / IAAS and the CD servers are hosted as WebApps. The reason for it  is  that generally you don’t need to scale the CM instance.

Hybrid scenario can point the IAAS server to SQL Azure and to XDB cloud as well.


Leveraging sitecore media library with Azure CDN

Using a CDN is an universal best practice to increase the “global” performances of your public web site.

Azure CDN would be the first choice if you are hosting your sitecore site in Azure, but the principles in these article would apply to any other CDN with lazy loading characteristics.

In this post I am assuming that your Sitecore instance it is hosted in Azure as IAAS or as PAAS and that your CDN is in the same instance of the webrole.

My overall goal is to use Azure CDN to cache the static items coming from the media library. In regard of the media library I really like the configuration that comes out of the box storing images on the database, this configuration allow you to use some essential modules like the image cropping one and the Diangoa Image optimizer (

After a bit of research I was able to leverage the Azure CDN on the top of Sitecore MediaLibrary without writing any code but just changing few configuration bits…

The way that my solution work, is the following one:
1) You reference a media library item
2) On CD it points to the CDN url
3) On the first instance, it redirect to
4) It rewrite the url to -/media.ashx?something
5) It cahce the url on the CDN for the following requests

More specifically this is the todolist to acheive it:

1) Configure Azure CDN on the CDN folder of your web role (you can do it from azure management portal)

2) Enable Querystring cache on the Azure CDN endPoint

3) Install the rewrite module for IIS (if your IAAS scenario) and add the following rewrite rule

     <rule name="RewriteIncomingCdnRequest" stopProcessing="true">
          <match url="^cdn/(.*)$"/>
          <action type="Rewrite" url="{R:1}"/>

4) Configure the media Library to support this scenario

<setting name="Media.MediaLinkServerUrl" value="" />
<setting name="MediaResponse.Cacheability" value="public" />


This configuration works well on most of the scenarios, the only case that would not work is the “attach” of a media item, unfortunately there is not a native way to let expire the azure cdn cache and the attached item would be visible when the cdn cache expire….  the simpler way to achieve it is to rename the media item attached, this will force the update of the querystring url….

An other recommended configuration is to change the media library handler from ~/media to -/media anyway this is not mandatory to have the cdn in place..

Hope it helps your Sitecore and Azure experience…