Sitecore mobile website – Separate content tree structure part 2

This post is Part 2 of the series for sharing information about sitecore mobile implementation where the content is not shared with other sites for e.g. desktop site and mobile site have different content architecture. The requirements for the implementation can be,

–          Content is different between mobile site (http://m.mysite.com/) and desktop site (http://mysite.com/).

–          Few pages might share the content from other site.

–          Sub-domain should be used for mobile site for e.g http://m.mysite.com/

Information about mobile device, layouts, sublayouts etc is covered in Sitecore mobile website – Shared content tree structure – Part -1

Content Tree

A new website can be defined for mobile site which will hold all pages and content.

sitecore mobile site - Separate - 1

Sharing content

There might be a requirement for few pages to derive their content from other site, in such scenario Cloning can be used. More details about cloning can be found at Content Author’s Reference and Cookbook

Web.config

Now define a new website in web.config file to map you mobile site content to m.mydomain.com. Refer to the section for web.config file in part-1.

Sitecore Azure – Kick Off

Recently I have a chance to work on Sitecore Azure, in this post I will share my experience with Sitecore Azure, pre-requisites for sitecore azure, installing sitecore azure, errors faced during installation and deployment of sitecore azure & their resolutions. So this post will help you to get started with Sitecore Azure.

As a novice I started to understand Windows Azure terms which I have now recorded at Comparison SaaS, IaaS and PaaS.

This post considers integration of Sitecore 7.2 and Sitecore Azure 7.2.

Compatibility

Below table gives an insight for various Sitecore Azure module versions compatibility with various Sitecore versions.

Sitecore-Azure-Compatibility

Installation and documentation sources

In order to download the package for Sitecore Azure you need to be a Sitecore certified developer and registered with Sitecore Developer Network.

Pre-requisites

Before proceeding with installation of Sitecore Azure you will need to have few pre-requisites. The list is as below,

1)      Windows Azure Authoring Tools

2)      Windows Azure Libs for .Net

3)      Windows Azure Storage Tools

4)      Windows Azure Emulator

Above list of files comes in different versions and you should download the correct version of files as per requirement of  Sitecore Azure ,

–          Windows Azure SDK for .NET – 2.2

–          Windows Azure SDK for .NET – October 2012

–          Windows Azure SDK for .NET – June 2012

5)      .Net framework 4 or higher

6)      Azure Account: I used 30 days free trial version, visit here to register and enjoy windows azure.

Environment File: Sitecore provides this file, visit here to get this file. Sitecore needs few details as can be seen in below screen shots. Sitecore states that it will take 48 hours for sending this file, but my experience was i received it in less than 12 hours.

Sitecore-Azure-Environment-1

Sitecore-Azure-Environment-2

Download links

–          Installation package: Sitecore Azure

–          Documentation: Getting Started with Sitecore Azure

Installation Steps

Sitecore Azure is available as a standard sitecore package and can be installed using Installation Wizard. I will skip installation step in this post as it has been explained nicely in Getting Started with Sitecore Azure. Also there is a really very nice blog Instantiating Your First Sitecore Azure Site written by Cameron Palmer.

Once package installation is over you can open Sitecore Azure dashboard from Sitecore Desktop and it looks like,

Sitecore-Azure-LocalEmulator-1

Initially you will see only “Local Emulator” in the Environment Type drop down. Hence first step is to upload Environment file that you have received from Sitecore. Click on “Add” to upload it.

Sitecore-Azure-Environment-Upload

Now you can see other environments in the drop down.

Sitecore-Azure-Environments

Moving ahead you can either configure Local Emulator or deploy your sitecore solution to Staging or Production environments.

Deploying to Local Emulator

I started with local emulator so that I can test my deployment locally on my machine after which only I should go for staging or production deployment.

You can create Content Editing and Content Delivery environments from the Sitecore Azure dashboard by clicking the gray dot. The dot color indicates deployment status for that environment. Below is a direct extract for explaining color from the Getting Started with Sitecore Azure

Dot-GrayGray Circle: Unused. You can create a content delivery farm.

Dot-GreenGreen Circle: Started. You can access this content delivery farm over the internet.

Dot-RedRed Circle: Suspended. You can start this content delivery farm.

Dot-BlueBlue Circle: Farm created but not deployed.

Hour-GlassHourglass: Busy. Sitecore Azure is attempting to start, suspend, delete, or otherwise administer the location, or the current operation for the location is queued.

Sitecore-Azure-LocalEmulator-2

Next you will have to define

1)      Number of Instances: For local emulator, number of instances specified will create those many website in IIS. In your Microsoft Azure account it will create that many number of web roles.

2)      Size of the VM: VM Size will not matter for local emulator.

3)      Share database for production and Staging slot:The option itself says it can be used to share databases between production and staging. If you have chosen this option and deployed sitecore on staging, now when you go for production deployment you will see below screen which will be prompted for all three databases (master, web and core)

