Azure-Windows2016-Native-Docker-And-Sitecore8-Setup

In this blog we will setup Sitecore 8 on a Windows Server 2016 Docker container, some basic understanding of Sitecore, Windows server and Docker is required and will be of certain advantage, but if you do not know much about them it’s ok, you are here to learn. so let’s dive in and get started.

  1. Identify the images and download from Docker HUB.

We need to pull/download the images from Docker hub/registry to begin, an image is an inert, immutable, file that’s essentially a snapshot of a container. Images are created with the build command, and they’ll produce a container when started with run.

I have identified following two images for our Sitecore on Docker.

  1. Microsoft/mssql-server-windows-express
  2. Microsoft/iis

If you are aren’t sure about which image you are looking for then either from command line you can go and search for the image, however https://hub.docker.com/explore/ is the best place to start with.

Since I already know the name of the image, I’ll go and pull it from registry.

Registry: A service responsible for hosting and distributing images. The default registry is the Docker Hub. Repository. A collection of related images (usually providing different versions of the same application or service)

If you would like to search on Docker command line, then you can use the following command and it should provide you with Microsoft images listed on Docker hub.

#docker search Microsoft

           

We will select Microsoft/IIS and proceed to pull the image from Docker registry.

  1. Pull/Download image from Docker Hub/Registry.

 

To build the container we will have to download the image or multiple images in our case, because we will have one IIS web server and a backend SQL server.

For Docker images certain mannerism is followed, so I suggest you visit http://docs.docker.com

Let’s back to downloading image from Docker.

  1. Download IIS Webserver

Note: I had already downloaded that image previously hence it says already exists.

  1. Download Microsoft/mssql-server-windows-express

If you are downloading it for first time, here’s what you’ll see on your screen. The time it takes to download it completely dependent on your bandwidth, if you are running your host machine on any cloud platform then it shouldn’t be a problem in downloading and should not take more than few mins.

Here’s the confirmation on images download.

#docker images

So you can see that we have two images being pulled from Docker Hub a. microsoft/mssql-server-windows-express b. microsoft/iis

We will first work with microsoft/iis, make some required changes and then deploy Sitecore.

Let’s build the container from the image and get going.

  1. Build Container from image (IIS Server)

I’ll show you how to build the container from image shortly, however for better understanding of Docker I’d encourage you spend sometime with Docker help before you go ahead.

#Docker –help (two dashes)

Back to building container.

We will be using following command in Docker to build the container from image.

# docker run –rm –d –p 81:80 microsoft/iis

Options explained:

Run: tells Docker to run a command in new Docker container, so it creates a new container to execute all of the following commands on:

–rm: automatically removes the container after existing it and this is actually very important, otherwise it gets cached (Docker keeps it), it will lock up the name and consequently, you’re filling up the hard drive partition of your host

-d: run container in background and print container ID for information.

-p port:port: bind host port 81 to container port 80 so that we can access container outside container/host as well.

For example: if your host machine is having live IP 1.2.3.4 and you associate your host port 81 to container port 80, then using the following url you can access the site from anywhere on internet.

http://1.2.3.4:81

If your command ran successfully then you should be able to see output something similar to above screenshot, the long alpha numeric character are the container ID. You might need part of it in future use.

