+ All Categories
Home > Documents > 06387c12_online Azure SQL

06387c12_online Azure SQL

Date post: 06-Apr-2018
Category:
Upload: joel-paredes
View: 250 times
Download: 0 times
Share this document with a friend

of 22

Transcript
  • 8/3/2019 06387c12_online Azure SQL

    1/22

    Managing SQL AzureAccounts and Databases

    SQL Azure is the SQL Server teams name for a set of highly scalable cloud services based on acustomized version of SQL Server 2008 and related services hosted in Microsoft data centers. SQLAzure is intended to provide the capabilities of an enterprise-grade data center without the capitalcost of its physical facilities or the operating expenses for its management or maintenance, as wellas server and database license fees. SQL Azure provides high availability by replicating a total ofthree redundant copies of your data to separate physical servers. SQL Azure achieves scalabilitywhile maintaining transactional consistency by partitioning data into individual 10GB or smallerdatabases.

    When this chapter was updated in January 2010, only the first of these services SQL AzureDatabase (SADB) v1, a scalable and available relational database had been released as a com-mercial product. Ultimately, SQL Azure will consist of the following services:

    SQL Azure Database to provide core SQL Server database capabilities (released duringPDC 2009).

    Azure Data Sync to enable synchronizing cloud and on-premises SQL Server and SQLAzure databases with the Microsoft Sync Framework. Chapter 13 describes AzureData Sync.

    Business Intelligence (BI) and Reporting Services (RS) with no current CTP or releasetimetable.

    This chapter concentrates on creating a SQL Azure account, getting connected to an SADB v1 server,and creating user databases with SQL Server Management Studio (SSMS) 2008 R2 November 2009CTP [Express] and the sqlcmd utility. This chapter was written after SADB released to the Web(RTW) as a commercial product with service fees. When you connect to the commercial version,the credit card you specify when creating your account will be charged US$9.99 per month for adatabase size up to 1GB (Web Edition) and US$99.99 per month for up to 10GB of space (BusinessEdition), plus US$0.10 per GB of data ingress and US$0.15 per GB of data egress.

  • 8/3/2019 06387c12_online Azure SQL

    2/22

    Part IV: Working with SQL Azure Services

    Microsoft offers several discounted service plans, which offer free Windows Azure compute and storagequotas; an SADB account with varying numbers of databases; as well as data ingress, egress, Service BusConnections, and Access Control Transactions. These plans are described in the Windows Azure Pric-ing Info page (http://bit.ly/1TeCsu, http://www.microsoft.com/windowsazure/offers/ ).Registered members of Microsofts Partners Network receive additional discounts, and MSDN Premiumsubscribers receive substantially larger free quotas. Links on the Azure Pricing Info page lead to more

    information about these additional benefits.

    Tracking SSDSs Migration to a Relational

    DatabaseRay Ozzie announced SQL Server Data Services (SSDS) at the MIX08 conference in Las Vegas duringhis March 5, 2008, keynote address. SSDS became available as a CTP later in the first half of 2008 andprovided an on-demand, pay-per-use data model, which offered the following features:

    A flexible, schemaless entity model that lets users add new attributes to the entity type when

    needed; the system indexes the attributes automatically. Simplified data types for attribute values: string, numeric, datetime, boolean, and binary.

    REST-based and LINQ-like queries; SOAP was also supported.

    Plain old XML (POX) was the only wire format then available; AtomPub was promised.

    No projections; the unit of storage was a complete entity.

    Highly scalable by partitioning of sizes in the tens of GB.

    Secure data access with SSL, LiveID authentication, and authorization at the account (billingunit), authority (collection of containers), container (set of entity sets), and type (entity type)levels.

    A promise of data synchronization and bulk uploads with the Microsoft Sync platform.

    For more background on the MIX08 SSDS announcement and early reaction to SSDS in the computertrade press, see the SQL Server Data Services to Deliver Entities from the Cloud post of March 7,2008, to the OakLeaf blog (http://bit.ly/SJydJ, http://oakleafblog.blogspot.com/2008/03/sql-server-data-services-to-deliver.html ) and Spelunking SQL Server Data Services(http://bit.ly/gS7RR, http://oakleafblog.blogspot.com/2008/03/spelunking-sql-server-data-services.html).

    The initial SSDS architects chose the Entity-Attribute-Value (EAV) data model implemented bya hierarchical set of Authority, Container, and Entity (ACE) objects, rather than the traditionalrelational data model because EAV databases could scale out to extreme sizes, typified by Googles

    BigTable and Yahoo!s Hadoop examples. The problem with this approach was the difficulty thatpotential customers encountered when attempting to distinguish SSDS tables from the similar EAVtables offered by Azure Data Services. Further, the Azure marketing team was strongly promotingthe benefits of leveraging developers experience with .NET programming and Visual Studio toease the burden of migrating conventional ASP.NET applications and .NET-based services fromon-premises data centers to those in the cloud. Developers and their management were more interestedin leveraging their relational database design and Transact-SQL (T-SQL) query skills than the potentialfor increased scalability. Architects and developers also had misgivings about the eventual consistency

    2

  • 8/3/2019 06387c12_online Azure SQL

    3/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    properties of EAV tables rather than the immediate, transactional update consistency of SQL Serveclusters.

    On October 27, 2008, Ray Ozzie announced that Windows Azure would be the name of Microsofts newPlatform as a Service (PaaS) cloud computing contender. SSDS was renamed SQL Data Services (SDSat PDC 2008.

    Microsofts marketing folks are well known for listening intently to their users, including mil-lions of developers, and acting on user feedback. The SSDS team finally understood theerror of their EAV approach about one year later and announced a mid-course correction totheir SSDS plans on March 10, 2009. Also on that day, David Robinson, this books techni-cal editor, added The no spin details on the new SDS features post (http://bit.ly/AW3Jm,http://blogs.msdn.com/ssds/archive/2009/03/10/9469228.aspx ) to whats now the SQL AzurTeam Blog:

    Today we announced the details of our plans to accelerate the delivery of core rela-tional database features as part of SDS. There has been quite a bit of buzz about SDSover the past couple weeks and it is great to be able to share the details more broadly.

    If we flash back about a year ago to Mix 08, Nigel Ellis got up on stage to introduce thecommunity to SDS which, at the time, was a flexible entity based cloud database thatyou accessed using standard internet protocols. We made this announcement with thepromise that more relational capabilities would be coming and they did. But theuniversal feedback we received from our TAP partners and other early adopters wasthe need for a relational database delivered as a service. This was extremely valuablefeedback and drove us to more aggressively investigate ways in which we coulddeliver these features. As a result of that work and based on the progress weve sincemade in the product team, we are announcing that SDS will deliver full relationaldatabase capabilities as a service.

    The SDS team changed its name and rebranded the service to SQL Azure on July 9, 2009.

    For additional details about SDSs change from the EAV to relational data model, see the Febru-ary 24, 2009, A Mid-Course Correction for SQL Data Services (http://bit.ly/85YOa,http://oakleafblog.blogspot.com/2009/02/mid-course-correction-for-sql-data.html )and the March 10, 2009, SQL Data Services Abandons REST for TDS API and Knocks My Socks Off(http://bit.ly/gWgyB, http://oakleafblog.blogspot.com/2009/03/sql-data-services-abandons-rest-for-tds.html) posts.

    Reviewing Current SQL Azure Database

    Documentation and ResourcesMSDNs SQL Azure Database documentation, which is available online at http://bit.ly/12N3Mphttp://msdn.microsoft.com/en-us/library/ee336279.aspx , contains the following chapters:

    Introducing SQL Azure Database

    SQL Azure Database Concepts

  • 8/3/2019 06387c12_online Azure SQL

    4/22

    Part IV: Working with SQL Azure Services

    Developers Guide

    Guidelines and Limitations

    Transact-SQL Reference

    SQL Azure Database Copyright and Legal Information

    The Transact-SQL Reference chapter is especially useful because it contains lists of supported, partiallysupported, and unsupported T-SQL reserved words.

    The Windows Azure team released the Windows Azure Platform Training KitDecember [2009] Updatefor downloading on December 23, 2009, at http://bit.ly/3Nwdbn, http://www.microsoft.com/downloads/details.aspx?FamilyID=413E88F8-5966-4A83-B309-53B7B77EDF78&displaylang=en . Thekit offers the following SQL Azure Databasespecific elements in .pptx, .docx, or .htm format:

    Presentations

    What is SQL Azure?

    Introduction to SQL Azure

    Building Applications using SQL Azure

    Scaling Out with SQL Azure

    Demonstrations

    Preparing Your SQL Azure Account

    Connecting to SQL Azure

    Managing Logins and Security in SQL Azure

    Creating Objects in SQL Azure

    Migrating a Database Schema to SQL Azure Moving Data Into and Out Of SQL Azure using SSIS

    Building a Simple SQL Azure App

    Scaling Out SQL Azure with Database Sharding

    Hands On Labs

    Migrating Applications to Windows Azure

    Introduction to SQL Azure

    Migrating Databases to SQL Azure

    Demonstrations and Hands-On Labs require a sample database, so you must have a commercial SQLAzure account in which to create the database.

    You can find the SQL Azure Getting Started forum at http://bit.ly/ARCwN, http://social.msdn.microsoft.com/forums/en-US/ssdsgetstarted/threads/ .

    4

  • 8/3/2019 06387c12_online Azure SQL

    5/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    Creati ng or Upgradi ng Wi ndows Azure and

    SQL Azure AccountsThe Windows Azure Platform team designated January 4, 2010, as the date for commercial release Windows Azure, SADB, and Azure AppFabric with the following announcements:

    Windows Azure Team blog (http://bit.ly/6HsovV, http://blogs.msdn.com/windowsazuarchive/2010/01/04/sign-up-for-a-windows-azure-platform-offer-today-and-get-

    visibility-into-your-usage.aspx )

    SQL Azure Team blog (http://bit.ly/61OS6H, http://blogs.msdn.com/ssds/archive/201/04/9943474.aspx)

    Windows Azure Platform AppFabric Team Blog (http://bit.ly/6a9xuS, http://blogs.mcom/netservices/archive/2010/01/04/announcing-windows-azure-platform-commerci

    offer-availability-and-updated-appfabric-pricing.aspx )

    The following procedure will create new commercial Windows Azure, SADB, and Azure AppFabr

    (formerly .NET Services) accounts with the Windows Live ID, or if you use the Live ID account wiwhich you created free CTP accounts, it will upgrade the CTP accounts and their projects to commestatus.

    The procedure and screen captures that follow are based on the OakLeaf Blogs How to Create and Activate a New Windows Azure and SQL Azure Account or Upgrade an Existing Account post of 1/5/2010(http://bit.ly/4riEfv, http://oakleafblog.blogspot.com/2010/01/how-to-create-and-activate-introductory.html).

    1. Log in to the Windows Azure Development Portals SQL Azure Project Viewer page(http://bit.ly/4riEfv, https://sql.azure.com/ProjectViewer.aspx ) with yourWindows Live ID, and click the Billing link at its upper-right corner (see Figure 12-1) t

    open the Microsoft Online Services Customer Portal (MOCP) landing page.

    Figure 12-1: The Billing link of the SQL Azure

    Project Viewer page.

    Alternatively, browse directly to the MOCP landing page (http://bit.ly/nPKPg,https://mocp.microsoftonline.com/site/default.aspx ) and click Continue to open

    Getting Started page (see Figure 12-2).

    2. If you arent signed in, click the Sign In link, and sign in with your Windows Live ID. Iyoure creating a new account, you must complete Contact Information, Company Infomation, and Service Usage Address forms.

    3. Click the Services tab and click the Windows Azure Platform link (see Figure 12-3).

  • 8/3/2019 06387c12_online Azure SQL

    6/22

    Part IV: Working with SQL Azure Services

    Figure 12-2: The Microsoft Online Services Customer Portals Getting

    Started page.

    Figure 12-3: The Services tab for Applying the Windows Azure

    Platform filter.

    4. Click any Rate Plan link to open a Pricing Info page (see Figure 12-4).

    5. If you dont qualify for a Partner Network discount or MSDN Premium special offer, clickthe Buy button for one of the three free or paid accounts, complete, and skip to step 8.

    (The Windows Azure Platform Introductory Special offers very limited compute hours andsmall storage quotas at no charge. The two paid plans require agreement to a six-month sub-scription duration.)

    6

  • 8/3/2019 06387c12_online Azure SQL

    7/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    Figure 12-4: One of Windows/SQL Azures four Pricing Info pages.

    6. If you have an MSDN Premium subscription, click the Special Offers for MSDN WindoAzure Platform Benefits link to open the Windows Azure Platform Benefits for MSDN Sscribers page (see Figure 12-5).

    Figure 12-5: This page explains temporary discounts offered to MSDN

    subscribers.

    7. Scroll to the grid at the bottom of the page to learn details of the introductory benefit plathe first eight months and three levels of ongoing plans when the introductory plan exp

    8. Click the My Account link to open the My Account page (see Figure 12-6).

  • 8/3/2019 06387c12_online Azure SQL

    8/22

    Part IV: Working with SQL Azure Services

    Figure 12-6: The My Account page confirms your MSDN subscription

    and presents a Windows Azure Platform link.

    9. Click the Windows Azure Platform link to open the MOCP Subscriptions Shopping Cartpage, which has the Windows Azure Platform MSDN subscription details added whereappropriate MSDN Premium for this example (see Figure 12-7).

    Figure 12-7: The Shopping Cart pages Billing Information pane

    indicates the MSDN benefit appropriate for your subscription level.

    8

  • 8/3/2019 06387c12_online Azure SQL

    9/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    10. Select the check box to acknowledge that you will be billed for usage over the allotment

    According to a post in the Windows Azure Platform, Web Hosting, and Web Services byou will be notified at your Windows Live ID e-mail when you reach 75 percent of yourcharge quotas.

    11. Click Checkout, provide your credit card data, if requested, and complete the transactio

    open the Review and Confirm Order page (see Figure 12-8).

    Figure 12-8: The Shopping Cart pane summarizes your

    subscription data.

    12. Click Confirm Order to open the Things I Need To Do page, and select Activate Now inlist (see Figure 12-9).

    Figure 12-9: Activate your account in MOCPs Things I Need To

    Do Page.

  • 8/3/2019 06387c12_online Azure SQL

    10/22

    Part IV: Working with SQL Azure Services

    13. If youre creating a new account, you must specify the Service Administrator name, e-mailalias, and password. When upgrading an account, the original Service Administrator cre-dentials will be used.

    14. Click Go to activate the subscription and add the new Subscription Name, which willbecome the Service Name, and to display the Service Activation Summary page (seeFigure 12-10).

    Figure 12-10: The Service Activation Summary page lets you review

    the activation details, including the portals that will be affected.

    15. Click Finish to complete the activation process. In a few minutes, youll receive a confirma-tion message at the e-mail alias of your Live ID account (see Figure 12-11).

    Apparently, the MOCP team didnt receive word that .NET Services was renamed WindowsApp Fabric at PDC 2009, as you can see in the e-mails third bullet point.

    16. Click the Developers Portals SQL Azure link to display the upgraded SQL Azure project(see Figure 12-12).

    17. If youre starting a new account with a different Windows Live ID, accept the Terms of Useto open the Create Server page, type a Server Administrator username and password, retypethe password, and select the Microsoft data center to provide your database(s) from the list(see Figure 12-13). The Server Administrator for the account corresponds to SQL Servers salogin.

    When this chapter was updated, only South Central U.S. (San Antonio, TX), NorthEurope (Dublin), and Southeast Asia (Singapore) data centers supported SQL Azureaccounts. Support for SQL Azure by additional Microsoft data centers in the U.S. andEurope is expected in early 2010.

    To prevent brute force attacks from succeeding with common user names, such as SA,Admin and Root, SQL Azure prevents use of these name.

    10

  • 8/3/2019 06387c12_online Azure SQL

    11/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    Figure 12-11: A message such as this one confirms

    your new or upgraded Windows Azure, SQL Azure,

    and Windows AppFabric (formerly .NET Services)

    accounts.

    Figure 12-12: The Windows Azure Summary page has links to your

    new or upgraded Windows Azure, SQL Azure, and Windows AppFabric

    (formerly .NET Services) accounts.

    18. For a new account, click Create Server to add the new SQL Azure server to the account.may take several minutes to complete and display the My Projects page.

    19. Click the Project Name OakLeaf Azure MSDN Subscription, for this example to opthe Server Administration page, which lists the CTP databases upgraded to commercia

  • 8/3/2019 06387c12_online Azure SQL

    12/22

    Part IV: Working with SQL Azure Services

    status, if any, as well as the master database for the account, which supports a single server(see Figure 12-14.)

    SQL Azure doesnt charge your account for the master database. The AdventureWorksLTdatabase shown in Figure 12-14 has only a few tables.

    Figure 12-13: Supplying Server Administrator credentials and

    selecting a data center for the server.

    Figure 12-14: Upgrading an existing SQL Azure CTP project upgrades

    the original databases.

    12

  • 8/3/2019 06387c12_online Azure SQL

    13/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    Setti ng Up the Server Fi rewal lSQL Azure servers provide a customizable firewall to control TCP/IP access to the server based oncallers IP address. The firewall also enables or disables access to the server by Windows Azure servsuch as Web and Worker roles.

    To enable Windows Azure services to access the new or upgraded server, open the Server Administrpage by clicking the SQL Azure vertical tab, click its Firewall Settings tab and mark the Allow MicroServices Access to This Server check box, which adds a MicrosoftServices rule with a default IP addrange from 0.0.0.0 to 0.0.0.0. This rule allows any Microsoft-hosted service to attempt to connect to server (see Figure 12-15.)

    Figure 12-15: Marking the check box enables any

    Microsoft-hosted service to attempt to connect to the

    SQL Azure server.

    To enable client applications to attempt to connect via the Internet to the server, click the Add Rule buto open the Add Firewall Rule form, then type a name for the rule and the range of IP addresses to ac(see Figure 12-16).

    The Add Firewall Rule form includes the IP address of the calling computer for reference. However, the

    Internet firewall is effective only for clients that have a fixed IP address. Most Internet service providers(ISPs) use the Dynamic Host Configuration Protocol (DHCP) to assign IP addresses from allocatedblocks to client computers. Unless you know the range of IP addresses that your ISP can assign, youmust allow all incoming addresses by specifying a range from 0.0.0.0 to 255.255.255.255.

    Firewall settings are cached for five minutes, so changes might not appear immediately.

    Figure 12-16: Enable client applications to attempt to

    connect to the SQL Azure server by specifying the

    allowable range of IP addresses.

  • 8/3/2019 06387c12_online Azure SQL

    14/22

    Part IV: Working with SQL Azure Services

    Creati ng a User DatabaseOn the My Projects page, click an item in the Project Name column to open the Server Administrationpage, which lets you add databases to or drop them from the server. Click Create Database to open adialog that lets you name the user database (see Figure 12-17).

    The Server Administration page connects to the selected servers default master database. SQL Azureassigns a DNS-compatible name to the server. SQL Azure doesnt permit database administrators orusers to add objects directly to master.

    Figure 12-17: The SQL Azure Portals Server Administration page for adding

    or dropping user databases.

    Type the user database name and click Create to close the dialog, add the user database to the server, andenable the Drop Database button when you select a user database (see Figure 12-18).

    Alternatively, you can create or drop a user database by opening the master database in SSMS 2008R2 [Express] and executing a CREATE DATABASE DatabaseName or DROP DATABASE DatabaseName T-SQLcommand.

    The later Connecting to SADB Master and User Databases with SSMS 2008 R2 [Express] sectiondescribes how to connect to databases with SSMS 2008 R2 [Express]. You cant connect to SQL Azuredatabases with SSMS 2005 [Express], and SSMS 2008 [Express]s Object Explorer doesnt display SQL

    Azure objects.

    14

  • 8/3/2019 06387c12_online Azure SQL

    15/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    Figure 12-18: The SQL Azure Portals Server Administration page after adding an

    empty Northwind user database.

    Clicking the Connection Strings button opens a message with ADO.NET and ODBC connection strifor the Master database that you can copy to the Clipboard:

    ADO.NET

    Server=tcp:k8jv7gpmwb.database.windows.net;Database=master;

    User ID=rogerj;Password=myPassword;Trusted_Connection=False;Encrypt=True;

    ODBC

    Driver={SQL Server};Server=tcp:k8jv7gpmwb.database.windows.net;Database=master;

    Uid=rogerj@k8jv7gpmwb;Pwd=myPassword;Encrypt=yes;

    The tcp: prefix specifies that the connection will use SQL Servers native Tabular Data Stream (TDS)protocol over TCP port 1433. SQL Azure connections are encrypted by default; the server will terminatethe connection if the client doesnt accept encryption.

    With a user database selected, click the Connection Strings button to open a message that con-tains examples of ADO.NET and ODBC connection strings for the selected user database (seeFigure 12-19).

    Click the ADO.NET entrys Copy to Clipboard link to save the connection string for use with on-premor Windows Azure clients.

  • 8/3/2019 06387c12_online Azure SQL

    16/22

    Part IV: Working with SQL Azure Services

    Figure 12-19: Connection strings for ADO.NET and ODBC drivers for the Northwind database.

    Testing Database ConnectivityClick the Test Connectivity button in the Server Administration screen to open the Database ConnectivityTest dialog, then type your Username and Password and click Connect (see Figure 12-20). You receive aSuccessfully connected to the database message if the test succeeds.

    The ability to migrate server connections from a local SQL Server 2008 [R2] [Express] instance to SADBin the cloud by simply changing the connection string is a widely publicized SADB feature.

    Figure 12-20: Testing SADB

    connectivity.

    Connecti ng to SADB User Databases wi th

    SSMS 2008 R2 [Express]SSMS 2008 R2 is the most convenient tool for executing single and batched T-SQL commands to themaster and user databases. The standard SSMS 2008 [Express] versions Object Browser feature isntcompatible with the SADB August 2009 CTP; youll also encounter error messages during the connectionprocess.

    SADB wasnt compatible with the Server Explorer feature of Visual Studio 2008 when this chapter wasupdated.

    You need SQL Server 2005 or 2008 [Express] to emulate SADB in projects that use the DevelopmentFabric. A standalone (Tools Only) version of SSMS 2008 R2 Express November 2009 CTP is available

    from http://bit.ly/2jfVw5, http://www.microsoft.com/downloads/details.aspx?FamilyID=c772467d-e45b-43e1-9208-2c7b663d7ad1&displaylang=en . SSMS 2005 [Express] doesnt workwith SADB.

    16

  • 8/3/2019 06387c12_online Azure SQL

    17/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    To connect to the SADB server that you provisioned in the preceding section with SSMS 2008 versio

    1. Launch SSMS 2008 R2 [Express], and click SSMSs New Query toolbar button to open tConnect to Database dialog.

    2. Accept the default Database Engine Server Type; copy the ADO.NET connection string

    ple to the Server Name text box, trimming the entry to the server name, including thet

    prefix; and (optionally) select the Remember Password check box.

    3. Select SQL Server Authentication in the Authentication list, and type the server administor credentials you created in the preceding section in the Login and Password text box(see Figure 12-21).

    Figure 12-21: Specifying SADB login

    parameters in the standard Connect to

    Server dialog.

    4. SADB doesnt support the T-SQL USE command and, therefore, requires you to specifythe database to which to connect. So, click the Options >>button to expand the dialogIn the Connect to Database combo box, accept the , or type master for the madatabase or the name of an existing user database, and select the Encrypt Connection ch

    box (see Figure 12-22).

    SADB connections are encrypted with Transport Level Security (TLS) by default, butmarking the Encrypt Connection check box will please your organizations data securityauditors.

    5. Click Connect to open the connection and click New Query to open the Query Editor paVerify that the database you specified in the preceding step is active by examining the hlighted status bar. Note that the toolbars Available Databases list is disabled.

    To run a test query against a system view, execute a SELECT * FROM sys.all_objects command(see Figure 12-23).

    To conserve resource consumption, SADB automatically closes connections after five minutes of inactivity. To reopen a closed connection click the Connect or Change Connection buttons at the extreme left ofthe SQL Editor toolbar.

  • 8/3/2019 06387c12_online Azure SQL

    18/22

    Part IV: Working with SQL Azure Services

    Figure 12-22: Specifying the SADB

    database for an encrypted connection.

    Figure 12-23: The status bar identifies the connections fixed

    database name.

    Configuring the Server FirewallSQL Azure stores firewall rules in the master databases sys.firewall_rules system view. You can retrievedetails about the current set of rules in effect by logging into SSMS 2008 R2 and typing master as theConnect to Database value and executing a SELECT * FROM sys.firewall_rules query (see Figure 12-24).

    18

  • 8/3/2019 06387c12_online Azure SQL

    19/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    Figure 12-24: Executing a T-SQL query against the master

    database to retrieve firewall rules in effect.

    SQL Azure offers two system stored procedures to create or update and delete server rules by name

    Run exec sp_set_firewall_rule NAllow Windows Azure,0.0.0.0,0.0.0.0 to creatupdate the named rule.

    Run exec sp_delete_firewall_rule NAllow Windows Azure to delete the named rule.

    Determining Server UsageThe sys.database_usage system view lists the history of your database usage with time (date), sku (Wor Business), and quantity (number of databases in use) columns. Each change in sku or quantity ad

    new row (see Figure 12-25).

    Figure 12-25: Retrieving your database usage history from the

    servers master database.

  • 8/3/2019 06387c12_online Azure SQL

    20/22

    Part IV: Working with SQL Azure Services

    Usi ng the sql cmd Uti l i ty wi th SADBThe sqlcmd utility is an alternative to SSMS that lets you manage database connections at the commandprompt. The following instruction with valid server administrator credentials typed or pasted at theWindows command prompt opens a connection to the Northwind database running on the SADB servercreated earlier in the chapter:

    sqlcmd -S k8jv7gpmwb.database.windows.net -U rogerj@k8jv7gpmwb

    -P Pas$w0rd -d Northwind

    The following table describes common sqlcmd command-line arguments:

    Argument Description

    -? Show syntax summary

    -S Server (use complete DNS name)

    -U Server administrator name in login@servername (name only) format

    -P Server administrator password

    -d User database name (default is master)

    -i Query input (T-SQL) file path\name

    -o Query output file path\name

    Figure 12-26 shows the result of executing sqlcmd -?.

    Figure 12-26: The Windows command prompt

    displaying the sqlcmd syntax summary.

    After connecting to SADB, executing T-SQL statements and batched queries with sqlcmd is a simpleprocess. At the sequentially numbered #> prompt, type a valid T-SQL command, and press Enter. TypeGO and press Enter to execute the preceding command(s) and reset the prompt number to 1. Type quitor exit to close the session. Figure 12-27 shows sqlcmds window after executing the SELECT name FROMsys.tables command against the Northwind database you create with SSMS and a modified version ofthe InstNwind.sql script in the next chapter.

    20

  • 8/3/2019 06387c12_online Azure SQL

    21/22

    Chapter 12: Managing SQL Azure Accounts and Databas

    Figure 12-27: Using sqlcmd to display a list of table

    names in a sample Northwind database.

    Compari ng SADB wi th SQL Server 2008

    R2 DatabasesSADB servers and databases are virtual objects abstracted from a customized, multi-tenant version clustered SQL Server instances and dont correspond to individual physical server instances. Therefyou administer databases, tables, indexes, tuning, query optimization, logins, users, and roles but nphysical storage, such as servers, files, and fixed disk drives. SADB automatically handles data replicand load-balancing for high availability, including transparent fail-over when a server dies. Backuphandled by data replication; restore operations after data loss or corruption are automatic.

    SADB blocks statements and options that attempt to directly manipulate physical resources, such aRESOURCE GOVERNOR, filegroup references, and some physical server DDL statements. Attempts to sserver options, such as SET ANSI_NULLS ON, generate error messages. CRL database objects, SQL Se

    vice Broker, SQL trace flags, SQL Server Profiler and Database Tuning Advisor tools and utilities aravailable.

    Deprecated data types, such as text, ntext, and image arent supported, but you can substitutevarchar(max), nvarchar(max), and varbinary(max) for them, as youll see in the next chapter. SAcurrently doesnt permit use of SQL Server 2008s geography and geometry spatial data types. If yoneed to encrypt data, you must do so in the client application; SADB doesnt support the column-leor row-level encryption introduced by SQL Server 2005 or SQL Server 2008s Transparent DataEncryption (TDE). The Transact-SQL Reference chapter of MSDNs SQL Azure documentation(http://bit.ly/15Ja0Q, http://msdn.microsoft.com/en-us/library/ee336281.aspx ) includestables that list supported, partially supported, and unsupported T-SQL statements.

    SummarySQL Azure Database is the basic element of SQL Azure. SADB provides a highly scalable and avaiable relational database as a public cloud computing resource running together with the WindowsAzure Platform in most of Microsofts newly constructed data centers. The SADB Web Edition supptransactional-consistent databases up to 1GB in size; the Business Edition is limited to 10GB or less.

  • 8/3/2019 06387c12_online Azure SQL

    22/22

    Part IV: Working with SQL Azure Services

    SADB grew out of early adopters dissatisfaction with technical previews of SQL Server Data Services(SSDS), which offered a flexible, highly scalable, schemaless Entity-Attribute-Value data model but wasmissing the relational features that IT groups and developers expected from a service carrying the SQLServer name. In March 2009, Microsoft announced that SSDS would morph to a fully relational versioncalled SQL Data Services (SDS), which enable developers to leverage their data architecture and Transact-SQL skills. SDS became SQL Azure Database in July 2009 and the first SADB CTP became available to

    invitees on August 17, 2009.

    The CTP version required requesting an invitation from the Microsoft Connect site that resulted in atoken, which was redeemable from the SQL Azure portal for a single server with multiple databases atno charge. The commercial version, which released on January 4, 2010, requires a credit card to cover acharge of US$9.99 per month (Web Edition) or US$99.99 per month (Business Edition), plus US$0.10 perGB of data ingress and US$0.15 per GB of data egress. Special pricing offers are available to users withMSDN Premium subscriptions and those willing to commit to a six-month subscription.

    SADB auto-assigns a unique DNS address to each server. SQL Server Management Studio 2008 [Express]and the sqlcmd command-line utility connect to SADB with the TCP protocol on port 1433 using SQLServers traditional Tabular Data Stream format via encrypted transmissions. Using TDS lets developers

    change from connections to local SQL Server 2005 or 2008 [Express] instances for development to SADBdatabases in the cloud simply by changing the connection string. SSMS 2008 R2 [Express] enables full-featured management of SQL Azure databases.

    Microsoft manages SADBs physical infrastructure, such as server instances, disk drives and files, aswell as backup and restore operations, so many T-SQL DDL commands arent supported. However,developers have full control over databases, tables, indexes, tuning, query optimization, logins, users,and roles. SADB doesnt support deprecated and new SQL Server 2008 spatial datatypes, nor does itoffer data encryption or compression.


Recommended