Guy Shahine's Blog

Moving my wordpress blog without losing any content

Today I decided to move my blog from to Windows Azure Websites. In this blog post I’ll explain the goal, challenges and solutions.


1. Move all content of my previous blog from godaddy hosting to Windows Azure Websites.

2. Implement URL redirects because I wanted to change the blog address from to and avoid breaking any of the indexed urls by search engines or referenced by other websites.

3. Shorten url path from /archives/{year}/{month}/{day}/{post name} to post name only.


1. I started by setting up a new wordpress blog through Windows Azure dashboard, where it was super easy to setup and here’s a detailed blog post that explains the process step by step


2. This one was a bit tricky to choose the best approach. Couple of months ago, I moved my main page ( to run on top of mvc 4 hosted on azure websites. So I searched online for url rewrite in and found this article which I skimmed through and decided to write a custom http module that listens to the “OnBeginRequest” event and manipulates the response url when the first word in the path matches “/blog” (code shared below, which includes the solution for goal #3).


3. When I initially setup my blog in 2009, I decided to pick a path that looks like this , well, my SEO (Search Engine Optimization) knowledge back then was pretty limited. Recently, I got some interest in learning more about SEO (and here’s a fantastic beginner’s guide So I wanted my new URLs to look like . WordPress, allows you to easily update the path under Settings->permalinks where they already have a predefined option for having a path with post name only but once you update the permalinks then all the old urls would stop working and return a Not Found page. So I had to update my url rewrite logic to only pick the last part of the path when applicable.


Here’s my custom http module code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using System.Web;

    public class CustomHttpModule : IHttpModule
        public void Init(HttpApplication context)
            var beginRequestWrapper = new EventHandlerTaskAsyncHelper(onBeginRequest);

            context.AddOnBeginRequestAsync(beginRequestWrapper.BeginEventHandler, beginRequestWrapper.EndEventHandler);

        public void Dispose()
        { }

        private async Task onBeginRequest(object sender, EventArgs e)
            HttpApplication app = (HttpApplication)sender;

            if (app.Request.Path.IndexOf("/blog") == 0)
                var splitPath = app.Request.Path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

                string postName = splitPath.Length > 1 ? splitPath.Last() : string.Empty;

                var newUrl = new Uri(new Uri(""), postName);

                app.Response.RedirectPermanent(newUrl.AbsoluteUri, true);

And you need to reference your custom module in your web.config

Removed for brevity
      <remove name="FormsAuthentication" />
      <add name="CustomHttpModule" type="," preCondition="managedHandler" />

I hope you find this interesting!


The Windows Azure Bed Time Story

These days, everyone is getting excited about the cloud. You here them talking about how it became easier to deploy, manage, and monitor your services, and how much money your company will save (IF, of course, they know how to use it). Plus, most of us started understanding the concept of the cloud and how it is different than the old way of running services (even though different people see it differently).

Your curiosity led you to surf the web for information about Microsoft Windows Azure, you read a whitepaper from here, a blog post from there, (ohh if you’ve checked out the MSDN documentation, let’s just say it needs improvement) but you still feel that something is missing. Suddenly, you realize that you still didn’t get your hands dirty with it, you didn’t get the A to Z experience, where A is an empty file and Z is a running service that you can interact with from anywhere in the world. Your journey is kinda straight forward at this point. Assuming you’ve got the expected Operating System, Visual Studio, IIS, … You download the Azure SDK et voila, now you’re ready to run an Azure service locally on your machine. Then you get an Azure account (let’s hope you’ve got a limit on your credit card 🙂 ), go through the Azure portal and you deploy your service that’s up and running in minutes. Wow, a process that used to take you hours, days or even weeks (depends on how large the organization and the type of process, at Microsoft it used to take weeks) to run your application in datacenters, now it became a matter of minutes, isn’t it amazing? Well, it is amazing, that’s why most of us are excited about this new technology and business model.

Most of us agree that Azure is still catching up, there are areas that needs improvement, features that are missing, and others… but the team is working hard (as we would expect) to improve things and stand strong against the competition. While we’re waiting for these improvements to see the light, here are some areas that I’m planning on writing posts about sometime soon to give you guidance on how you can make your life easier:

Sleep tight 🙂

Three Days at Microsoft’s PDC

How was PDC this year?

Last week (Nov. 17-19), Microsoft gathered around developers, architects, media, etc.. at the Convention Center in LA in an event called Professional Developer Conference (PDC09). Unlike previous years where Microsoft used to announce new products at PDC, this year was more focused on accomplishing the announcements that were made before, for example: the launch of Windows Azure and the launch of Windows 7, or what’s coming up in the next version of previously released Microsoft products, for example: Microsoft Visual Studio 2010, Microsoft Office 2010, Microsoft Internet Explorer 9, Microsoft Silverlight 4.

Who am I?

I’m a developer on the Windows Azure team and in the past year and a half, I was part of the on-boarding team where I work closely with developers that are building services on top of Windows Azure platform.

Guy Shahine

Windows Azure at PDC

The Windows Azure lounge was one of the busiest places for three consecutive days (there is a Lebanese saying: “The monkey is a gazelle in the eyes of his mother”, but I’m telling the truth here). Everyone seemed interested and people were lining up for three hours to get a spot for the hands on labs (alright, we were giving a flip camera for every attendee that finishes one lab exercise and one Windows Azure session, but the third day we ran out of cameras and the labs were still full). Oh, and did I mention the container? Windows Azure had a datacenter container on site. The container is a smaller version than the original ones but it was still very exciting to see one of them.

Windows Azure Container

I was fortunate to be helping in the hands-on labs, where I had the chance to stumble upon people who were only interested in getting the camera instead of taking the opportunity to learn something. The best one was a lady in her 50s who waited in line for like two hours, and I was very happy to see a dedicated person that can’t wait to play with the labs (the thought of her waiting for a camera didn’t cross my mind for 2 seconds) until she made a typo while following the lab walkthrough and she called me to ask what does the underlying red zigzag means under her using statement and that her application is not running when hitting the “run” button. What did I do? Well, I gave her a stamp and sent her in piece for her little camera. The second best one was from a person with an eastern European accent, who skipped the 3 hours like and came directly to me: “Look, I am not a programmer and I don’t know how to write code, but I want the camera and there is no point for me to wait in line and reserve a station, so can you give me a stamp?”, I replied: “no”, He replied: “But why?”, I replied: “If you wait in line and your turn arrives I’ll personally give you a stamp without the need to finish the lab”, he ran away 🙂 .

Windows Azure Hands-on labs queue

Overall, the experience was awesome and the customers were very interested. Many of the attendees had very good questions and feedback, others were still interesting which led me to write this blog post 🙂 .