This article will show how to set up the Adventure-works database using the Microsoft Azure Cloud.
The following tutorial is divided into four parts:
Let’s get started:
You need 3 things in order to reproduce this example:
1. A Microsoft Azure Subscription. If you do not have one, you can get a free trial subscription for one month and 200 CHF at: http://azure.microsoft.com/en-us/pricing/free-trial/
2. A computer with an installation of the .NET framework in version 4. If you run Windows 8, you are set. If you run an earlier version and .NET 4.0 is not installed, you can get it at the Microsoft Download Center: http://msdn.microsoft.com/en-us/vstudio/aa496123
3. The Azure db must be accessible from your client computer. This is a configuration setting in the Azure Management Dashboard. Details can be found below. Note that currently there are two Azure Portals. The old one under https://manage.windowsazure.com and the new one under https://portal.azure.com. For simplicity, I am going to use the old one.
After you have created your Microsoft Azure account, go to the management portal: http://manage.windowsazure.com and log in.
On the portal, select SQL DATABASES from the navigation on the left hand side:
Once you are on the SQL DATABASES page, click SERVERS on the top navigation:
Finally, click the ADD button at the bottom:
The CREATE SERVER wizard will pop up, fill in the fields and confirm. Select a region that is close to your location.
After some time, it took about 30 seconds for me, your database server is ready to go! Click the little arrow on the right of the server name to proceed to the server settings:
On the following page, click CONFIGURE and then click the arrow on the right, where it says “ADD TO THE ALLOWED IP ADDRESSES”. This configuration is vital since it allows your local machine, where the browser is running, to access the database server. IMPORTANT: Do not forget to hit the save button, once completed!
Note the server name and the credentials that you specified and we can go on with the next step. Alternatively, you can navigate to the DASHBOARD page and copy the MANAGE URL from there.
Navigate to http://msftdbprodsamples.codeplex.com/releases/view/37304 and download the “AdventureWorks2012ForWindowsAzureSqlDatabase” file. Save and extract the zip file.
Open a CMD prompt with administrative privileges and navigate to the directory where you unzipped the package and there into the \AdventureWorks directory.
Enter the following command:
CreateAdventureWorksForSqlAzure.cmd <servername> <username> <password>
Important Hints! Make sure you enter the name as “username@servername”. Providing the username only can lead to problems during the installation. Additionally, you have to use the full server name, as in: zvnhp88skk.database.windows.net. Example:
CreateAdventureWorksForSqlAzure.cmd zvnhp88skk.database.windows.net mme@zvnhp88skk.database.windows.net mypassword
After roughly 5 minutes, the script should show “Installation Completed”. That’s it, your database is up and running.
You can use any SQL Server tool, such as Visual Studio or the SQL Server Management Studio to connect to your DB and verify that the data is there. I would like to show a very simple approach using SqlCmd.exe. SqlCmd is shipped with Visual Studio and the easiest way to use sqlcmd.exe is by using the Visual Studio Command Prompt. Run the following command inside the VS command prompt:
sqlcmd.exe –S <servername> –d <db name> –U <username> –q <query>
or, in our case:
sqlcmd.exe –S zvnhp88skk.database.windows.net –d AdventureWorks2012 –U mme@zvnhp88skk –q “select top 10 firstname, lastname from person.person”
If you see 10 records that contain names, the data is there and we are done!
Important hint: Always keep in mind that Microsoft Azure is based on a pay-as-you go policy and you will be charged on a per-minute base for your database instance! If you don’t need it, shut it down!