This post will be very direct. It will get a database running in the Azure cloud as quickly as possible. There is plenty of material about why SQL Azure might be of interest and how it works. Go to Bing and type SQL Azure and you’ll get all the reasons that SQL Azure is the right solution in many scenarios. www.microsoftpdc.com is a great place to start.
Brief Goals
Steps in this post
The Northwind database – where to download
Do a search on Bing for “Northwind and pubs Sample Databases for SQL Server 2000” and you should find this link:
http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&displaylang=en
The Northwind database – building the database
The file to pay attention to in the SQL Server 2000 Sample databases is instnwnd.sql.
This is only a fraction of the .sql code.
Microsoft SQL Server Management Studio
Start Microsoft SQL Server Management Studio and choose, “File, Open, File”
Execute the Query to build the database
Open instnwnd.sql and go to SQL Server Management Studio and hit the “f5” key or go to the menu and choose “Query, Execute.”
Notice that we have a Northwind database
We will work with some of the tables here in our sample application.
NorthWind Database – Attach to “Server Explorer”
One of the first tasks we need to get done is get a database created and ready to code against within Visual Studio 2010.
Adding a connection to Northwind
Northwind
Advanced connection properties
Task – Creating the Visual Studio Project
In this task you will create a new Visual Studio project for the Windows Azure Web Site:
Open Microsoft Visual Studio 2008/2010 elevated as Administrator, from Start | All Programs | Microsoft Visual Studio 2008/2010 right-click Microsoft Visual Studio 2008/2010 and choose Run as Administrator.
If the User Account Control dialog appears, click Continue.
From the File menu, choose New and then Project.
Create a new Web Cloud Service
Rename the WebRole to NorthWind_WebRole by clicking the pencil icon.
Click the OK button to create the solution.
When the project template has finished creating items you should be presented with the Default.aspx page. If not open the Default.aspx page.
Ensure that you are viewing the Default.aspx page in Design View by clicking the Design button
Drag and drop a GridView control from the Data section of the Toolbox onto the design canvas.
The steps in detail follow below
Creating a new cloud project
To create a cloud service application
Creating a new web role
You will need to click on the pencil to rename the web role.
Northwind_WebRole
See previous step about click the pencil.
Adding a GridView control
Select <New data source..>
Choosing a data source type
We are selecting our Northwind SQL Server database.
Choose Your Data Connection
Save the connection string
Create a "select" SQL statement
This is the data that will show up in our GridView control.
Build the select statement
It will be used to populate our GridView.
The test query
You can test the query before even running it.
Run the application to test the grid and the database
We will now run our application.
Our cloud application running on the local developer cloud
The next step is run the application in the cloud.
So now we are moving to the cloud and our goal is to deploy our database in SQL Azure. We have a few steps to get this done.
Login into http://windows.azure.com
Note that when you create a server (from the SQL Azure tab), you will need to specify:
You will need these later when you modify web.config to support connectivity to SQL Azure from your Windows Azure ASP.NET web application.
Once you’ve created your server, you will need to create a database. Our database will be called “NorthwindInCloud.” The database will be empty initially, until we add our tables and data.
Server Name established
Note that in this case, the server name has been created as
Naming and Sizing for the database
You will now provide:
Recap – Where we are so far
At this point we’ve accomplished quite a bit. We have:
The “Connection Strings” button
I found this button to be “almost true,” in that I got an error for “Encrypt=True.” More on that later.
Unless you modify Firewall settings, you will get connnection failures.
Configuring the Firewall
You will need to add a firewall rule. The good news is that you are told about the IP address, “Your IP address: 205.248.102.81”
Add Firewall Rule
I’m working in Peets Coffee today when I’m writing this post. And I’ve had to add additional firewall rules based on where I’m connecting from.
Example of a Firewall rule
Depending on your network scenario, you may need to add additional rules.
Testing Connectivity
You may need to wait a few minutes for the firewall rules to take hold. Nothing beats a green “Successfully connected to the database” message.
Migrating our data
Now that we have the on-premise database running correctly, we are now ready to deploy to the cloud. To help with this effort we will use the SQL Azure Migration Wizard available on CodePlex.
WinRar to install our SQL Azure Migration Wizard
There’s nothing complex about the installation. Just extract to a holder and you are good to go.
Starting the migration wizard
I will select “Analyze and Migrate” to start the process.
Logging in to our local instance of SQL Server
Selecting the database we wish to upload to SQL Azure
We wish to upload “Northwind”
Customers Table
We are interested just in the Customer table.
Summary Screen
This allows us to verify our migration.
Results Summary
Note the DMO queries that will build the customers table
Logging in to SQL Azure
Our database up in the cloud (previously created)
It is time to execute
Execution in progress
Success !
Modify web.config
Make changes to reflect your connection string
Running our application as a final test of success
Don Quixote would say, “The proof of the pudding is the eating."
Done !