Since Document DB started supporting Mongo's protocol I was wondering if we could have Sitecore running on Document DB. And today I managed to get it running. It threw a couple of exceptions the first time, but since then I don't see any error and, apparently, everything is working fine (of course, I haven't tested it thoroughly).

The first step is creating the database as a service for Mongo on Azure

Go to the portal and click on New
Filter by "mongo"
Select Database as a service for MongoDB
Fill in your details for name, subscription, resource group and location

Create the required databases

Select the Resource you've just created. On the overview tab, you can only find the option to add collections. We don't need to create each of the collections, Sitecore will do it for use, but what we have to do is create the database.
Go to the "Browse" section. Now you will see the option to "create database" on the top of the new blade. Create 4 new databases:
  • Analytics
  • Tracking_live
  • Tracking_History
  • Tracking_contact

  • Add database to documentdb

Update the connection stringsGet the connection string from Azure

Select the connection string option, from the settings section. Then copy the connection string from the bottom of the new blade

DocumentDB connection string

Replace your connection strings

Open your connection string file: ...Website\App_Config\ConnectionStrings.config
Replace the connectionString for the connection analytics with the value you just copied from the portal. You will notice that this connection string is missing the database. To include the database, find the text "/?ssl=true" at the end of the string. We have to include the database after the "/". It should look like this: "xxxxxx/analytics?ssl=true";
Do the same for the other 3 databases.
Save the file.
Sitecore will re-start, but will throw errors like "Unable to connect to server Authentication failed because the remote party has closed the transport stream". This is because the mongo provider is not using configuring SSL correctly. We are lucky, Sitecore gives us the opportunity to set up the driver, before it uses it.

Set up Mongo Provider to use SSL "properly"

You can follow these two links to implement your own solution or you can use mine from here.
Just drop this dll in the bin folder, and this config file in the app_settings/include folder
That's it. Now your Sitecore will connect to DocumentDB and will start creating the required collections.
DocumentDB with support for mongo is still in preview, and this provider is not supported by Sitecore, so You shouldn't use it for production environments but if you are "playing" with Sitecore on Azure and you want to keep everything in Azure as Sitecore is doing with 8.2.1 supporting Azure webapps, Azure search, Azure Redis cache, etc. with this trick, you can now use DocumentDB to store your collection database.

Please get in touch with us if you find any errors using DocumentDB.

Author bio

Vicent Galiana
Vicent Galiana
Solutions Architect
Putting blocks together to make things easier, creating those missing clever parts which make it possible. That's my passion, that's my hobby, that's my job. It's about keeping up to date with current tools, and figuring out how to glue them together to solve client's challenges.


comments powered by Disqus

Related Articles

Sign up to our ClearThought newsletter

Get inspired and learn something new by subscribing to our FREE newsletter. It’s full of ClearPeople's thought-leadership whitepapers, blogs, events, and much more. We promise to not use your email for spam.

Closing this message and/or accessing our website tells us you are happy to receive all cookies on the ClearPeople website.
However, if you would like to, you can change your cookies settings at any time.