Awesome latest generation 4 data centre for Microsoft’s cloud services

Microsoft don’t active talk about their datacentres especially what they have running inside. Even the team managing the centres known as Microsoft Global Foundation Services (but they have their own website!) doesn’t get much limelight for themself. But today I found out Dave Aiken has a blog post with a couple of videos on what is powering our Windows Azure instances.

Below is a video showing the inside of datacentres running not just Windows Azure but also the more familiar Windows Live (aka Hotmail), Office 365 and XBox Live. Also shown the Dublin datacentre running latest Generation 4 modular datacentre.

 

Grab more videos here http://www.davidaiken.com/2011/10/07/our-datacenters-are-awesomeness-in-a-box/

A friendly reminder from Microsoft Online Services

I used my company’s MSDN subscription to sign up for Windows Azure’s MSDN offer. Basically I was allocated 750 hours of extra small compute for the first 6 months of my sign up. Even now that the offer is over, and I am paying the full price whenever I use Azure, Microsoft Online Service (which manages the billing) still send me a reminder of my so called exceed usage. Smile Below is a screen clip taken from my email client.

azureover

What all this means is if you accidentally exceeded your usage, you have better delete your instance if it is only used for testing. Do not shutdown the instance below it will still incur charges.

How to try out Windows Azure at minimal cost?

There are a couple of way for you to try out Windows Azure with almost ZERO cost. Microsoft gives out offers and trial account with certain resources allocation. Below are your options

