Day 1 - Windows Azure Platform - Compute Service

by Kev Ritchie 1. December 2010 00:12

 

 

Over the next 12 days; in a 12 Days of Christmas style, I’ll be breaking down the components of the Windows Azure Platform into little snippets to give you an idea of what’s going on in “The Could” and how it works.  It’s not going to be of an eye-glazing technical nature, but more a user-friendly, easy to understand guide.

Yes, I’m sure you’re wondering why I’m starting now.  Simple answer, I’ll be full of Christmas Spirit, if you know what I mean Wink, and I’ll probably forget to do it.

So, on the first day of Windows Azure Platform Christmas my true love gave to me, the Compute Service.

What is the Compute Service?

In short, the Compute Service (and this is just my take on it), is the environment in which your Windows Azure application runs; the execution environment.

A closer look at the service reveals more.  The Compute Service is built from one or more roles.  A role defines a component that may run in the execution environment.

Web Role

A Web Role is customised for web applications and allows the creation of applications using ASP.NET, WCF and other web-based technologies.  Importantly, this is not just limited to Microsoft technologies; you can also create applications using PHP, Java or other non-Microsoft tools. Smile

NOTE: Web Roles run in full IIS 7.0

Worker Role

Worker roles are useful for running a variety of tasks and e.g. rendering of large files (I think RenderMan may use this), but are most useful for performing background processing for a web role.

Virtual Machine (VM) Role

A Virtual Machine role runs a user-customised server image.  This means that you can take a snapshot of the server (in your network) on which your application currently runs and apply it to a newly defined VM role in the Compute Service.  The best part, once the image is up and running in Azure, you can RDP (Remote Desktop) to it and control it like it was back in your network.

The Compute Service can run one or more instances of a role e.g. your application.  This allows for the workload on your application (when it gets too heavy) to be shared out to multiple virtual machines and the best bit, these VMs could be in different Microsoft Data Centres around the world and no-one would notice the difference Smile

The ability to scale up the amount of roles/VMs used is controlled by the Fabric Controller, which I’ll be discussing on the 3rd day of Windows Azure Platform Christmas.

Tomorrow’s installment: Storage

P.S. If you have any questions, corrections or suggestions to make please let me know.

Using Umbraco for the first time

by Kev Ritchie 26. November 2010 21:12

Yesterday, I spent a few hours tinkering with Umbraco.  For those of you that don’t know, Umbraco is an Open Source ASP.NET CMS (Content Management System).

Before I ramble on, a little back story for you.

I recently developed a website for my company that dynamically constructed the page content based on data retrieved from a SQL database.  Unfortunately, common in most development projects, the budget didn’t stretch as far as I needed it to Wink

So, the end result a really good CMS base, but no way of maintaining it; well unless you’re a whiz with SQL Server and fancy adding new pages and content through the SQL Server Management Studio.

It wasn’t until a few days ago, a friend of mine; Martin Beeby mentioned that he was looking into a CMS tool called Umbraco.  I was intrigued.

Now back to the present, an IE9 tab opened on Umbraco.org and an eager mouse hanging over the download link.

NOTE: There are two options for downloading.  You can use the Web Installer (which will do all the fiddly bits for you) or you can download the files for manual install.  Follow this link for more detail on the install options: http://our.umbraco.org/wiki/install-and-setup/how-to-install-umbraco-on-windows-server-2008

I chose the manual install option because I like to know what’s going on and how things hang together. 

After following the instructions in the link above, I fired up my browser (IE9 in case you didn’t notice before) and navigated to the Umbraco URL I had set up earlier, the Umbraco Configuration Wizard then appeared.  Part of the configuration was to install Runway (a basic website) or create a blank site.  My choice was to install Runway, the reason being that I could get an idea of what was needed to build a website.

After some familiarisation, I removed the Runway files (Document Types, Templates, CSS and Content).  One handy feature; in light of this, is the Recycle Bin.  If you make a mistake you can get your files back.

So, sitting with a now blank website structure in front of me, I needed to decide what I was going to put in it.  Yes, you guessed it, I decided to port over the website I created for the company.  This was an obvious decision because all the content and layouts had already been done.  All I needed to was a user friendly CMS.  Step in Umbraco. 

Diving straight into the Settings section (above), I created a new CSS file under Stylesheets and copied over the CSS from the other site.  I then created a new master page under Templates and copied over the HTML markup from the other master page.

 

As you will notice in the screenshot above, there are some more templates and also Document Types.  Document Types are extremely important and define the content for your site.  For more detail on this go to: http://our.umbraco.org/wiki/how-tos/working-with-document-types

