Archive for the ‘Azure’ Category

Moving a WordPress Blog to Windows Azure – Part 5: Moving From a Subfolder to the Root

July 11th, 2013 No comments

In Part 1, I created a new WordPress site hosted on Windows Azure. In Part 2, I transferred all of the relelvant content from my old WordPress site to my new one hosted on Windows Azure. In Part 3, we made the necessary configuration changes from my domain registrar to Windows Azure to have my custom domain ( direct people to my new blog site on Windows Azure. In Part 4, I had to define some URL Rewrite rules with a web.config file to handle my custom permalinks in my WordPress blog.

In Four (somewhat) short steps, I’ve completely moved my WordPress blog over to Windows Azure! However, I’m not done yet. As part of this transition, I made the decision to finally move my blog off of a subfolder off of my site ( to the root of my domain (

This made me nervous as I imagined all of the links scattered across the Interwebs that I’ve built up for the past 10 years suddenly blowing up. However, with a little plug-in magic and a new URL Rewrite redirection rule I was able to finally check off this task that’s been on my list for several years!

The Database Search/Replace Magic


WARNING! Before you do anything, make sure you have a backup of your WordPress site and WordPress database. See WordPress Backups on steps on how to protect yourself. I am not responsible for any catastrophic events that may take place.

The good news is you are migrating from an existing site, so you should be covered. Plus, short of completely deleting  your database without a backup, any changes made should be easily remedied. But…you’ve been warned!

My WordPress content database is littered with relics of the past. Namely various references to my old blog address ( From various WordPress configuration settings to my post content as well. The recommended approach found within the Moving WordPress documentation is to search all references of the past and replace with the new. According to this document, there are no less than 15 (!) steps to accomplish this task. Thankfully, the great folks over at interconnect/it have created a Search and Replace for WordPress Databases Script to accomplish this feat for us.

Download the script zip file.

If you’re running Windows, I recommend ‘unblocking’ the zip file once it’s downloaded and before you unzip it. Open up Windows Explorer and navigate to the folder containing the downloaded zip file. Right-click on the zip file name and select properties. On the ‘General’ tab, click the ‘Unblock’ button and click ‘Ok’.

Unzip the file and upload the ‘searchreplacedb2.php’ script file to the root of your WordPress site.

Some helpful steps on how to upload files to your WordPress site using FTP can be found in Part 2 and Part 4.

Run the script by opening your favorite web browser and navigating to the location of the script file (ie.


Click the ‘Submit’ button to have the script retrieve your database connection strings as defined in your wp-config file.

On the ‘Tables’ step, I kept the defaults and selected Continue.

For my purposes, I chose to replace the following on the ‘What to replace?’ step:


Thankfully, I didn’t encounter any errors:


Don’t forget that once the script is finished running to DELETE THE SCRIPT FILE FROM YOUR SITE!

After a cursory scan of my blog content, everything seems to be in working order!

Handling 301 Redirects with a URL Rewrite Rule

Now that my site content has been updated with the new permalink content, what about all of those hanging links to my content scattered across the Internet. Are they forever broken? Thankfully, with a little URL Rewrite magic, they’re not. The recommended approach to notify the various search engines of this change and handle the redirection from existing links is to use a 301 Redirect.

To handle this for my purposes, I added a Redirect rule to my <system.webServer> configuration section in my web.config file:

         <rule name=”RedirectRule” stopProcessing=”true”>
             <match url=”^blog/?(.*)$” ignoreCase=”true” />
             <action type=”Redirect” url=”{R:1}”
                         redirectType=”Permanent” />

Setting ‘redirectType’ to ‘Permanent’ identifies this as a 301 Permanent Redirect. In short, the match regular expression looks for the string ‘blog’ within the url, captures everything following ‘blog/’ and replaces {R:1} with the contents in the <action> element. My rule defined in Part 4 for handling the custom permalinks in my WordPress site follows this RedirectRule definition.

WE DID IT! In a few short steps we migrated a WordPress site over to Windows Azure with a couple of additional tweaks required for my particular purposes to move from a subfolder to the root of my domain. FINALLY!

What I’ve learned is that within a matter of a minute or so, I can stand up a WordPress site on Azure. And within an hour or two, I can migrate all of my data over from my old WordPress site to my new site hosted on Windows Azure.

I hope these instructions were valuable in your pursuit. Let me know how everything turns out in the comments.


Categories: Azure

Moving a WordPress Blog to Windows Azure – Part 4: Pretty Permalinks and URL Rewrite rules

July 11th, 2013 1 comment

We’re down to the last few, albeit most important, steps in this little project.

In Part 1, we created a new WordPress site hosted on Windows Azure. Part 2, we transferred the content from our old site to the new one. With Part 3, we set up our custom domain with some DNS wizardry.

In this fourth step, I’m going to walk through the steps to make sure my custom permalinks are handled correctly in Windows Azure.

As with most blogs, I want to have “pretty permalinks”. I’m opting for something like over the less friendly Chances are your permalinks are configured just the way you want them. After all, your entire existing WordPress site options and configurations were moved over as part of the data content transfer in Part 2.

However, if you’ve elected to go with any custom permalink format in WordPress other than the default, you’re going to need to set up some URL Rewrite rules.

Although your WordPress site hosted on Windows Azure is running PHP, it’s running PHP on an instance of Internet Information Server (IIS). Setting up URL Rewrite rules on an IIS server is slightly different than modifying an .htaccess file on an Apache instance.

URL Rewrite rules are defined in the web.config file in IIS.

That’s right. Even though we’re running an PHP website, web.config is still utilized for any server configuration items, including URL Rewrite rules.

Open up your favorite text editor and create a ‘web.config’ file with the following contents:

<?xml version=”1.0″ encoding=”utf-8″ ?>
                <rule name=”Main Rule” stopProcessing=”true”>
                    <match url=”.*” />
                    <conditions logicalGrouping=”MatchAll”>
                        <add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
                        <add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
                    <action type=”Rewrite” url=”index.php” />

Save the ‘web.config’ file and upload it to the root folder of your WordPress application. For my purposes this is the same location for the root of my website as well. As stated in Part 2, an easy method to upload files to your website is through FTP. The FTP HOST NAME and DEPLOYMENT / FTP USER information is available on the website’s dashboard in the Windows Azure Management Portal. You may have to reset your FTP login credentials if you haven’t already done so. You can do this by clicking on the ‘Reset your deployment credentials’ link on your websites Dashboard page.

More information on creating this URL Rewrite rule is available on the IIS Product site.

Assuming you have custom permalinks for your website, you should be up and running with your WordPress on Windows Azure now. CONGRATULATIONS!

However, that’s not the end of this article series. I chose to take a big leap during this transition to running my WordPress blog on Windows Azure to finally removing my blog off of a subdomain ( vs. We’ll cover that adventure next.

Categories: Azure

Moving a WordPress Blog to Windows Azure – Part 3: Setting Up Your Custom Domain

July 11th, 2013 2 comments

In Part 1, we discussed how to stand-up a WordPress website in Windows Azure. In Part 2, I outlined the steps to export your content from your old WordPress website to the new one hosted in Windows Azure. In this article, we’ll walkthrough the steps to setup up your custom domain for your new Windows Azure Website.

When you first create your website in Windows Azure, it is hosted under a domain that’s great for testing but not great for “production”. What we want is to go from http://<mysite> to http://<mysite>. We can do this in Windows Azure by configuring a custom domain.

To use a custom domain in Windows Azure Websites, your website must be configured to run in Shared or Standard mode. Note, that running in Shared or Standard does incur a cost which our outlined on the Windows Azure Pricing page. However, as I stated in previous articles, MSDN Subscribers and BizSpark members are afforded various benefits including price reductions across the various Windows Azure Services.

The steps to setting up your custom domain include:

1.) Configure your web site for shared or standard mode

2.) Configure the CNAME with your domain registrar (ie. GoDaddy, Hover, etc.)

3.) Set the domain name in the Windows Azure management portal

These instructions are outlined in the article, Configuring a custom domain for a Windows Azure web site.

Configure your web site for shared or standard mode

Starting with Step 1, login to your Windows Azure Portal and open the dashboard for your WordPress site. From there, click on the SCALE menu item and select the appropriate WEB SITE MODE: SHARED or STANDARD. (NOTE: You will start incurring the relevant charges once you select either of these modes. Pricing details can be found here.)


Once the Web Site Mode is selected, click the Save button on the task bar at the bottom of the page.



Configure the CNAME with your domain registrar

This next step will vary based on who your domain registrar is. Your domain registrar maintains the records for your domain. Most importantly, it maintains the instructions of where to send people when they type in your domain. More likely than not, your domain registrar is the place where you bought your domain. For my domain,, my registrar is GoDaddy. I’m in the process of moving all of my domains over to Hover but I haven’t had the chance to move just yet.

Log on to your domain registrar’s site. Find where you manage the DNS entries for your domain and create a CNAME for your domain that maps back to your site.

For GoDaddy, open the management page (Domain Details) for your custom domain and select the “DNS Zone File” tab.

For my site, my hosting provider was maintaining my Nameservers along with all my CNAME and A records. To switch completely away from my hosting company, I had to set my Nameservers back to GoDaddy’s servers by selecting ‘Manage’ under ‘Nameservers’ and selecting the ‘Standard’ setup type.


Now click on the “DNS Zone File” tab to manage your DNS entries.

We’ll want people to navigate to our website whether they enter using the ‘www’ alias ( or without ( For Windows Azure Websites, we need to add an additional CNAME item to handle a required verification process that we’ll come across in Step 2.

With this in mind, add the following CNAME entries:


Alias Points To (Value) TTL
www <yoursite> 1 Hour
awverify awverify.<yoursite> 1 Hour

To handle the ability to navigate to your site without the ‘www’ alias, you will need to create an A Record with your domain registrar. An A Record will map traffic to a public IP address versus redirecting to a domain. Therefore, you will need to know  your new Windows Azure website public IP address.

To get your websites public IP address, open the Windows Azure portal page for your website. On the task bar at the bottom, select ‘Manage Domains’.


On the Mange custom domains page, your public IP address is listed towards the bottom:


Switch back to the domain registrar’s DNS management page and create an A Record that points to your Public IP address, in this example we’ll use

A Record:

Alias Points To (Value) TTL
@ 1 Hour


After my changes and additions, my DNS entries include the following:


Set the domain name in the Windows Azure management portal

Once your CNAMES have been propagated with your domain registrar, you can add your domain names to your Windows Azure Website.

Note: Your domain name should be valid as we are moving an existing site over to a new host. However, the domain name may not redirect to the proper address until the DNS change propagates across the Internet. Check with your domain registrar’s policy for the expected turnaround time. There are several factors involved for how long the DNS propagation it will take.

Open the Windows Azure Management Portal. Click on the Web Sites tab, click the name of your website. From there, click on the Dashboard tab to open your websites dashboard page.

As we did in the step to retrieve our public IP address, click on the Manage Domains button on the task bar.



Add an entry for both your ‘www’ aliased domain and your root domain.



Windows Azure will validate the existence of the host name before it will save the changes. In the case of our A Record (, the verification process will check against the awverify.<yoursite> CNAME item we created earlier. Our ‘www’ address is verified against the ‘www’ CNAME record.

Click the check mark to save the changes.

Once your domain registrar propagates the changes across the Internet, you’ll be up and running with your custom domain!

In the next step, we’ll cover how to handle custom permalinks with a server-side configuration file.

Categories: Azure

Moving a WordPress Blog to Windows Azure – Part 2: Transferring Your Content

July 11th, 2013 2 comments

In Part 1, I covered how to create a new WordPress blog on Windows Azure. This article will focus on  how to move our WordPress content from our old blog site to the new site.

There are numerous ways to backup or export your WordPress blog and restore or import into a new WordPress instance. These include various plug-ins, scripts and wizardy scattered all over the Internet. WordPress also provides guidance on Moving your WordPress site as well. I took the various directives and tooled a method that worked for me. YMMV (Your mileage may vary).


Transferring Themes and Plug-ins

Most of the content on my blog is stored in the WordPress database. This makes it as simple as exporting my current database and importing the data into my new database. However, I have additional content on my site that is not stored within the WordPress blog such as images, media files, presentation/demo files and such that are not stored in the database. Not to mention my WordPress theme files, plug-ins, and uploaded content I currently have activated within my site.

Thankfully my current hosting provider as well as Windows Azure Websites provides me a method to get at and modify my server files. The old try and true FTP.

Although Windows Azure Websites provides a method to publish content through various means (Visual Studio/WebMatrix publishing, Git, etc.), I chose to go with the FTP route. It’s the most straightforward method for my purposes, and I can easily transfer files from one FTP site to another using an FTP client tool such as FileZilla.

To gain access to the FTP HOST for your Azure Website, you need to reset your deployment credentials. To do so, click on the ‘Reset your deployment credentials’ link on your websites dashboard page.


Once you’ve defined your deployment credentials, you can fire up your favorite FTP client and transfer the necessary files from your old site to your new site.

For your theme files, plug-ins and any additional content uploads, you’ll want to transfer the files in each of the following directories to their respective directories on your Azure hosted site.


As I stated earlier, I have some additional content directories and files, not related to WordPress, that I needed to copy over as well. Be sure to move over any additional folders and files you have outside of the WordPress files.

Transferring Your WordPress Content

All of your WordPress content and a majority of your WordPress configuration settings are stored in a database. This makes it very convenient in our transition from our old hosting provider to Windows Azure. Essentially we just need to Export our database from our old site and Import into our new site. Once again, there are several ways to backup and restore your WordPress database. My method of choice was to use the phpMyAdmin Portable plug-in. phpMyAdmin is an administration tool for MySQL databases that provides easy export/import functionality. phpMyAdmin Portable is a WordPress plug-in that drops the phpMyAdmin tool right in your blog! You’ll need to install this plug-in on both your old website and your new Azure-hosted website.

To install the plug-in, log in to your WordPress dashboard (ie. Once in the WordPress Dashboard, click on the Plugins tab and select ‘Add New’. In the search box, type ‘Portable phpMyAdmin’ and click ‘Search’. Click ‘Install Now’ under the entry for Portable phpMyAdmin and follow the instructions to install the plug-in.


Once the plug-in is installed, you need to Activate the plug-in by clicking on ‘Activate Plugin’:


Once activated, Portable PMA will be listed in your WordPress Dashboard menu bar:


Export your existing content

Launch Portable PMA and follow these steps to backup your database from the WordPress support site: Backing Up Your Database.

If you followed the steps correctly, you should now have a local .ZIP file of your exported database contents. Now it’s time to import that content into our new site hosted on Windows Azure!

Import your content to the new WordPress site

Log in to the WordPress Dashboard on your new Windows Azure hosted site and follow the preceding instructions to install the Portable phpMyAdmin plug-in on your new site.

Once the plug-in is installed and activated, run the phpMyAdmin tool by selecting ‘Portable PMA’ from the Dashboard’s menu bar.

In phpMyAdmin, select your Database and click on the Import tab.


In my case, my ZIP file was over 7MB in size. As you can see, the max upload size is 2MB. This limit is a system-level default setting (upload_max_filesize) defined in our PHP instance. Thankfully, this limit can be adjusted with a simple configuration file. Those instructions are outlined in the article, How to Configure PHP in Windows Azure Web Sites.


Upload the ZIP file created by the backup process by selecting the ‘Browse’ button and selecting the ZIP file. Once selected, click ‘Go’. It may not look like anything is happening but just give it a minute or two. DON’T CLICK ON ANYTHING until a status message appears.


That’s it!

The steps were roughly:

- copy theme, plugins, and uploads directory from old site to new site
- export old wordpress content database
- import wordpress database content into new wordpress site

Open up a browser and navigate to your new WordPress site (ie. to verify the content, themes and plug-ins are in working order.


In the next article, I will show you how to set up your custom domain which at this point most of you will be done! We’ll finish up the series with a 4th installment on some custom steps I had to go through to clean some items up that I have been wanting to do for some time, including moving my blog from a subdomain ( to the root (

Categories: Azure

Moving a WordPress Blog to Windows Azure – Part 1: Creating a WordPress Blog on Windows Azure

July 10th, 2013 10 comments

As an MSDN Subscriber, I have some great benefits on Windows Azure at my disposal. One of which is a credit of up to $150/month to use at my discretion for any Windows Azure service. With the recently announced general availability of Azure WebSites at the recent Build 2013 conference, I am choosing to take advantage of my MSDN Azure benefits and move this very blog over to Windows Azure Web Sites.

Currently my blog is hosted on IIS (Internet Information Server) running WordPress as my blog engine. I switched from .TEXT (dotText) (an ASP.NET based blog engine that has spawn several forks including SubText and BlogEngine.NET along with many others) to WordPress a few years ago for an opportunity to dabble in the PHP world and learn a thing or two. As it turns out, my PHP friends tell me that if you want to learn PHP, stay away from WordPress. :)  Anyhow, WordPress is used to serve up millions of websites across the world and has an outstanding support community behind it. I’m not ready to switch off of WordPress just yet. Let’s focus on switching service providers first before I start thinking about switching blog engines.

There are probably several different ways to move your WordPress blog over to Azure. There are several steps involved, with various nail-biting instances in play. However, it turned out to be easier than I thought it would be and I was up and running in less than an hour!

Let’s get started!

Creating a WordPress Blog on Windows Azure

To create a WordPress blog on Windows Azure, it really couldn’t be simpler. I’m assuming you’ve already signed up with Windows Azure. If you’re an MSDN Subscriber, be sure to activate your Windows Azure Benefits. If you’re coming to Windows Azure for the first time, you can sign up for a free 1-month trial with a $200 credit towards any Azure Service as part of your trial.

Once you’re all signed up, sign into your Windows Azure account and go to your Portal. In the Portal, click the ‘+’ sign on the taskbar to bring up the task menu.


In the task menu, Select Compute | Web Site | From Gallery. There are many apps ready to be deployed to your new Azure web site including app frameworks, forum software, content management systems, as well as several blog engines. Seeing as how we’re moving an existing WordPress blog over to Azure, we’re going to select ‘WordPress’. Once selected, click on the next (“Right Arrow”) button to set up site configuration.



Windows Azure provides you the opportunity to create up-to 10 free websites. These websites are hosted under the ‘’ domain. You can host your website under a custom domain once you upgrade your website to the Shared or Standard mode service tiers. There is a cost associated with these service tiers. MSDN Subscribers and BizSpark members receive a nice discount for the various Azure services. Even without the discount, we’re still far below our monthly Azure credit as an MSDN Subscriber!

On the Site Settings page, enter a URL to host your new WordPress website. This name must be unique under the ‘’ domain. Think of this as your staging area for your new WordPress site. Once we get everything up and running, we’ll switch out site over to a Shared hosting plan and configure our custom domain.  A WordPress site requires a MySQL database. If you don’t have a MySQL database already configured, this setup process will create one for you. From there, select the Region in which would like your site to be hosted from. Once finished, click the next button.



On the “New MySQL Database” settings page, specify a name for your MySQL database and select the Region where the database should be hosted. Ideally you’ll want your website and database to be hosted within the same region to cut down on any latency between  your website and the backend database. Read the terms for ClearDB (the hosting provider of your MySQL database) and if you agree, check the box and complete the setup process by clicking on the check button.


Once you click on the Check button, you will be returned to the Web sites Portal page where you should see an entry for your newly created website. The Status indicator will briefly display “Creating” while the new site is provisioned and the WordPress software is installed for you. When everything is complete, the status will change to “Running”.

In the Website Portal page, click on the website name to open the site’s dashboard page. Initially you’ll see a quick-start page outlining some options to help you get started. Feel free to skip those options for now and click on the “DASHBOARD” link at the top of the page.



The Dashboard page provides an overview of your websites usage along with configuration items and the locations of some important links such as your FTP host, where you can upload files to your website, and the FTP Diagnostic logs, where you can download the log files of your website.

Click on the link under SITE URL (ie. to test your new website.


If you see the WordPress installation page, CONGRATULATIONS! You’re up and running with WordPress on Windows Azure!

Finish the WordPress installation by filling out the required details and clicking the “Install WordPress” button.


That’s it! A fully functional WordPress site on Windows Azure!

Next, we’ll cover how to import your existing WordPress content, move over your additional content such as your theme and plug-ins, a couple of server tweaks and wrap everything up with a nice custom domain.


Part 2: Transferring Your Content

Part 3: Setting Up Your Custom Domain

Part 4: Pretty Permalinks and URL Rewrite rules

Part 5: Moving From a Subfolder to the Root





Categories: Azure