Jan 23

How to deploy Orchard to Windows Azure using Team Foundation Service TFS

How to Deploy Orchard to Windows Azure using Team Foundation Service TFS and Visual Studio 2012 is quite easy (once you know how ūüėČ If you want to know more about Orchard, I can refer you to this book¬†and Team Foundation Server is nicely explained in Professional Team Foundation Server 2012.

Of course you can also use Visual Studio Team Foundation Server 2012instead of the hosted Microsoft Service.

We assume that:

  • you have a Orchard project that you can publish manually to Windows Azure
  • the TFS workspace¬†folder is C:TFS
  • the project name is Miglia
  • you have an account on Microsoft Team Foundation Service

These are the step on how to deploy Orchard to Windows Azure using Team Foundation Service

Make a modification to the CopyModulesAndThemes.proj

Without some changes to the CopyModulesAndThemes project, I got the error:

error MSB3021: Unable to copy file xxxx to yyyy. Access to the path yyyy is denied.

In the CopyModulesAndThemes.proj file change

<OrchardWebFolder>$(MSBuildProjectDirectory)….Orchard.Web</OrchardWebFolder>
to
    <OrchardWebFolder>$(MSBuildProjectDirectory)Orchard.Web</OrchardWebFolder> 

Check in the project files

  • Copy the Orchard project files¬†to your TFS local project map (C:TFSMIGLIA)
  • Start Visual Studio 2012 as administrator
  • Connect to the Team Foundation Service
  • In the TFS Team Explorer click “Create a New Team Project
  • Fill in the project name (Miglia in this case)
  • After the creation has finished go to Visual Studio and click ‘Connect to a Team Project’
  • Select the project you’ve just created
  • Go to¬†the Source Control Explorer
  • Click on the project name
  • click “Add Items to Folder” and select all Orchard files and maps
  • click Next
  • You must include the library DLL’s now:
    • click Excluded item (approx. 10.443)
    • sort on destination folder
    • click the first file in $/Miglia/lib
    • scroll to the last file in $/Miglia/lib
    • hold the shift key and select the last files (you must have approx 135 files selected)
    • click Include Items
    • click Finish
    • the files will be added now
  • Go to Pending changes in the Team Explorer
  • enter a comment (e.g. Orchard Source files)
  • click Check in (aprox. 6252 items)

Connect TFS project to Windows Azure service

You have to create a Cloud Service so you can connect this service to TFS.

  • Open the Orchard.Azure.sln solution file in VS 2012
  • rightclick on Orchard.Azure.CloudService
  • publish the service and wait for it to finish
  • to go the Windows Azure Managementportal
  • click on the service that you have just created
  • click on ‘Set up TFS publishing”
  • enter the URL of your Team Foundation Service project.
  • click authorize now
  • click accept
  • select the right project and click ‚ąö

Create the Build Definition and start the Build process

  • In Visual Studio go to Team Explorer -> Build
  • rightclick the Build Definition miglia_CD (in my case miglia)
  • edit Build Definition
  • Enable the build definition (click Enabled)
  • click process
  • Set Solution To Build to Orchard.Azure.sln (in $Miglia/src/Orchard.Azure)
  • close and save the settings
  • rightclick the build in the Team Explorer
  • click Queue New Build to start building
  • after 20-30 minutes your Cloud Service is fully deployed to Windows Azure.

And this is how to Deploy Orchard to Windows Azure using Team Foundation Service

Jan 11

How to publish Orchard to Windows Azure using Visual Studio 2012

I ran into several issues running Orchard 1.6 CMS in Windows Azure. So it‚Äôs time to document my achievements on how to publish Orchard to Windows Azure using Visual Studio 2012. I hope everyone can benefit from it. I¬īm assuming you have knowledge of Windows Azure. If not, check the Windows Azure .NET developer center

Follow these steps to install Orchard in Windows Azure:

Download and unzip Orchard source code

Download the OrchardSource.1.6.zip file from the Orchard Codeplex project. Extract the files to a directory on your local drive.

Download the Azure SDK

Install the Microsoft Web Platform Installer 4.0

  • Start the MSWPI
  • add the Windows Azure SDK for .NET (VS2012 SP1) 1.7.1 – june 2012 SP1

Run the ClickToBuildAzurePackage.cmd

You need to run the ClickToBuildAzurePackage.cmd file. It is located in the root of the Orchard project:

  • Open the Developer Command prompt for VS2012 from your Windows start menu (or Windows 8 tiles)
  • Run the command prompt as administrator (right click the icon)
  • go to the root of your Orchard project
  • type ClickToBuildAzurePackage.cmd

The script wil run for 1-2 minutes, depending on your systems.

Get your storage credentials

  • Sign in at the Windows Azure Dashboard
  • Create a storage account
    • click on +NEW at the bottom left
    • Data Services -> Storage – Quick create
    • Enter the details
    • Click: create storage account
  • Wait for the account to be created and click on the account when it becomes available
  • Click on Manage keys (bottom center)
  • Note the primary access key

Enter the Azure credentials

  • Edit srcOrchard.Azure.Orchard.Azure.CloudServerServiceConfiguration.cscfg
  • change the setting DataConnectionString line to:
    • <Setting name=”DataConnectionString” value=”DefaultEndpointsProtocol=https;AccountName=your-account-name;AccountKey=your-account-key” />
    • replace accountname and account key with your own values
    • replace UseDevelopmentStorage with your primary access key

Change the project file

Open srcOrchard.AzureOrchard.Azure.WebOrchard.Azure.Web.csproj in notepad. Add the following lines after an ItemGroup:

<ItemGroup> <Content Include=”Themes***”¬† <Exclude=”**bin***;**obj***;***.user” /> <Content Include=”Core***”¬†¬†¬† <Exclude=”**bin***;**obj***;***.user” /> <Content Include=”Modules***” <Exclude=”**bin***;**obj***;***.user” />
<ItemGroup>

This should mitigate the HTTP error 500 Internal Server Error issue.

Save the file.

Publish to Windows Azure

Rightclick the Orchard.Azure.CloudService project. Select publish to publish Orchard on Windows Azure. (I assume that knowledge). In order to run Orchard, you must have a database ready (you can use SQL Azure).

You now have a working Orchard on Windows Azure.

More information can be found on the Orchard website or Ooiks’s Blog