SQL Azure Database Windows Azure SQL Database is a feature-rich, fully managed relational database...

30
Windows Azure SQL Database

Transcript of SQL Azure Database Windows Azure SQL Database is a feature-rich, fully managed relational database...

  • Slide 1
  • Slide 2
  • SQL Azure Database Windows Azure SQL Database is a feature-rich, fully managed relational database service that offers a highly productive experience, incorporates proven SQL Server technology, and delivers business-class capabilities. SQL Database allows customers to scale business apps for burst and global reach by removing the high costs of building an infrastructure which would accommodate occasional peak loads.
  • Slide 3
  • SQL Azure Database Customers can also remove the security risks and hassles associated with hosting public-facing apps & websites from within a datacenter by quickly & cost-effectively building websites and mobile & social apps directly on SQL Database.
  • Slide 4
  • Step 1: Create a Windows Azure account Open a web browser, and browse to http://www.windowsazure.com. To get started with a free account, click free trial in the upper right corner and follow the steps. Your account is now created. You are ready to get started.
  • Slide 5
  • Step 2: Connect to Windows Azure and create a database Sign in to the Management Portal. You should see a navigation pane that looks like this.
  • Slide 6
  • Slide 7
  • Click New at the bottom of the page. When you click New, a list rolls up the screen showing things you can create. Click SQL Database and then click Custom Create. Choosing this option lets you create a new server at the same time, with you as the administrator. As the system administrator, you can perform more tasks, including connecting to the Management Portal for SQL Database, which you will do later in this tutorial.
  • Slide 8
  • Slide 9
  • The Database Settings page appears when you click Custom Create. In this page, you provide basic information that creates an empty database on the server. Adding tables and data will come in a later step. Fill out the Database Settings page as follows:
  • Slide 10
  • Slide 11
  • Slide 12
  • Step 3: Configure the firewall To configure the firewall so that connections are allowed through, you'll enter information on the server page. Note: The SQL Database service is only available with TCP port 1433 used by the TDS protocol, so make sure that the firewall on your network and local computer allows outgoing TCP communication on port 1433. For more information, see SQL Database Firewall.
  • Slide 13
  • In the navigation pane on the left, click SQL Databases. Click Servers at the top of the page. Next, click on the server you just created so that you see a white arrow to the right. Click on the arrow to open the server page.
  • Slide 14
  • Slide 15
  • Slide 16
  • Copy the current client IP address. This is the IP address that your router or proxy server is listening on. SQL Database detects the IP address used by the current connection so that you can create a firewall rule to accept connection requests from this device. Paste the IP address into both the beginning and end range. Later, if you encounter connection errors indicating that the range is too narrow, you can edit this rule to widen the range. Enter a name for the firewall rule, such as the name of your computer or company. Click the checkmark to save the rule. After you save the rule, your page will look similar to the following screenshot.
  • Slide 17
  • Slide 18
  • To create a table and add data follow the steps next
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data.SqlClient; using System.Data;
  • Slide 27
  • private static string userName = "SQLServer"; private static string password = "gsmenergy@123"; private static string dataSource = "gct870i4ka.database.windows.net"; private static string sampleDatabaseName = "ContactsDB";
  • Slide 28
  • SqlConnectionStringBuilder connString1Builder; connString1Builder = new SqlConnectionStringBuilder(); connString1Builder.DataSource = dataSource; connString1Builder.InitialCatalog = "ContactsDB"; connString1Builder.Encrypt = true; connString1Builder.TrustServerCertificate = false; connString1Builder.UserID = userName; connString1Builder.Password = password;
  • Slide 29
  • using (SqlConnection conn = new SqlConnection(connString1Builder.ToString())) { using (SqlCommand command = conn.CreateCommand()) { conn.Open(); command.CommandText = "SELECT * FROM contacts"; using (SqlDataReader reader = command.ExecuteReader()) { // Loop over the results while (reader.Read()) { Console.WriteLine("{0}, {1}, {2}, {3}, reader["ID"].ToString(),reader["FirstName"]. ToString(), reader["LastName"].ToString(), reader["ContactNO"].ToString()); }
  • Slide 30
  • Console.ReadKey(); conn.Close(); }