Shared Database

4)      Publishing mode: You need to run a publish operation.

5)      Live mode: Live mode causes changes in the content editing farm to be immediately available on the frontend of the web site.

6)      More options: It takes you to sitecore content tree where in you can change few settings and
configurations like instance name, database size etc..

More-Options

After selecting the options best suited for your environment click on “Start deployment”.

Sitecore-Azure-LocalEmulator-3

After successful deployment on local emulator to run the emulator execute Run.bat file with administrator privileges.

Sitecore-Azure-LocalEmulator-4

Sitecore Azure dumps the deployed package at a path specified in the “Build Folder field. By default it has “$(dataFolder)/AzurePackages” value. I was forced to change this value to “c:\s” due to an error that occurred during deploying to local emulator. The error is mentioned in detail in the Error & Resolutions section of this post.

Sitecore-Azure-BuildFolder

Alternatively you can execute Run.bat from a folder location as specified in the “Build Folder” field.

Sitecore-Azure-RunBat

Also for each deployment carried out it creates a new folder “DevFabric” and prefixes it with the deployment number.

Below are few screen shots after you execute Run.bat

Sitecore-Azure-LocalEmulator-5

Sitecore-Azure-LocalEmulator-6

Below are the two instances created which were specified during environment creation.

Sitecore-Azure-LocalInstances

Deploying to Azure Environment

For deploying to Windows Azure, you can select staging or production environment from the Environment Type drop down.

Sitecore-Azure-ProdDeployment

In my case I already have Content Editing deployed hence it is disabled. On clicking “Add Delivery Farm” it will ask for uploading a .publishsettings file.

Sitecore-Azure-PublishSettings

Click on “link” which will generate the .publishsettings files. You will see below screen where it cannot display content, so you have to follow “Open this content in a new window” link.

Sitecore-Azure-PublishSettings-1

It takes us to manage.windowsazure.com and once the file generation is complete it will download the file as well save the file and upload it to Install management certificate.

Sitecore-Azure-PublishSettings-2

Before you start with the deployment to azure environment I would recommend to make few changes in Sitecore.

1)      DNS Host Name

Sitecore-Azure-DNSHostName

Sitecore uses the value from DNS Host Name field to define your cloud service name and the url of you app.

For e.g. in my case provided the value as “hiscazureplay-ceprod” hence my cloud service was named  “hiscazureplay-ceprod” and the url is http://hiscazureplay-ceprod.cloudapp.net/

If this field is left blank it will create lengthy service name containing project name + Environment + Location + Content Delivery or Editing + Role.

For e.g SCAzurePOCDevEusCd01Role01Sc8c8

Sitecore-Azure-DNSHostName-1

Sitecore-Azure-DNSHostName-2

2)      Database size

By default sitecore azure creates master, core and web databases of size 150 GB on cloud which might not be necessary also this can be scaled later when the size of databases actually grows.

Sitecore-Azure-DatabaseSize

I made the changes to the size of the database at “/sitecore/templates/Azure/Databases/Azure SQL Database/__Standard Values

Sitecore-Azure-DatabaseSize-1

However if you still forget to change the database size you can change it from the azure dashboard after the deployment is complete.

Sitecore-Azure-DatabaseSize-2

Sitecore-Azure-DatabaseSize-4

Sitecore-Azure-DatabaseSize-4

Now you can switch back to sitecore azure dashboard and define the environment details and go for “Start deployment”, sit back and wait till the deployment on Azure get completed it took about one hour for the deployment to get completed. Side by side you can track the progress of deployment by visiting Azure Dashboard or the log screen. The databases are created at firstly and then a cloud service.

Sitecore-Azure-SQLDBs

Sitecore-Azure-CloudService

Errors & Resolutions

This section will describe few of the errors we faced with Sitecore Azure.

1) The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

C:\Websites\Sitecore\hiscazureplay\Data\AzurePackages\(0) DevFabric\DevFabricLCe01Role01ScBaf20140707052333.cspkg\roles\SitecoreWebRole\approot… UCPack_Command_Line: Error : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. at Sitecore.Diagnostics.Assert.IsFalse(Boolean condition, String message) at Sitecore.Azure.Pipelines.CreateAzurePackage.Azure.ExecutePackage.Action(RolePipelineArgsBase arguments) at Sitecore.Azure.Pipelines.BasePipeline.RolePipelineProcessor.Process(RolePipelineArgsBase args)

You will face this error when you are deploying on local emulator and “Build Folder” field value is not short enough. To resolve this error specify the shortest path you can.

2) Cannot load imported module named ‘Caching.’ Or Azure SDK must be v2.2

