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.
- 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 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
- 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. - 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.
- Connect to the destination website with your favorite FTP program and delete the wwwroot folder.
- Upload the source wwwroot folder with the updated wp-config.php file (which should now be configured to use the destination's MySql database)
- 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
- 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 - Make sure you remove the old Microsoft Azure Website's reference to the custom domain name you are planning to use.
- Now set it up your custom domain in the new Microsoft Azure Website.
- 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.