By

Switching Microsoft Azure Subscriptions for WordPress Site

Have you ever wanted to move your WordPress Microsoft Azure Website from a pay-as-you-go subscription to the subscription that you get with an MSDN license? It’s not as easy as you would think. Today I spent several hours battling with Microsoft Azure, ClearDB (service Microsoft Azure uses for MySql databases) and WordPress trying to move my website, lunamark.com, from my pay-as-you-go subscription to my subscription that is tied to my MSDN license.

A month ago, I setup my new business website lunamark.com using Microsoft Azure Websites. At that time I did not have my MSDN license, so I setup a pay-as-you-go subscription in order to use my custom domain. Moving my website from a pay-as-you-go subscription to the new subscription tied to my MSDN license took longer than I anticipated and required more steps. In the event that you have to move a Microsoft Azure Website between subscriptions, I hope the following notes will make it easier for you.

  1. Backup your website
    • Backup the files for the source website by downloading the wwwroot folder using your favorite FTP program (I used Cyberduck for Mac. Find your FTP credentials in the source website’s publish profile.
    • Backup your database which is a linked resource to the source website by using mysqldump. If you don’t have that on your computer you can download the MySQL Suite which will include both the mysqldump and mysql commands. Thanks to [John Papa’s blog post](http://www.johnpapa.net/azurecleardbmysql/ I was able to do easily backup and restore my MySql database. Here is the command I used on my Mac to backup my database:
      /usr/local/mysql/bin/mysqldump -e -u[user] -p[password] -h[host] [database] > [output file]
      Note: the -e makes multiple values rows for the insert syntax but is not required
  2. Create a new Microsoft Azure Website (from WordPress gallery).  I will refer to this website as the destination website to keep the two straight. Note: This will require a new name (new_name.azurewebsites.net). Later we will need to replace the old_name with the new_name in the backup sql file created above.
  3. Get the connection string from the the destination website created in step 2 and use it to update the wwwroot/wp-config.php file downloaded from the source website with the new database name and login information.
  4. Connect to the destination website with your favorite FTP program and delete the wwwroot folder.
  5. Upload the source wwwroot folder with the updated wp-config.php file (which should now be configured to use the destination’s MySQL database)
  6. Edit the [output file] that was created in step 1 and replace the old_name of the website with the new_name that was created in step 2
  7. Use the mysql command to update your new database.
    /usr/local/mysql/bin/mysql u[user] -p[password] -h[host] [database] < [input file]
    Note: the [input file] would be the name of the [output file] that was created above and modified to replace the name of the old_name with the new_name of the Microsoft Azure Website
  8. Make sure you remove the old Microsoft Azure Website’s reference to the custom domain name you are planning to use.
  9. Now set it up your custom domain in the new Microsoft Azure Website.
  10. Last, I would recommend stopping the old Microsoft Azure Website to verify the new website is working as desired before deleting the old website

Please Note: The steps described above will require some downtime for your website. If downtime on your website is not an option, then watch this Scott Hanselman video where he recommends to use a load balancer to not have any downtime.