35DevFabricLCe01Role01PScBafProduction [P] Create package failed System.ApplicationException: DevFabricLCe01Role01PScBafProduction [P] Create package failed —> System.ApplicationException: Create package is failed —> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.InvalidOperationException: Build Package failed: Searching for imported module Diagnostics at C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.2\bin\plugins\Diagnostics\Diagnostics.csplugin… Searching for imported module Caching at C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.2\bin\plugins\Caching\Caching.csplugin… Searching for imported module Caching at C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.2\bin\plugins\Caching\Caching.csmod… UCPack_Command_Line: Error : CloudServices58 : Cannot load imported module named ‘Caching.’ Copying ‘C:\Websites\Sitecore\hiscazureplay\Data\AzurePackages\(0) DevFabric\SitecoreWebSite’ to C:\Websites\Sitecore\hiscazureplay\Data\AzurePackages\(0)”

Above error is encountered when your machine do not have correct version of Azure SDK tools. The correct version of SDK are mentioned in Pre-requisites section of this post.

Sitecore-Azure-Error2

Sitecore-Azure-Error2-1

3) Cannot move or create server. Subscription ‘xxx-xxx-xx’ will exceed server quota

37SitecoreCloudTestTestEaCe01Role01PScB28Production Sitecore.Azure.Pipelines.Automation.Azure.SqlAzureDatabaseServer failed System.ApplicationException: SitecoreCloudTestTestEaCe01Role01PScB28Production [P] Sitecore.Azure.Pipelines.Automation.Azure.SqlAzureDatabaseServer failed —> System.ApplicationException: Sitecore.Azure.Pipelines.Automation.Azure.SqlAzureDatabaseServer is failed —> System.Net.WebException: REST REQUEST FAILED : Request: https://management.database.windows.net:8443/b28e3bd6-097d-443c-9c87-c1041d0ab1db/servers Server response = 40652 Cannot move or create server. Subscription ‘b28e3bd6-097d-443c-9c87-c1041d0ab1db’ will exceed server quota. 16 1  —> System.Net.WebException: The remote server returned an error: (400) Bad Request. at Sitecore.Azure.Managers.HttpGatewayManager.GetHttpResponse(String uri, String httpMethod, String versionXMsVersion, String body) — End of inner exception stack trace — at Sitecore.Azure.Managers.HttpGatewayManager.GetHttpResponse(String uri, String httpMethod, String versionXMsVersion, String body) at Sitecore.Azure.Providers.AzureSQL.AzureSqlProvider.CreateDataBaseServer(String subscriptionID, String location, String userID, String password) at Sitecore.Azure.Managers.AzureManagers.AzureSqlManager.CreateDataBaseServer(String subscriptionID, AzureSqlDatabase database, String login, String password) at Sitecore.Azure.Managers.AzureManagers.AzureSqlManager.CreateDataBaseServer(AzureSqlDatabase azureSqlDatabase, String login, String password) at Sitecore.Azure.Pipelines.Automation.Azure.SqlAzureDatabaseServer.ResolveServer(AzureSqlDatabase azureSqlDb, List`1 resolvedServers, Dictionary`2 preferServer, String contextLanguage) at Sitecore.Azure.Pipelines.Automation.Azure.SqlAzureDatabaseServer.Action(RolePipelineArgsBase args) at Sitecore.Azure.Pipelines.BasePipeline.RolePipelineProcessor.Process(RolePipelineArgsBase args) — End of inner exception stack trace

Our Azure subscription had a limit of creating only 6 SQL servers which was getting violated when we started with the deployment. Hence we deleted the unwanted SQL servers from Azure Dashboard.

Sitecore-Azure-Error3

4) Failed to find certificate in publishsettings file.

Sitecore-Azure-Error4

This was because of using invalid publishsetting file that was downloaded from Azure dashboard. Try generating a new publishsettings file.

5) The database ‘{0}’ already exists

The error message is a little bit misleading. I encountered this error message when I was deploying sitecore to production environment. I already had deployed my staging environment and used the option to share the database between staging and production. I was like why should it give error as I have already selected the databases to be shared. However when I ran through the log files the error was something different.

The actual error was,

“ManagedPoolThread #0 12:24:44 ERROR Exception processing remote events from database: SCAzurePOCDevSaCe01Sql01Set01Sc8c8web_ix88tkg0j5
Exception: System.Data.SqlClient.SqlException
Message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.”

I would admit that it was me who invited this error. I tried deploying Sitecore on Azure few times and when I was done I removed the databases from my Azure account however the reference to the databases still exists. So removing the references of the Azure databases from “\App_Config\connectionstrings.config” and “\App_Config\Include\Sitecore.Azure.config” resolved my issue. After this I was able to deploy sitecore on production even if the database was shared with staging.

New learnings and tasks always needs a helping hand to overcome the issue and errors, thanks to Nikki Punjabi to work with me and also allowing me to use his Windows Azure subscription.

Nice To Read

Sitecore Azure Walkthrough by Sohel Siddique

Sitecore in Windows Azure by Parshva Vora

Why we love Sitecore on Azure by Jakob Leander