Secondly, you can also try to access the site outside your host machine if you wish to using the method explained above (http://1.2.3.4:81). Make sure you have allowed port 81 in your host machine firewall, otherwise it won’t work.

Alright, let’s get back to working with our new container, let’s get couple of windows feature enabled.

  1. Enable Windows Feature for ASP.net

So far we have only downloaded and build our container from image, now we have to go and enable some of the windows feature so as to work with IIS/Asp.net

So as to enable some of the windows feature within Container we will be using PowerShell, here’s the Docker command to get PowerShell extension on container.

Just before that make a note of your container ID, because using the container ID you will be able to run the PowerShell.

#docker ps

Now we will run the Docker command to get Powershell prompt for given container.

# docker exec –it 37a6 PowerShell

Before you start enabling windows feature it’s a good practice to see what’s already enabled and what needs to be, I like doing that, so that I can be sure that my commands are working fine and as per expectation.

#Get-Windowsfeature

Make a note of second column with heading as “Name”, there are two feature down the list (not visible in screenshot) which we will have to enable.

  1. NET-Framework-45-ASPNET
  2. Web-ASP-Net45

With PowerShell it’s quite easy to do so and here’s how it’s done.

#Install-windowsfeature net-framework-45-aspnet

Once started here’s what you will see as your first screen and the last screen shot shows you the confirmation.

Collecting data info.

Starting Installation.

Installation done.

Let’s quickly enable the other feature as well.

#Install-windowsfeature Web-Asp-Net45

In our case it’s already enabled so here’s what we get.

  1. Build Container from image (SQL Server)

So let’s quickly go and run the SQL Container in background, since we have already downloaded the image it should be pretty quick and easy, as we already know how to run the container from image.

# docker run –rm –d –p 1433:1433 –e sa_password=P@ssw0rd1234 –e ACCEPT_EULA=Y microsoft/mssql-server-windows-express

Few changes in this Docker command.

  1. We are exporting port 1433 of SQL Server for both host and container
  2. We are specifying sa password for sql
  3. We are accepting SQL end user license agreement, this is important without which SQL won’t start.

Here’s the interesting part:

To restore the Sitecore databases I do not use the command line, it’s much easier to connect your Sql Server Management Studio to container and easily restore the DB’s.

  1. Connecting SSMS to SQL Container

There are couple of ways you can restore your Sitecore DB’s to SQL container however for the learning purpose or maybe in production too, I find it easier to use SQL Server Management Studio connected to container or host machine.

There are two scenarios that I’ll show you to connect your SQL server management studio to either your container or your host machine.

Scenario 1:

  1. Your host machine is already having SSMS installed and you need to connect to your container from host.
  2. In this case find out the IP address of your container
  3. Ping back and forth between host machine and container
  4. If they are able to talk to each other than point your SSMS to container IP and use SA user/password details to login.
  5. To test connectivity login to container PowerShell and ping.

  1. Server name: IP address of your SQL container, you can find out couple of ways
    1. Connect to your SQL Server using Powershell (Refer to section 4) and run following command and it should let you know the local IP address of your container

# ipconfig

  1. Other method to find out the IP address is using following command

# docker inspect containerID

This command will show you the local IP address of container at the end of the output.

  1. If you are like me and would like to test SQL connectivity from different perspective then you can connect from your host machine IP address.

You can run your SSMS outside your host and point it to your live IP, make sure your firewall is allowing it go through, not a very secure way, nonetheless you can define security methods once you are logged in.

For the purpose of this demonstration, connecting to your Container from host machine is good enough.

Now as such you are connected let’s quickly attach your DB’s so that we are done with our SQL part and can move back to Sitecore setup in IIS Container.

Note: through SSMS server you are connecting to your SQL container which means using SSMS GUI when you try to restore the DB the SSMS will try to restore from SQL Container, it will look for those DBS MDF/LDF there in container, so make you copy db on to that SQL Server.

How to copy the DBs to SQL container ?

Let’s look at step 7 quickly.

  1. Copying DBs to SQL Container

You have to using Docker command to copy DBs from your local host machine to SQL Container so as to attach/restore those DBs.

#docker cp Databases grave_perlman:/c:\

Let’s understand this.

cp: simple copy parameter to pass on

Database: Name of the local folder on host machine which contains all the DBs.

grave:Perlman:/c:\ à grave:Perlman is the name of the container and later part is the path location where you want to copy your database folder.

Now you can go ahead use SSMS and restore the DBs, I am not going to show that part here. Once you have restore the DBs then you can move to step 8:

  1. Cleanup IIS Container.

Before you start copying the Sitecore application, I like getting rid of any default IIS setting/website.

So I’ll quickly run

# remove-website –Name “Default web site”

  1. Deploying Sitecore App to IIS Container.

Alright, so the Sitecore App fun begins here. Let’s copy the application folder to IIS container, create new website and define the permissions in coming few steps. There are other config changes that we will have to make to get the Sitecore up and running.

Let’s go step by step.

  1. Copy Sitecore app folder to inetpub path, not that you have to use this but that’s the default path.

Alright, so let’s understand what’s happening here:

  • My current location is c:\docker\sitecore 8.2\wwwroot
  • I am trying to copy everything wwwroot in current location to IIS container under c:\inetpub\wwwroot\
  • Hence the command #docker cp . jolly_stallman:/c:\inetpub\wwwroot\ will copy everything from my current location to remote location in IIS container.

Now let’s deploy new website in IIS using PowerShell

 #New-Website –Name “Sitecore” –Port 80 –PhyscialPath “C:\inetput\wwwroot” –ApplicationPool “.Net v4.5”

Great, so our application is deployed and if you have done your license file and network path setting correctly in Sitecore.config and Connectionstring.config then you should be able to see Sitecore default page.

#docker run –d –p 81:80 microsoft/iis

  1. There’s all possibility that you might be able to see the default page, might also be able to login to admin but when you try to open the control panel, you’ll come across this error.

In such situation we have to go and check the permission of folder where we have copied our Sitecore application.

So let’s first check, then set the policy and recheck the page for final confirmation.

  1. Go to location where you have deployed your application and run following command

#get-acl

 

  1. Set the permission for Network Service as follows and hopefully it should work for you, if doesn’t then it’s definitely to do with permission only.

$acl = Get-Acl c:\inetpub

$permission = “NETWORK SERVICE”,”FullControl”,”Allow”

$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission

$acl.SetAccessRule($accessRule)

$acl | Set-Acl c:\inetpub

 

 

 

 

Create Azure VM from PowerShell with IIS Web Server auto installed

I saw someone asking on a forum about how to create Azure VM with Windows feature pre-installed, i thought it would be nice weekend exercise to see if i can get a Azure virtual machine created from PowerShell with IIS Web Server auto installed.

Now, by no means, i am saying that the PowerShell script given below is the best way to do it, there could be better, easier and correct way of doing it, but hey … this got my job done, so it should help you as well.

So in below PowerShell script the only thing that you have to change is, replace wherever you see XXXXXX with your cloud service name (the name that appears in Azure cloud service section), i know i can add a variable and make it easier for you, perhaps in next version of script.

so let’s see the script.


#Let's select the VMImage first that we want to use to build Server
$getvmimage = "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201412.01-en.us-127GB.vhd"

# keep some variable handy which we will reuse many times
$user = "webadmin"
$pass = "P@ssw0rd"
$name = "Web60" #####This will be the name of your VM, you can changet if you wish to########

# Create new AzureVMconfig for Web60 and provide it as input to Azureprovisioningconfig and eventually to New-AzureVM
$newvm = New-AzureVMConfig -Name $name -InstanceSize Medium -ImageName $getvmimage | Add-AzureProvisioningConfig -Windows -AdminUsername $user -Password $pass
New-AzureVM -ServiceName XXXXXXXXXXX -VMs $newvm -WaitForBoot -Verbose

#Some Port & Session Variables
$port = Get-AzureEndpoint -Name PowerShell -VM (Get-AzureVM -ServiceName XXXXXXXXXXX -Name $name) | Select -ExpandProperty Port

Write-Host "$port"   ####No real importance, writing it on console only for testing##############

$credential = Get-Credential -Credential $user -Verbose
$sessionoption = New-PSSessionOption -SkipCACheck
$session =  New-PSSession -ComputerName XXXXXXXXX.cloudapp.net -Credential $credential -Port $port -UseSSL -SessionOption $sessionoption -Verbose

$getstatus = Get-AzureVM -ServiceName XXXXXXXXXX -name $name | select InstanceStatus, PowerState -Verbose
if ($getstatus -match "ReadyRole" -and "Started") {Write-Host "Server is Ready, Connecting Now"; Enter-PSSession -Session $session}
else {Write-Host "Unable to Connect, Something Wrong, Try Again"; $getstatus }

#Once PSSession  starts then it should install Webserver Role in remote server
#Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature -IncludeManagementTools -Verbose

Invoke-Command -Session $session  -ScriptBlock {Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature -IncludeManagementTools -Verbose} -Verbose

There are many more stuff that you can do it from this script by making some easy changes, like instead of Web-server you can deploy any other Windows Feature by just making some changes, or you can leave the windows feature about completely and just use the PowerShell remoting to login to remote server and do whatever you want to.

If you come across any bug, or if you know about a better way of doing it, just share in comment.

Till then happy learning.

Hardeep

Remote Desktop Sitecore Azure Instance

Sitecore Azure is built around Windows Azure cloud services (PaaS) and includes automatic deployment of web servers as well as Microsoft SQL databases. So the point to be noted is does Sitecore supports IaaS? Yes Sitecore supports both the flavours of Windows Azure, hence a sitecore solution can be deployed on either PaaS or IaaS. Also Sitecore and Sitecore Azure should be considered as two different entities and that is where it is said that Sitecore Azure Module is built to support (PaaS) and not IaaS.

For comparing SaaS, IaaS and PaaS you might read through my another post here which will give you a fair bit of details about all the three services provided by Windows Azure.

The reason to write this post is How can we enable Remote Desktop Connection(RDC) to a WebRole that is deployed using Sitecore Azure? As Sitecore Azure only supports PaaS which might make us think that we cannot manage IIS or connect to the Virtual Machine(VM) which gets created during sitecore azure deployment. Well I was also under the same thinking that what benefits do sitecore azure comes with, if we cannot look what’s setup has been made behind my sitecore website. I was totally wrong until I figured out a way to connect to the VM.

So let’s see How RDC can be enabled on a webrole instance for a sitecore azure supported website?

RDC can be enabled via Windows Azure Management Portal but considering after a successful deployment of Sitecore.

1) Login to Windows Azure Management Portal

