Moving my wordpress blog without losing any content

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

Goals

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 http://gshahine.com/blog to http://blog.gshahine.com 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.

Solutions

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 http://sunithamk.wordpress.com/2013/11/06/migrate-your-existing-wordpress-site-to-windows-azure/

wordpress-import

2. This one was a bit tricky to choose the best approach. Couple of months ago, I moved my main page (http://gshahine.com) to run on top of asp.net mvc 4 hosted on azure websites. So I searched online for url rewrite in asp.net and found this article http://msdn.microsoft.com/en-us/library/ms972974.aspx 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).

fiddler

3. When I initially setup my blog in 2009, I decided to pick a path that looks like this http://gshahine.com/blog/archives/2012/11/22/dont-be-a-turkey/ , 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 http://static.seomoz.org/files/SEOmoz-The-Beginners-Guide-To-SEO-2012.pdf). So I wanted my new URLs to look like http://blog.gshahine.com/dont-be-a-turkey . 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.

wordpress-permalinks

Here’s my asp.net custom http module code

namespace Gshahine.com.HttpModules
{
    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("http://blog.gshahine.com"), postName);

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

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

<system.webServer>
...
Removed for brevity
...    
<modules>
      <remove name="FormsAuthentication" />
      <add name="CustomHttpModule" type="Gshahine.com.HttpModules.CustomHttpModule, Gshahine.com" preCondition="managedHandler" />
    </modules>
  </system.webServer>

I hope you find this interesting!

-guy

Don’t Be a Turkey

Today is Thanksgiving day, which is probably the second most popular holiday in the US where families get together and feast on a turkey, mashed potatoes, gravy and jelly, followed by a pecan or pumpkin pie with lots of whip cream. Here’s a comic about Thanksgiving by Matthew Inman http://theoatmeal.com/comics/thanksgiving.

When I hear “turkey”, it always reminds me of a story that I first read few years ago in a book called The Black Swan by Nassim Nicholas Taleb. A story that I’ve told multiple times (I have my own version now with all the salt and pepper), it goes like this: A turkey wakes up hungry, and furiously searches for food until she finds some in the corner.  Same deal the second day until she finds more food in the same spot. Fast forward few weeks, the turkey doesn’t think about food anymore, when she’s hungry she knows where to go. The turkey’s life is amazing, she’s never hungry, she can now focus on other activities until one day around the end of November, she’s snatched from her little heaven and a butcher is about to do his little business.

BingWallpaper-2012-11-22

The moment before the knife touches the turkey’s throat, she’s in shock, and she’s wondering why. How could you blame her? she didn’t do anything wrong, and there is no way she could’ve seen this coming. This goes to all of us, I smile and remember the turkey story when I hear someone saying things like “Ohh my boss said that I’m on a fast track for a high position” or “I have a stable job at company X, their stock is getting more gain”. Find a good balance in your life, don’t take shortcuts and don’t get carried away by the little details. There is a favorite quote from a Kevin Spacey movie “You can’t win a marathon without putting some bandaids on your nipples”

To help you remember not to be a turkey, I wanted to hire miss Turkey but hardee’s beat me to her http://youtu.be/qHW6QbKzJtw

Happy Thanksgiving, Don’t be a turkey my friend.

The + in Google but not Google+

If you have a gmail account like the cool kids these days, then there is an amazing feature that you didn’t know about, it’s the + feature (I’m not sure what google officially calls it), I also like to call it “catch the bastards” feature (explanation coming later).

So what is it about? Basically, you’re allowed to add a keyword, an identifier, a spell, whatever you want to call it after your username in your email address where you separate them with a ‘+’ (plus character).

Here’s an example: Let’s say I want to sign up to a new website, for instance, http://resoltz.com. My email address is “gshahine@gmail.com”, my username is “gshahine” so when I get asked to enter my email address, I set it to “gshahine+resoltz@gmail.com”. Now, when I receive emails from http://resoltz.com, they show up like this

email-Clip

How awesome is that??? I would kiss a goat right now (I look for the slightest excuse by the way Smile)

Now, you might ask me “But Guy, how would this make my life easier?”. Well, few things off the top of my head:

  1. Making your life easier is up to you and it’s all in your head.
  2. It allows you to label emails easier, for instance, adding rules for “+family”, “+friends”, “+FYI”…etc
  3. It might allow you to identify the bastards that sell your email address to entities that want to you suck your fat (ladies) or enlarge your penis (dudes).
  4. You can sound cheesy, where let’s say a beautiful lady that you just met asked for your email address to stay in touch, “gshahine+inlove@gmail.com, bamm, next thing you’ll realize is having breakfast together.

The Awesome Shift+Right Click in Windows

Sometimes it’s the small things that matter, I use my computer on a daily basis, and the fact that I work at Microsoft, my primary operating system is definitely Windows.

Working with people that are part of the organization that built the Windows OS, sometimes you learn small tricks (also called hidden features) that make your life soooo much easier (Most of those tricks are in command prompt and visual studio). You might say, “well it’s probably documented somewhere”, or if you’re more geeky, you might say “ohhh http://lifehacker.com mentioned those tricks long time ago”. Sorry to disappoint you my friend, I’m that kind of a guy that never reads the instructions manual for pretty much anything. And on many occasions I challenge myself by even not looking at the Ikea instructions to put a desk together (I just remembered how many hours I’ve spent pulling things apart and starting all over because I realized towards the end that I’ve put some screws in the wrong spot *sigh*)

Anyway, back to our main topic that’s highlighted in the title, “What’s awesome about Shift+Right click?”. Well, instead of giving you the answer, let’s play one of my favorite games that’s usually featured in newspapers, and since we’re still on missing the right spot topic Smile, it’s called “Spot the differences” (I’ll make it easy, I promise)

ok, so here’s a snapshot for a right click on a text file in Windows 7

image

And here’s a snapshot of Shift+Right click on the same file

image

Did you see it? Com’on, try harder. Ok, I promised I’ll make it easy, notice that “Pin to Start Menu” and the sneaky “Copy as path”, and here’s an example of what get’s copied to your clipboard  when you use the copy as path ["C:UsersgshahineDesktopSomeFile.txt"]. The copy as path feature is really useful when you want to share with your coworkers a file location on a shared folder or a file location in your source control enlistment. I can’t even count on my hands how many times other coworkers were surprised when they saw me pulling a copy as path while working on the projector. (Well, probably 4 or 5 times, but it sounds cheesier when you use the “can’t count on my fingers” expression, it’s makes 11 sound like sooo much Smile)

Not impressed, try it on an Excel file and discover some goodies Smile. Still not impressed?? I’m sure you don’t even smile to a maple bar donut topped with bacon. It’s those small things that matter.

Azure User Account Management

“Necessity is the mother of invention”

The Windows Azure Platform currently offers the ability to have an administrator and 10 co-administrators associated with every account (Thanks to Steve Marx’s help to figure out that number), which introduces a limitation when 11 or more team members want to share the same account. In this post, I’m going to illustrate the different ways to avoid this limitation, and I’m pretty confident that at some point in the near future the platform will support a much more sophisticated user management interface.

Some rules of thumb: Treat the account as your online banking credentials. Whoever is paying the bill should frequently keep an eye on the consumption for any suspicious activity. Periodically renew the password or refresh the management certificates, and remember that the more people that share a secret, the less secret it is Smile

Even though we all know the rules, sometimes (in some cases, many times) we don’t follow them. So here are the different ways I’ve used to share the same account.

Share Co-Admin Credentials

One of the light overhead ways to share the account is to create a single LiveId account and give the credentials to every team member. This way everyone can login to the Windows Azure Portal as a co-administrator. To add an additional layer of safety, you can periodically change the password, this way you can avoid cases where someone left the group and still has the password or probably someone engraved the password in their favorite pub’s bathroom on a drunk night (yes ladies, you would be surprised with what’s in there Smile)

Share A Jump Box

A jump box could be a dedicated machine or virtual machine where you save the co-admin credentials in the browser, then anyone who needs to deploy a service will have to login to the jump box with some operating system credentials. This technique is painful (imagine the process: package your service –> remote login into the machine –> copy the package and config file –> deploy through the portal) but more secure because the jump box could live under the corporate network and the credentials of the Windows Azure account are not shared with the users. Ohh by the way, only one user can be logged in to the box at a time, so depends on your team size, you might need more jump boxes.

I followed this process for like a couple of weeks until the team wide bug bash day arrived where I had to apply few fixes and deploy multiple times, and trust me I wasn’t in the best mood afterwards, the extra step of copying the files and deploying through the portal felt like ages Smile

Share A Certificate And Subscription ID

(My favorite and most practical way)

At the moment, the Windows Azure Portal allows you to deploy a maximum of 10 certificates to your account, which will allow you to use the service management APIs to manage your account. You can create a single password protected certificate and share it with everyone on your team or you can have multiple certificates for different employees status (for instance, you can have a certificate for your full time employees, another one for contingent staff, another temporary certificate for developers who are not on the services side of the house but decided to experiment with cloud based services part of their out of the box projects. Once a user has the certificate installed on their machines and the associated Azure account subscription ID, they’ll be able to use the sweet visual studio publish button to package and deploy their service, or any of their favorite Azure Service Management Tools

Finalement (finally in French)

Sharing a certificate and subscription ID is my favorite approach because I mostly use the client side tools to deploy and manage my applications.

Please share any other ways your team applied and what you like and don’t like about them.

CloudCamp Seattle

Few weeks ago, I attended the CloudCamp event that was held at the Amazon headquarters in Seattle. For anyone who couldn’t make it, here’s my take:

The event started with a 5 min talk by the main sponsors (For more details about the speakers, check out the schedule at CloudCamp Seattle):

Amazon: The presenter pitch was around the idea that the cloud is secure and that the concept might have changed. Historically, you probably were able to point at or hug your machines and call them yours, but once you connect them to the internet, the question becomes “are they secure?”. Steve believes that the statement “the Cloud is insecure” is not true, “what’s secure anyway?”

IBM: I was so happy to know for the first time where IBM is partially heading toward, they’ve been talking about cloud and green earth and those nice commercials for months but on the technical ground I didn’t see a defined story. During Tony’s (who’s not a technical guy, he’s more of a sales/business person) presentation, it was a product pitch about what they call WebSphere CloudBurst/Hypervisor Editions (ouuu fancy name). Here’s the one sentence that summarizes his whole 7 minutes talk “They provide an appliance (the size of a pizza box, he said it like 10 times) that you connect to your network and machines, and what it provides a Front End between you and your machines sitting in your own data center or lab to spin up Virtual Machines and control the environment”

Windows Azure: The presentation was an overview of the Windows Azure Platform features. I wish the talk was around how Windows Azure brings value as a cloud platform. Well, I guess there is very little that you can squeeze in a 5 minutes talk.

Skytap: it was a pure product pitch delivered in a super boring manner. Their website has an overview of what they do, the presentation didn’t bring any value other than repeating this description.

Atlantic.NET: NO SHOW

Hubspan: Business talk, the presenter was really funny and the presentation was engaging. The talk was mostly addressed to business owners/investors and pretty much how the cloud could (lcoud coudl colud ) promote the old business model.

Guest Speaker: Patrick from a local company (forgot the name) that runs financial profiling to give you advice on the stock/mutual funds/… that you need to invest in. If you’re curious: I chatted with the dude, and they don’t take customers with less than a million dollars in investment Smile

Then we moved to the Unpanel section where the audience asked 9 questions related to cloud: 6 answered by people who called themselves cloud experts, 3 answered from the audience (1 of them by me Smile). Example questions: In the light of wikileaks being kicked out by Amazon, where does cloud stand providers stand ? Where do you think the NoSQL database is heading toward? Name one type of business or firm that can’t move to cloud, and give facts? Where does cloud stand on multiple geo located databases and how do you keep them in sync? Where does cloud stand in the open source community? … etc

Finally the unconference time came where around 7 people from the audience suggested topics to chat about. Some of the topics were: Cloud APIs, Open source community, Windows Azure 101, Google Webservices 101, CloudDatabase discussion … others

That’s it, let me know if you have any questions.

Azure Service & Storage Management Tools

In your day-to-day efforts to build a cloud service on Windows Azure, it’s crucial to be aware of the currently available tools that will facilitate your job and makes you more productive. I’ve created a table that will illustrate the different aspect of each tool, then I expressed my opinion about each one of them.

Azure Tools Table

See the table in Zoom.it

UI tools

Cloud Storage Studio

A tool developed by a company called Cerebrata, It’s currently my favorite tool which I extensively use for service management and browsing storage accounts. Even though the name is confusing, the interface is really nice, the application is stable and the team is very receptive of feedback . The only thing that annoys me, I can’t retrieve storage accounts information. Plus, it’s not for free but the team is actively adding new features and rolling fixes.

UPDATE 5/29/2011: The team read my blog post and they implemented the ability to retrieve storage accounts information. Now, I wish I had the ability to right click on a certain storage account and connect to it.

Windows Azure MMC tool

It has the richest set of utilities and It’s for FREE. Now, If you can bite on the wound and accept a blend interface, plus you expect it to hang here and there, then this tool if for you. Also note, that the tool is lightly maintained and I’m not aware of any planned new releases.

Azure Diagnostics Manager

Another tool developed by Cerebrata. This tool is more focused on managing your diagnostics. It includes a bunch of utilities that will definitely help you a lot in browsing through the logs, getting performance counters, trying to figure out some weird issue…etc It also includes a storage explorer (that I haven’t used because I already have Cloud Storage Studio)

UPDATE 5/29/2011: I’ve been using this tool more lately, and besides the fact that it gets stuck when I connect to a certain storage account once in a while, it’s very useful, and I really like the graphs that gets generated for the performance counters over time.

Visual Studio Tools For Azure

There are multiple parts: It has a nice interface for configuring your service. You’re able to build, package and deploy your service when you ask Visual Studio to publish your app. You can also build, package and run locally in devFabric. There is also a readonly storage explorer. The downside is that you can’t manage your services or storage data but I believe there are plans to allow you to (at least for storage data)

Windows Azure Portal

The portal is required for many things that are usually done very rarely like creating and deleting a storage account. It’s slow and poor on features, but there was an announcement at PDC2010 that there will be a redesigned portal built on top of Silverlight.

Cloud Storage Studio /e

A web based storage explorer built by Cerebrata. It’s still in beta and for free. I personally haven’t used it in a while.

UPDATE 5/29/2011

Thanks to all the readers that brought to my attention other tools that I’ve missed, here’s another set of tools:

Azure Storage Explorer

A FREE open source tool published on codeplex that allows you to manipulate your Azure Blob, Queue and Table storage Smile

AzureXplorer

Developed by a company called clumsyleaf, it’s a paid product and I haven’t used it myself but it’s worth checking it out, it might suite your needs, check out the website for all the details/screenshots/pricing …

CloudXplorer

A Clumsyleaf free product, it let’s you browse through your Azure blob storage account in a similar fashion as the Windows file system explorer.

TableXplorer

Another Clumsyleaf free product, it offers a simple way to retrieve your Azure tables.

Windows Azure SCOM Management Pack

Here’s a nice blog post that enumerates the features of the SCOM (System Center Operations Manager) Management Pack for Windows Azure.

As far as I’m aware, it’s currently the only enterprise level monitoring tool for Windows Azure. If you’re already using SCOM then it’s perfect, you can immediately start monitoring your Azure services.

Here’s what I really like about it :

  • Setup alerts to get notifications by email, phone call, IM, … for the following cases:
    • Service status changed .
    • Performance counters crossed some specific threshold.
    • A Windows Event with a certain ID is detected.
    • Critical, Error, … logs are observed in the logs store.
    • and more…

What I don’t like about it:

  • You need to have a SCOM license to be able to use the Management Pack.
  • If you’re not familiar with SCOM, I found it cumbersome to set it up.

Script based tools

Windows Azure Service Management Cmdlets

Even though I haven’t wrote any scripts that make use of the cmdlets, I know the test and operations team rely on them to automate different kinds of services management.

Azure Management Cmdlets

Didn’t also get the chance to play with it, but I believe it’s very similar to the Windows Azure Service Management Cmdlets. I’ll leave it for you to figure the difference :)

Azure SDK command line tools

The SDK command line tools are essentials for automation. There are multiple ways you can find those tools useful, I’ll name a couple 1) Write a custom script that will allow you to package then run your service locally (or perform other actions) using cspack.exe and csrun.exe. 2) Integrate cspack.exe part of your build system to automate packaging the service.

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 :)