Q100. Build a Windows Azure Application that works with SQL Database?
Create a Visual Studio Project - Cloud application
Open Microsoft Visual Studio and from the File menu, choose New and then Project. In the New Project dialog, expand Visual C# in the Installed Templates list and select Cloud. In the Templates list, select Windows Azure Cloud Service. Set the name of the project to “SqlDatabaseTestApp”. Click OK to create the project.
Refer Figure. In the New Windows Azure Project dialog, inside the Roles panel, expand the tab for Visual C#, select ASP.NET Web Role from the list of available roles and click the right button (>) to add an instance of this role to the solution. Click OK to create the Cloud service solution.
Open Default.aspx page in Design View by clicking the Design button which you can find at the bottom of the screen. Drag and drop a GridView control from the Data section of the Toolbox on to the design canvas. The result screen is shown below.
In the Data Source Configuration Wizard, choose a data source type of Database and specify the name to the data source. Click the OK button to display the Configure Data Source dialog.
In the Configure Data Source dialog, click New Connection. Now, you can configure a connection to your SQL Database. In the dialog, choose Microsoft SQL Server (SqlClient) in the Data Source list Then set the Server name to the name of your SQL Database. Next, change the authentication type to ‘Use SQL Server Authentication’ and type the credentials for your SQL Database. Finally, enter SOMDb in the database name drop down list.
Continue with the Data Source Configuration Wizard and save the connection string to the Application Configuration file. Next, configure the Select statement and then press Test Query and you can see results returned. Click Finish on the configure data source dialog. Press F5 to run the application in the compute emulator.
Open Microsoft Visual Studio and from the File menu, choose New and then Project. In the New Project dialog, expand Visual C# in the Installed Templates list and select Cloud. In the Templates list, select Windows Azure Cloud Service. Set the name of the project to “SqlDatabaseTestApp”. Click OK to create the project.

Refer Figure. In the New Windows Azure Project dialog, inside the Roles panel, expand the tab for Visual C#, select ASP.NET Web Role from the list of available roles and click the right button (>) to add an instance of this role to the solution. Click OK to create the Cloud service solution.
Open Default.aspx page in Design View by clicking the Design button which you can find at the bottom of the screen. Drag and drop a GridView control from the Data section of the Toolbox on to the design canvas. The result screen is shown below.

In the Data Source Configuration Wizard, choose a data source type of Database and specify the name to the data source. Click the OK button to display the Configure Data Source dialog.
In the Configure Data Source dialog, click New Connection. Now, you can configure a connection to your SQL Database. In the dialog, choose Microsoft SQL Server (SqlClient) in the Data Source list Then set the Server name to the name of your SQL Database. Next, change the authentication type to ‘Use SQL Server Authentication’ and type the credentials for your SQL Database. Finally, enter SOMDb in the database name drop down list.

Continue with the Data Source Configuration Wizard and save the connection string to the Application Configuration file. Next, configure the Select statement and then press Test Query and you can see results returned. Click Finish on the configure data source dialog. Press F5 to run the application in the compute emulator.
See More Questions and Answers on - Azure SQL Server
- Two models of using SQL Server in the cloud
- Choose between SQL Server in vm and sql database
- How to access data in Azure sql databas
- Create and configure SQL database server in the cloud
- How to configure the SQL database firewall
- How to connect SQL database instance with SQL Server management studio
- How to connect to a SQL database with ado.net
- Connect to Azure sql database using the ado.net entity framework