Friday, August 26, 2011

Migrating a Web Application to Azure: Step 2

Migrating the database to SQL Azure

Now that we have a local web-application with a database, and a SQL Azure instance up and running, we can start the application migration by moving the database to SQL Azure.

SQL Azure is a modified version of SQL Server 2008 R2, and there are some small, but significant limitations on the SQL DDL commands that can be run on Azure. See here and here for more information.

The upshot is, if you already have a local SQL Server database, then you’re really much better off using some specialized migration tools to move it to Azure. The tool of choice for us is the SQL Azure Migration Wizard off codeplex.

Download and install the latest version of this tool on your development box. You’ll thank the tool-developer later!

Fire up the tool, and select “SQL Database” under “Analyze / Migrate”

sql_azure_mw_0

Select the local database server which hosts the instance you want to migrate

sql_azure_mw_1

Select the database(s) to migrate in turn.

In our case, we will have to migrate both the ASPNETDB and PICTURES databases.

sql_azure_mw_2

Click through the dialogs, and migrate database object present in the database.

sql_azure_mw_3

The Migration Wizard has created the script to use for the migration, and will now require your credentials to migrate to. This is where you fill in the details from the SQL Azure instance screen in the previous step.

sql_azure_mw_4

Let’s let the migrator create a PICTURES database on the Azure Server

sql_azure_mw_6

…and begin the migration work

sql_azure_mw_7

…and we are done!

sql_azure_mw_8

The Azure portal shows the two databases created and ready for use.

sql_azure_portal

Now, let’s hook up the application we wrote to use these databases in the cloud. To do this, we point the connection strings in the Web.Config of the web application to the databases in the cloud.

Thusly:

web_config_2

And that’s it. Here’s the application running locally but with the data in the cloud.

localapp_remotedata

I’ve created a new album called “Clouds” now, and uploaded three new pictures. If we look at the Azure database instance and look at the data in the PICTURES instance, we see the data there:

data_in_the_cloud

Next, we’ll talk about setting up the Azure workspace so we can move our application there…

blogBling_150x150_02333

No comments:

Post a Comment