2) Click Cloud Services, click the name of the cloud service (in our case it is SitecoreCloudTestTestSaCe01Role01ScB28), and then click Configure.

Azure Cloud Service

3) Click Remote.

Azure Remote

Warning: All role instances will be restarted when you first enable Remote Desktop and click OK (checkmark). To prevent a reboot, the certificate used to encrypt the password must be installed on the role.

To prevent a restart, install a certificate and then return to this dialog (see Using Remote Desktop with Azure Roles for more information). If you choose an existing certificate, then a configuration update will be sent to all the instances in the role.

4) In Configure Remote Desktop dialog select Role of you sitecore website,

Specify UserName, New Password, Confirm Password, Select Create a new certificate and lastly the date of expiration of this certificate.

Remote Desktop

Once you click , background process will be initiated.

Configuring RDC

5) Windows Azure Portal will notify on successful configuration of RDC.

Success RDC

6) There might be a thought in your mind now what to do after configuring RDC. How can you get a .rdp file to connect to the Remote Session? Read further…

Now click on INSTANCES tab and select CONNECT, this will allow you to download a .rdp file.

Connect EDC

 

RDP Download

7) You now just need to double click and open the .rdp file in order to remotely connect to the VM. Provide UserName and Password.

Login

8) On successful login you can now access the VM.

