Moving your SQL Database to Azure

In this section, I will show you how to port your SQL Database from your old ISP to Windows Azure.

  1. Log onto Windows Azure using your Windows Live ID. If you don't already have an Azure account, please read the previous section.

  2. Click on Manage.

  3. Click on "Database" (on bottom left of screen)
    Database Button

  4. On the top left pane, click on the Subscription to which you want to add an SQL Database
    Subscription Pane

  5. Click “Create” (on top menu)
    Create Database

  6. Select the same Region you chose for your website in the previous section, and click on "Next".
    Choose Database Region

  7. Create the administrator login you want to use to access the database.
    Create Database Login

  8. You will be prompted to add firewall rules. These rules will define which remote machines are allowed to directly access this SQL role. You will want to access SQL from your development machine and also allow your Web Role instances to access the SQL server. Click on Add; the resulting dialog will show your current IP address. Add the Rule name “local development environment”, and enter your IP address twice. Click on “OK”.
    Firewall Rules

  9. Click on “Allow other Windows Azure services to access this server
    More Firewall Rules

  10. Click on ”Finish”. You will now see a “Fully Qualified Server Name”; write this name down so you can use it later for your connection string.

  11. At this point, we have setup a "Database Server", but we still need to create an actual database so we can put data in it (I strongly recommend against putting your new tables in the “master” database which has been created for you). Click on the second "Create" button on the top of the screen, and enter a name for your database. Here is an article describing the differences between SQL Azure web and business editions.
    Create DB

    Database Name

  12. Download Sql Azure migration wizard from: Extract and run the Sql Azure Migration tool to move your schema and tables to Azure; make a note of any errors the tool generates. IMHO, this is a truly amazing bit of programming. If you have developed your web application on older versions of SQL Server, some of the features you have used may have been deprecated.  Also, I have found that choosing the "Specify database" is a better option than "Master DB (List all databases)". This article discusses the differences between SQL Server and SQL Azure
    Azure Sql Migration Tool

  13. Next, navigate to your new database in the left hand pane.
    Navigate to DB

    On the left pane, you will see the text "Connection Strings". Click on "View" to see your connection string.
    Connection String

  14. Put this connection string into your web.config file, and publish your Web Application to Azure.