1. Windows Azure 90 day trial (http://www.microsoft.com/windowsazure/free-trial/)

You will be allocation the following monthly resources for up to 30 months

Compute: 750 hours of a Small Compute Instance
Storage: 20GB with 50k Storage transactions
Data Transfers: 20GB out / Unlimited inbound data transfer
Relational Database: 1G Web Edition SQL Azure database
Access Control: 100,000 transactions
Service Bus: 2 connections
AppFabric Caching: 128MB cache**

2. If you have MSDN subscription, it comes with allocation of Windows Azure resources based on your subscription model with savings of up to USD3,500. Check out this website for more information http://www.microsoft.com/windowsazure/msdn-benefits/

3. When you sign up for Windows Azure training at any Microsoft certified training centres, you will be given free Windows Azure access for a certain number of days.

4. 30 day Windows Azure pass (http://windowsazurepass.com/) is the special promo where you get access to Windows Azure for 1 month without even using your credit card (refer below). However, you have have exceeded your allocations, your application will ceased to function as there is no way Microsoft can charge you. This is a special pass where is it only available at certain Microsoft’s events or occasions. The promo code can only be used once and it is tied to your Windows Live (aka Hotmail) ID.

Options 1 to 2 requires your card info so you will be billed when you exceeded your allocations. So you have to be cautioned especially on the bandwidth usages.

Hello Orchard – Creating a Orchard module using latest source code

What is Orchard?

Project Orchard is the latest open source CMS project by folks in Microsoft based on ASP.NET MVC platform. It has some relationship with project Oxite which is another CMS used by the MIX event website. You can read more about Orchard from the official website here. And you can also check out the official download as well as the latest build from Codeplex. It is light weight where you can do copy-paste deployment onto shared webhosting, doesn’t require SQL Server to run yet at the same time you can add functionalities as a Orchard Module.

 

Official Download

The official download dates back to March 2010 at the time of MIX 2010. The feature sets are primitive and less composite than what’s in the roadmap. It has been 4 months since the release and the team will release a official Alpha release by end of July 2010.

Having said that, the March release comes with a walkthrough which you can follow to build a customized module for Orchard. You can check out the walkthrough here.

March 2010 release

Walkthrough Document

Video walkthrough

Latest Build

In the true spirit of open source, the Orchard team chose Mercurial instead of Team Foundation Server to be the source code host of the project. Codeplex supports both source control systems maybe because of some non-.NET or non-Windows hosted there.

In the March 2010 release Modules are actually ASP.NET MVC 2 Area where else in the latest build, they are individual ASP.NET MVC Web App. The new module design makes Orchard more suitable for composition and multi tenancy, in a way like SharePoint features.

Because of this architecture change, the walkthrough mentioned above does not work with the latest build. So in this and subsequent blog post, I will share more about creating a customized module for latest build of Orchard

Downloading latest build

To get the latest build, you either download from the source tree using TortoiseHG which is a Windows based Mercurial client (instructions here) or you can download the latest changeset from the source code page at Codeplex.

image

Whenever you download source code packages as a zip file from the Web, remember to ‘unblock’ it from the file property page else Visual Studio will give you a not trusted source warning message which can be annoying at times.

image

 

Understand the Orchard architecture

I won’t dwell too deep into this as Bertrand Le Roy wrote an extensive document titled How Orchard Works here. Architects should read this document first to understand how things work.

Accessing the latest change set

image

I downloaded the latest change set as of today and from Windows Explorer you will notice there are 2 Visual Studio solution file. Note also that it has been updated to support Visual Studio 2010 solution. You also note that there is a Windows Azure solution file here but let’s check this out in my future post.

The whole Orchard application framework is inside the Orchard folder while Orchard.Web is the ASP.NET project which can be hosted inside IIS. Let’s open up Orcahrd.sln using VS2010.

image[15]

All in all there are more than 30 projects in project Orchard with Orchard.Core, Orchard.Framework and Orchard.Web at the center of this CMS. On top of that there are some core modules which Orchard needs such as the User, Pages, and Setup modules.

Build and setup a sample site

Orchard supports both SQL Server and SQLite database but for sake of debugging and troubleshooting I will choose SQL Server. Let’s create an empty database inside SQL Server called OrchardTutorialDB in the local SQL Express instance.

image

Back to Visual Studio 2010 with the project opened, press Ctrl-F5. IE will be opened and you will see the Orchard setup page

image

At this page, you need to give a name for the website and assign a website admin account. Then click on ‘Use an existing SQL Server database’ to setup SQL Server. Key in the connection string in the following format

Data Source=.\sqlexpress;Initial Catalog=OrchardTutorialDB ;User Id=myUsername;Password=myPassword;

Note: Skip and leave the Database Table Prefix empty at the moment because of a known bug with using the prefix

image

Click ‘Finish Setup’ and a few minutes later you will see the website up and running!

image

I will normally change my theme to a more presentable one.

image

Hello Orchard – Adding a new Module

Note: from this point onwards I will reuse some of the text in the Orchard Walkthrough document.

NOTE: Step 2 to 4 and 15 to 17 are very additional steps to make the walkthrough works in the new change set.

The objective here is to build a very simply Hello World style webpage themed by Orchard with a menu item on top.

Objectives:

1. A simple custom area that renders “Hello World” on the app’s front-end

2. Views in the custom area that take advantage of the currently applied Orchard theme

3. A menu item on the front-end for navigating to the custom area’s view

Follow These Steps:

1. Right-click the Modules node in VS Solution Explorer, and choose “Add > New Project…”

image

2. In the project creation screen, choose “ASP.NET MVC 2.0 Empty Web Application”

<Very Important> On the path text box, it is default to <Orchard location>\src folder. Change it to <Orchard location>\src\Orchard.Web\Modules\ folder (Screenshot below). Else Orchard will not recognize the new module.

Finally Type “Orchard.Commerce” for the area name and click [OK].

image

3. For Orchard to discover this module, you need to add a module.txt file at the project root folder and insert the following content.

name: Commerce
antiforgery: enabled
author: Patrick Yong
website: http://patrickyong.net
version: 0.1
orchardversion: 0.1.2010.0312
description: Commerce
features:    Orchard.Commerce:
Description: Commerce.
Category: Commerce

4. Modify the web.config file accordingly. Basically I added <httphandlers> and <handlers> in <System.WebServer> for MVC routing.

<?xml version="1.0"?>
<!--  For more information on how to configure your ASP.NET application, please visit  http://go.microsoft.com/fwlink/?LinkId=152368  -->
<configuration>
<system.web>
   <!--             Set compilation debug="true" to insert debugging             symbols into the compiled page. Because this             affects performance, set this value to true only             during development.    -->
   <compilation debug="true" targetFramework="4.0">
   <assemblies>
      <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
   </assemblies>
</compilation>
<customErrors>
   <error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>    -->    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
   <add namespace="System.Web.Mvc"/>
   <add namespace="System.Web.Mvc.Ajax"/>
   <add namespace="System.Web.Mvc.Html"/>
   <add namespace="System.Web.Routing"/>
   <add namespace="System.Linq"/>
   <add namespace="System.Collections.Generic"/>
   <add namespace="Orchard.Mvc.Html"/>
   </namespaces>
</pages>
   <httpHandlers>
      <add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
   </httpHandlers>
</system.web>
<system.web.extensions/>
<!--         The system.webServer section is required for running ASP.NET AJAX under Internet        Information Services 7.0.  It is not necessary for previous version of IIS.  -->
<system.webServer>
   <validation validateIntegratedModeConfiguration="false"/>
   <modules runAllManagedModulesForAllRequests="true"></modules>
   <handlers>
      <remove name="MvcHttpHandler"/>
      <remove name="UrlRoutingHandler"/>
      <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
   </handlers>
</system.webServer>
<runtime>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
         <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
         <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
   </assemblyBinding>
</runtime>
</configuration>

5. Right-click the newly created “Ocrhard.Commerce > Controllers” folder, and choose “Add > Controller…”

6. Name the Controller “HomeController”

7. Right-click on the “Index()” method name and choose “Add View…”

image

8. Selected the “Create a partial view” option and click [Add]

image

9. Add the following HTML to the View page: <p>Hello World</p>

10. Add Orchard.Framework and Orchard.Themes to the project reference

image

11. Add the following namespace imports to the HelloController.cs file:

using Orchard.Themes;
using Orchard.UI.Navigation;

12. Add an [Themed] attribute to the HelloController class:

[Themed]
public class HomeController : Controller

13. Add another class to create a new Menu item, you can create a new .cs file in the project root folder or add it inside the controller class

public class MainMenu : INavigationProvider
 {
        public Localizer T { get; set; }
         public String MenuName
        {
            get { return "main"; }
        }

         public void GetNavigation(NavigationBuilder builder)
        {
            builder.Add(menu => menu.Add(T("Shop"), "4", item => item.Action("Index", "Home", new { area = "Orchard.Commerce" })));
        }
}

14. Type Ctrl-F5 to build and run in VS.

15. Login as admin (using the admin account you created during setup) and navigate to the admin page

image

16. Scroll down to look for Site Configuration menu and click on Features

image

17. Voila! If you had done everything right, you will see Orchard.Commerce as a module under the Commerce category. Now click on the ‘Enable’ button.

image

18. After a moment, message(s) will appear and to try out the feature, click on Your Site on top.

image

19. Now you notice an additional item on the top menu

image

 

10. Finally click on ‘Shop’ to Navigate to this URL in the browser: http://localhost:<port>/Commerce

image