รับทำเว็บไซต์ครบวงจร
เลือกภาษา Thai English     facebook
รายการหลัก



บทความ


Page Ranking Tool

Exercise 1: Preparing Your SQL Azure Account


สอน windows azure
> Exercise 1: Preparing Your SQL Azure Account


In this exercise, you will step through provisioning your new SQL Azure account. We’ll then connect to that account and create a database, add a new user and then reconnect to SQL Azure so that we can begin working with our database. It is assumed that you already have already obtained a SQL Azure Token, if you have not you can request one fromhttp://www.azure.com

Note:
 As of the October CTP all accounts are created on the Production cluster. Databases and servers that were created during the August CTP can be accessed via the portal at https://ctpportal.database.windows.net/. Additionally, previous documentation instructed all connections to point to <server>.ctp.database.windows.net as of the October CTP connections should be made to the Production cluster at <server>.database.windows.net.

Task 1 – Provisioning a SQL Azure Account

  1. Go to the website https://sql.azure.com
  2. Login to your Windows Live account.

    Figure 1 Logging into the Azure Services Portal

  3. Type in your invitation code and then click Submit.

    Figure 2 Entering a SQL Azure Token

  4. Read the terms of use then click then Accept button.

    Figure 3 Accepting the Terms of Use

  5. Fill in an admin account name, password and region, and then click Create Server. The Location determines which datacenter the database will reside in.

    Figure 4 Create a server and set administrator passwords.

    Note:
    An admin account is a master account used for administering the new server. This should not be used in connection strings where the username and password may be exposed. The password policy requires that this password contain at least one number, one character and one letter and one symbol. In addition, the password cannot be less than six characters nor contain three consecutive characters from the username.

  6. The virtual server should now be created and a list showing your projects should be displayed. To view the databases on the virtual server click the project.

    Figure 5 SQL Azure Projects List

  7. The Server Administration screen allows basic administration of the database server and allows a quick way of viewing the available connection strings.

    Figure 6 SQL Azure Server Management .Your server fully qualified domain name will take the following format: <ServerName>.database.windows.net.

  8. The new firewall features allows a customer to specify an allow list of IP address that can access their SQL Azure Server. Your firewall will deny all connections by default, so be sure to configure your allow list so that existing clients can continue to connect.

    Figure 7 SQL Azure Server Management – Firewall Settings

    Note:
    The application of your firewall settings can take a few moments

    You now have a database server created and ready for the next steps in this lab. This database can be connected to from anywhere in the world.

Task 2 – Connecting to SQL Azure and Creating a Database

  1. Open SQL Server Management Studio. Start > All Programs > SQL Server 2008 R2 > SQL Server Management Studio. You will be presented with a logon dialog.

    Figure 8 SQL Server Management Studio Default Connection Dialog

  2. Enter your login information that you created in Task 1. Click Connect.

    Ensure that you select SQL Server Authentication. SQL Azure currently only supports SQL Server Authentication. Click on the options tab, and specify the database to connect to as master. Click Connect

    Note:
    Please replace server name with your assigned server, i.e. REPLACE_SERVER_NAME.database.windows.net

    Figure 9 Connecting to SQL Azure

    Figure 10 Connect to master database

  3. You should now see in your Object Explorer the structure of your database. Notice that your SQL Azure database is no different to an on premise relational database.

    Figure 11 The Object Explorer

  4. Click the New Query button. This will open a similar dialog requesting logon information.

    Figure 12 Creating a New Query Window

  5. We now have a query window with an active connection to our account. We can test our connection by executing the @@version procedure. Type SELECT @@version into the query window and press the Executebutton. You will get a scalar result back, which indicates the edition as Microsoft SQL Azure.

    Figure 13 Retrieving the SQL Azure version

  6. Replace the previous query with a new query SELECT * FROM sys.databases and click Execute

    Figure 14 As you can see, we just have our Master database now.

  7. Next, we will create a new Database. One of the good things about SQL Azure is that it takes care of much of the management of our database for us including how to manage the underlying data files. This means that ourCreate Database statement can be very simple. Type Create Database HoLTestDB and click Execute

    Figure 15 Creating a New Database

    Note:
    We can select which SQL Azure Database edition (Web or Business) is created during the database provisioning process. This is surfaced both in the SQL Azure Portal and in the T-SQL Create Database statement. For example, to create a Business Edition database the T-SQL command would be as follows: CREATE DATABASE HolTestDB (MAXSIZE = 10GB). Once a database has been created, the database size will not be able to be changed.

  8. Remembering from above that there is a system view called sys.databasesExecute the query SELECT * FROM sys.databases.

    Figure 16 Querying the sys.databases view

    Note:
    The USE <database_name> command does not work with SQL Azure. Therefore, you need to disconnect and reconnect in order to change from the Master database to the new user database you just created.

  9. Close the existing Query tab. And disconnect from the master database by right clicking the server in the object explorer

    Figure 17 Disconnect from the master database

  10. To start up a new connections click the New Query button. The Connect to Server dialog will open. If necessary, retype your credentials. Click the Options button to expand the options panel and choose to Connect to DatabaseHoLTestDB. You will need to type this rather than using the dropdown box

    Figure 18 Connecting to a specific named database

  11. To check that we are now in the context of our User database execute the query select db_name()

    Figure 19 Querying the database currently in use.

