Sitecore on Azure… With Unicorn

I’ve been trying to get our internal demo website running on Azure, and have it deployable in a very easy manner. Provisioning Sitecore onto Azure is really easy these days, and the code itself is also easily deployed to my environments (see these previous posts for more information).

The issue I was having was with Unicorn – or more specifically the locations of my data folder. On my local machine, I have Sitecore running in a specific location, and can simply point my Unicorn to a specific location on my machine (i.e. c:\development\demo\data\unicorn). Since all my colleagues working on the projects have the same file structure and we never have to deploy to an actual server that works perfectly.

However, I’m now adding a new deployment server to the mix, with a different file structure. I can’t simply use the same path as it might not exist there. I also can’t use the $(dataFolder) option that Unicorn provides since I don’t work in the Webroot as I have my Unicorned items in source control in that specific location – the actual demo site datafolder lives on c:\sites\demo\data in my case.

SlowCheetah to the rescue! I wrote about SlowCheetah earlier as well, and could actually create a pretty simple transformation: All I had to do was add a Transform to the Unicorn.config file in Visual Studio, to rewrite the data folder path.

addtransform

For each of my transforms (in my case I just use one CM and one CD, but it’ll work for multiple other deploy targets) I’d put in the XML transformation:

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
 see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <sitecore>
    <unicorn>
      <defaults>
        <targetDataStore physicalRootPath="$(dataFolder)\Unicorn\$(configurationName)" useDataCache="false" type="Rainbow.Storage.SerializationFileSystemDataStore, Rainbow" singleInstance="true" xdt:Transform="Replace" xdt:Locator="Match(type)"/>
      </defaults>
    </unicorn>
  </sitecore>
</configuration>

Because I use the Publish way of deploying my code, I do need to make sure the Unicorn files get deployed as well, so I have to include all my .yml files in my solution (not just source control).

However, after this it just… works :-).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s