Create Your Next Application and Database in the Cloud
page 4 of 6
by Vince Varallo
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 24911/ 60

Step 3: Create a New Solution

1.    Launch Visual Studio 2010.

2.    Select FileàNew Project… from Visual Studio's menu.

3.    Expand the Visual C# templates and click on the Cloud node.  You should see the Windows Azure Cloud Service template.

4.    Change the name of the project to "ASPAllianceSample" and click the OK button.

5.    The "New Cloud Service" dialog box should appear.

6.    Click on the ASP.NET Web Role in the left pane and click the > arrow to move it to the right pane.  This allows you to create a traditional ASP.NET web site for the cloud.  You can create a MVC web site, WCF service, background process or GCI application but for this example we'll stick with the traditional ASP.NET web site.

7.    Click the OK button.

8.    Visual Studio will add a whole bunch of standard files for a typical ASP.NET application. Some of these files include a master page, the login and password management pages, a style script, an about page, and a scripts folder. 

9.    Click the run button to start the project.  You should get the following message.

10. To remedy this you need to close Visual Studio and then launch Visual Studio again as an administrator.  You can do this by clicking on StartàAll ProgramsàMicrosoft Visual Studio 2010 and then right click on Microsoft Visual Studio 2010.  Select "Run as administrator" from the pop-up menu.  Now you need to open the ASPAllianceSample project again.

11. Now try running the project again.  If you don't have SQL Express installed you'll get the following message.

12. The Output window will give you a more descriptive message.

"Windows Azure Tools: Failed to initialize Development Storage service. Unable to
start Development Storage. Failed to start Development Storage: the SQL Server 
instance ‘localhost\SQLExpress’ could not be found.   Please configure the SQL
Server instance for Development Storage using the ‘DSInit’ utility in the Windows 
Azure SDK."

13. To fix this open the Windows Azure SDK Command Prompt.  This is found at StartàWindows Azure SDK v1.2àWindow Azure SDK Command Prompt.

14. Enter the following in the command window.

dsinit /sqlinstance:.

15. You should see the following dialog.


16. Click the OK button and then run the project again.  You should see the following web page.

17. Close the browser to stop debugging.  Now we'll add a GridView control to the default page that displays the records in the Person table in our database in the cloud.

18. Open the Default.aspx page in design mode and drag a GridView control from the toolbox to anywhere on the page.

19. When the GridView is dropped on the page the GridView Task window should appear which allows you to configure the control.  Select <New data source…> from the "Choose Data Source:" drop down list.  The "Data Source Configuration Wizard" will appear.

20. Select "SQL Database" from the list of sources and change the ID to SampleDB.

21. Click the OK button.  The "Configure Data Source" window will appear. 

22. Click the "New Connection" button.  This will display the "Add Connection" window.

23. The server name should be the server name where your cloud database is located.  To figure this out you can go back to the Database Manager.  To do this open your browser and navigate to  You need to log into your account and then click on the "Database" icon on the left pane in the dashboard.

24. The "Subscriptions" should appear on the left hand side of your screen.  Expand your subscription.  This will display your servers.  Expand your servers and you should see the "SampleDB".  Click on this node and then click the "Manage" icon in the toolbar.

25. The Database Manager will appear and your server name is displayed in the "Server" input box.  Copy this value and go back to Visual Studio to enter this name in the Connection server name.

26. Change the authentication type to "Use SQL Authentication" and enter the user name and password you created when you created the database.

27. Change the database to SampleDB by selecting it from the list in the "Connect to a database" section.

28. If you click the "Test Connection" button you should get a "Test connection succeeded" message if you've entered the correct information.

29. Now click the OK button.  This will bring you back to the "Configure Data Source" window.

30. Click the "Next" button.

31. Keep the box checked that says "Do you want to save the connection in the application configuration file?"  Click the "Next" button.

32. The next screen allows you to specify the table and the fields you want to select from the database.  The "Person" table should appear in the list of tables or views.  This table should already be selected but if it isn't you should select it.

33. The ID, FirstName, LastName, and Email fields should be listed in the columns list.  Leave the "*" selected so all the fields are returned.

34. Click the "Next" button.

35. The next screen allows you to test your query.  If you click the "Test Query" button you should see the data in your table.

36. Click the "Finish" button.

37. Run the application again and you should see the Default page with the data from the table.

Now that you have that working we can deploy this to the cloud.  You don't have to deploy it to the cloud.  You can just stop here and deploy it to your local production servers and leave the database hosted in the cloud but for those of you interested in how to deploy the application to the cloud read on.

View Entire Article

User Comments

Title: garland.kg69@asp.alliance/com   
Name: Kenneth A Garland III
Date: 2011-03-04 12:53:26 PM
I wish to have my own web-site in the cloud .
Title: Cloud at GoDaddy   
Name: Kevin Tweedy
Date: 2011-01-25 5:19:44 PM
Does anyone have any experience with the Cloud at a GoDaddy hosted area? None of their "Help" [s.i.c.] files reference the Cloud at all and in the past they've been extremely lagging in getting with "the latest and greates". Any pointers, info?

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-06-23 7:18:12 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search