Task 3 – Creating a Logins and Database Users

Much like SQL Server, SQL Azure allows us to create additional logins and then assign those logins as users with permissions on a database. In this task, we will create a new login and then create a user that uses the new login in ourHoLTestDB database.

  1. Connect to the master database again by following the steps in the previous task. You may need to clear theConnect to Databasecombo box from the Options tab.
  2. Create a new Login, and User in the for your new login in the db_ownerrole, by executing the following
    CREATE LOGIN HoLUser WITH password='Password1'
    GO
    
    Note:
    You should choose your own password for this login account and use it where appropriate throughout the lab. If you do not choose a unique password you should ensure that you DROP Login HoLUser when you have finished the lab

  3. Disconnect by right clicking your server in the object explorer and selecting Disconnect
  4. Reconnect to the HoLTestDB by clicking Connect->Database Engine in the object explorer. Enter your admin credentials and specify the database name in the connection properties tab.

    Figure 20 Connecting to HoLTestDB

  5. Create a user from the login HoLUser
    -- Create a new user from the login and execute
    CREATE USER HoLTestUser FROM LOGIN HoLUser
    GO
    
    
    Note:
    You should choose your own password for this login account and use it where appropriate throughout the lab. If you do not choose a unique password you should ensure that you DROP Login HoLTestUser when you have finished the lab

  6. Close the Query tab.
  7. Add the user to the db_owner role of your HoLTestDB by right clicking on your HolTestDB in your object explorer and selecting New Query and execute the following.
    -- Add the new user to the db_owner role and execute
    EXEC sp_addrolemember 'db_owner', 'HoLTestUser'
    GO
    
  8. Note:
    By making, our user a member of the db_owner role we have granted a very extensive permission set to the user. In a real world application you should be careful to ensure that you grant users the smallest privilege set possible

  9. Close the Query tab once again.
  10. Reconnect to the database you created (HoLTestDB) but this time use your new HoLUser login. We will be using this login for the rest of the lab.
  11. Execute the following query
    SELECT @@version
    


  12. Short URL click!
    << กลับคืน : เข้าชม 3,568 ครั้ง : ขึ้นไปด้านบน

รับทำเว็บไซต์ รับสร้างเว็บไซต์ รับออกแบบเว็บ รับเขียนเว็บ รับสอนทำเว็บ รับเช่า hosting รับเช่าพื้นที่เว็บไซต์ จดชื่อเว็บ รับโปรโมทเว็บไซต์ รับดูแลเว็บ SiteMap
สปริงเกอร์http://www.xn--22c2c4blb9n.xn--o3cw4h/