When creating Document Types you have the option to create matching templates, I went with this as it saves time (well not too much Wink)).  I clicked on each newly created template and changed the Master Template option to the name of the master page I created earlier.  The screenshot  below shows this and also the markup copied from the other website.

You’ve probably noticed some <Umbraco:> elements in the screenshot above.  These relate to controls or objects created for example via the Document Types or the Developer section where you can create XSLT (Extensible Stylesheet Language Transformations) files and accompanying Macros.  In my case, I used XSLT and Macros to control the dynamic building of a list based on the Umbraco Related Links item.

It’s also worth mentioning that every template must have an <asp:content> element and the ContentPlaceHolderID  must match the Id of the ContentPlaceHolder in the master page.  If not, you will get either a compilation error or your content will not appear on the page.

With my CSS, templates, document types, XSLT and macros set up, it was time to create some content.

This was very easy.  I navigated to the Content section, right clicked on the Content node in the tree view and selected Create. 

I gave the new page a name (the name you enter for the page will be used in the URL with an .aspx extension), selected a document type (template) for the new page and clicked Create.  My new page appeared in the tree view (in a dirty state – highlighted by an asterisk) with all the fields set up previously in the selected document type.  Now it was just a matter of entering some content and publishing.

If you’re a stickler for procedures and want some control over what goes on to the web.  Umbraco has a nice permission set that allows you to give users Writer permissions (this means they can’t publish content, only send for approval) and Editor permissions (the ones that do the approving and publishing).  There is also the ability to lock users down to specific sections of the CMS.  So for example, if you give a user Writer permission and lock them down to just the Content and Media sections, they will only be able to create and save content.  So we have procedural control and security, nice Laughing

Final Thoughts

With just the few hours that I spent playing with Umbraco, I was able to move over my layouts and HTML markup and build up the new website exactly the same as the original, even adding more functionality than was possible before.  All this, without reading a single help file, which is testament to a well thought out and designed CMS.

Thanks Umbraco Laughing

Tags: , ,

Web

OK, OK, yes I'm a geek!

by Kev Ritchie 21. November 2010 20:18

It's not often that I profess to being a geek, but today I was looking through my DVD collection and noticed that I have a fair few "geek" films.  I like to think they're cool and never get bored of watching them.

Here a just a few that I can see at a glance.

1. Hackers - This should be in every geeks DVD collection.  Yes, there are a few technical faux pas, but we can let them slip because, well just because.

2. War Games - Who wouldn't want a super computer like Joshua!

3. Antitrust - Was this based on Microsoft?!? They've certainly tried to make Tim Robbins look like Bill Gates.  Well; that aside, Rachael Leigh Cook and Claire Forlani are in it, so that's good enough for me Laughing

How sad I am!  If you're a geek like me, what geek films do you have in your DVD collection?

AnonymousType to DataTable madness!

by Kev Ritchie 5. November 2010 21:53

Today I was working on converting a project over to WPF.  Everything was going well until I needed to put the results of a LINQ query into a DataTable.

There didn't seem to be any easy way to do it, unless I'm being really blind Laughing.  Well, after some research and tinkering, I chucked together this little handy method:

private DataTable QueryResults<T>(IEnumerable<T> anon)
{
    DataTable results = new DataTable();
 
    if (anon != null)
    {
        PropertyInfo[] columns = null;
 
        foreach (T item in anon)
        {
            if (columns == null)
            {
                columns = ((Type)item.GetType()).GetProperties();
 
                foreach (PropertyInfo column in columns)
                {
                    Type columnType = column.PropertyType;
 
                    if ((columnType.IsGenericType) && (columnType.GetGenericTypeDefinition()
                        == typeof(Nullable<>)))
                    {
                        columnType = columnType.GetGenericArguments()[0];
                    }
 
                    results.Columns.Add(new DataColumn(column.Name, columnType));
                }
            }
 
            DataRow dr = results.NewRow();
 
            foreach (PropertyInfo column in columns)
            {
                dr[column.Name] = column.GetValue(item, null) == null ?
                    DBNull.Value : column.GetValue(item, null);
            }
 
            results.Rows.Add(dr);
 
        }
    }
 
    return results;
}
You can also pass in objects of type ISingleResult e.g Stored Procedures, into this method.

Have a go and let me know what you think

Powered by BlogEngine.NET 2.5.0.6
Theme by Mads Kristensen | Modified by Mooglegiant