VM Login
9) You can also check IIS and the sitecore website deployed.

IIS VM

Hope this would have been a nice read for you! Enjoy Sitecore and keep sharing.

 

Sitecore Azure Install Management Certificate Bug

This post, “Sitecore Azure install management certificate bug” contains information and resolution about an installation error received while creating a new environment via Sitecore Azure module. The issue is related to generation of “.publishsettings” file.

One of my colleague Shivam Barve faced this issue while he was trying to have his hands on Sitecore Azure installation. Trying to generate .publishsettings via “Install management certificate”, he was not able to download the file from Install Management certificate dialog.

Sitecore-Azure-PublishSettings

After having his head around with “This page can’t be displayed” error.

Certificate error

I was called in for a helping help. Looking at the error I discovered that the url that is being referred for generation of .publishsetting file was incorrect. It was still using older “https://windows.azure.com” url, but Microsoft has already updated the Azure management portal to “https://manage.windowsazure.com/”. So earlier, for generation of .publishsetting file the url was like “https://windows.azure.com/download/publishprofile.aspx” after new Azure portal it is now https://manage.windowsazure.com/publishsettings/.

I was aware of few knowledge base post for sitecore azure hence visited “Error when installing management certificate for Sitecore Azure” article which explains about two options for generating the .publishsetting file.

Option A did help us generating the .publishsettings file but when we tried uploading it in Sitecore azure we were having “Failed to find certificate in publishsetting file” error.

Sitecore-Azure-Error4

Now the last card that can rescue us was sitecore support, reply from sitecore support (specifically Yuriy Yurkovsky, thanks to him for providing the solution) agreed that it is a bug for the current module version. Microsoft uses a new PublishSettings schema version in new management portal, and this version is incompatible with current module of sitecore azure. For generating .publishsettings file based on old schemaversion we were asked to use the following url.

https://manage.windowsazure.com/PublishSettings/index?client=&schemaVersion=1.0

Bingo!! That did helped us for generating the correct .publishsettings file.

Further googling about the schema version change and comparing the old and new .publishsettings file I discovered the following change.

publishsettings schema2.0

As highlighted in above image the new publishsetting file has an attribute  SchemaVersion=”2.0″. So if your file contains this attribute it will not work with sitecore azure module. The old publishsetting file looks like,

publishsetting schema

Sitecore support now has reported this as a bug and will notify once the bug is resolved. Oh! Are you worried how will you be notified for the issue resolution? I will update this post once the update is released for Sitecore Azure module. Alternatively you can also keep watch on Sitecore Azure Module page at SDN. Till then keep watching this space and keep sharing sitecore knowledge!

Sitecore has now come up with an alternate solution for fixing this issue check the knowledge base article, “Error installing a management certificate in Sitecore Azure when using the 2.0 format of the publish settings file

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