Getting Started with Windows Azure SQL Database - TechNet Articles - United States (English) - TechNet Wiki

 Note
SQL Azure Portal has been replaced by Windows Azure -content-fragment-top">

Getting Started with Windows Azure SQL Database

 Note
SQL Azure Portal has been replaced by Platform Management Portal. A new version of this article, which introduces SQL Azure using the Windows Azure Management Portal is available, see Getting Started with SQL Azure using the Windows Azure Platform Management Portal.

This article provides guidelines on how to sign up for SQL Azure and how to get started creating SQL Azure servers and databases. Microsoft SQL Azure Database is a cloud-based relational database platform built on SQL Server technologies. By using SQL Azure, you can easily provision and deploy relational database solutions to the cloud. SQL Azure Database is the relational database service on the Windows Azure platform.  

In this Article

Creating a Windows Azure Platform Subscription

To start using SQL Azure, you must first purchase a Windows Azure Platform subscription by visiting the Windows Azure Platform offers page or the Microsoft Online Services Customer Portal. Follow these steps to purchase a  subscription:
  1. If you are on the Windows Azure Platform offers page, choose one of the available offers and click Buy. Then, go to step 3.
  2. If you are on the Microsoft Online Customer Portal, click Sign in on the upper-right corner.
  3. Microsoft Online Services Customer Portal will ask you to sign in with your Windows LiveID account.  After you type your Windows Live e-mail address and password, click Sign in. If you don’t have a Windows LiveID account, visit Windows LiveID sign-up page and get a Windows LiveID account for your account administrator or owner. For more information on Windows LiveID, see Windows Live ID Online Help.
  4. To purchase a subscription from Microsoft Online Services Customer Portal, click the Services panel at the Microsoft Online Services Customer Portal.  Add services to your shopping cart.  If you have already chosen an offer on the Windows Azure Platform  offers page, this offer will be shown at the Shopping Cart automatically. For more information on Microsoft Online Customer Portal, see Microsoft Online Customer Portal Help.

Important: A single account may contain zero or more subscriptions. An account represents the way that you establish a billing relationship with Microsoft. A single Windows Azure Platform subscription can contain multiple services, such as Windows Azure, Windows Azure AppFabric, and SQL Azure.

Visit the Windows Azure Platform  offers page.  As an example, choose Windows Azure Platform Introductory Special and click Buy. After your purchase is complete, you will receive a confirmation notification in e-mail with instructions for accessing your account in the SQL Azure platform.  

This opens the Microsoft Online Services Customer Portal Sign up page. Use your Windows Live Id and password to sign in.
  

After you type your Windows Live e-mail address and password, click Sign In. The Microsoft Online Services Customer portal will show up. Click Shopping Cart. Review your purchase details in the Shopping Cart and click Checkout.

Note: The Windows Azure Platform Introductory Special will end on March 31, 2011 and all usage will then be charged at the standard rates.

Then, the Microsoft Online Services Customer Portal asks you to enter the payment options. Choose New credit card option and click Next.
  

Note: When you want to purchase your subscription to the service through Microsoft Online Services Customer Portal, you will be prompted to enter information regarding your account owner. The account owner or account administrator is the person who signs up for the SQL Azure platform and other Microsoft Online Services. As an account owner, you own the billinle="border:0px solid;" />

Note: The Windows Azure Platform Introductory Special will end on March 31, 2011 and all usage will then be charged at the standard rates.

Then, the Microsoft Online Services Customer Portal asks you to enter the payment options. Choose New credit card option and click Next.
  

Note: When you want to purchase your subscription to the service through Microsoft Online Seg relationship with Microsoft. Account Administrators can log in to the Microsoft Online Services Customer Portal to manage their subscriptions and to the SQL Azure portal to manage their SQL Azure servers.

Enter Payment Information and Billing Information as shown in the following window.
  

Next, read the Microsoft Online Subscription Agreement. Accept the Terms and Conditions by clicking the check box. Enter your Full name and Title, and click I Accept.


 
Review and confirm the order as shown in the next page. Once you review all, click Confirm Order.


 
After you click Confirm Order, the following Confirmation page appears. Click Proceed to activation….


 
This opens the Service Activation page. In the Service Activation page, enter SQLAzure_Introductory as a subscription name and click Next.

The subscription name will be used to identify the subscription on bills. It will also be used to name your project in the Windows Azure Platform. One subscription refers to one project. Make sure to name each subscription uniquely based on your business needs. As an account administrator, you can purchase one or more subscriptions of each offer except the Windows Azure Platform Introductory Special offer.


 
Then, Microsoft Online Services Customer Portal asks you to enter contact details for the person in your company who will be responsible for setting up and managing your service. This person is called the service administrator, and is assigned by the account owner. The service administrator defaults to the account owner from your profile, in case your service administrator is the same as your account owner. If your service administrator is not the same as your account owner, he/she can only access the SQL Azure portal and manage their servers. The service administrators cannot manage the subscriptions via the Microsoft Online Services Customer Portal but the account administrators can. 

As soon as activation is complete, an e-mail message is sent to the account owner and the service administrator, outlining the next steps to take.

Enter the information in the Service Activation window and click Next.

 

Then, you will see the Summary page as follows. Review all the information and click Finish.


 
After you click Finish on the Summary page, Confirmation window appears. Click Close.


 
At this point, a confirmation e-mail message will be sent to your Windows Live ID account. You can see the status of your subscription under the Subscriptions tab at the Microsoft Online Services Customer Portal.
  

After purchasing a Windows Azure Platform subscription, you will receive an email, which will show you how to activate your account.  The following image shows an example confirmation email. In the confirmation email, click Microsoft SQL Azure and sign in with your Windows Live ID username and password.

Creating a Server on the Portal

After creating and activating your subscription, you can create your server at the SQL Azure Developer Portal. Once you sign in the SQL Azure Portal, a list of projects you have created will show up. By default, the subscription name will be used to name your project. Check the Status column to verify if your subscription is Enabled or not. For more information, see Status Codes for SQL Azure Accounts.


 
When you click the project name, SQL Azure Portal asks you to read and accept the Terms of Use.

 
Click I Accept. Then, you can create your logical server. Choose the location that is closest to you to avoid extra bandwidth costs and achieve better performance. For more information on bandwidth costs, see Accounts and Billing in SQL Azure.

Note: One subscription maps to one logical SQL Azure server 1:1.  A SQL Azure server is a logical server and contains one or more databases.

Enter Administrator Username and Password, click Create Server.

After you click Create Server, the provisioning process creates an SQL Azure server, a database named master, and a login that is the server-level principal of your SQL Azure server. That login is similar to the server-level principal, sa, for an instance of SQL Server on your premises.

Note: Once you create your server, you can create your SQL Azure databases either by using the SQL Azure portal or connecting to the master database and running the CREATE DATABASE statement.  A master database is created automatically. You must be connected to the master database whenever you CREATE, ALTER, or DROP databases. If you do not specify a database in the connection string, you will be connected to the master database by default. Each SQL Azure server has a fully qualified unique domain name, such as servername.database.windows.net. The servername refers to the name of your SQL Azure server.

Next, the Server Administration page appears.

Click Create Database to create a new database.


 
Type TestDB and choose 1GB Web Edition database and click Create. For more information on different database sizes and editions, see Accounts and Billing in SQL Azure.

If you want to see an example connection string that can be used to connect to your SQL Azure database, select TestDB database, click Connection Strings. This will provide ADO. to create a new database.


 
Type TestDB and choose 1GB Web Edition database and click Create. For more information on different database sizes and editions, see Accounts and Billing in SQL Azure.

If you want to see an example connection string that can be used to connect to your SQL Azure NET and ODBC connection strings that can be used in your application.


 
Select your SQL Azure database and click Test Connectivity. Enter your Username and Password as shown below and click Connect. Initially, all access to your SQL Azure server is blocked by the SQL Azure firewall; connection attempts originating from the Internet or Windows Azure will not be able to reach your SQL Azure server. Therefore, the connection will not succeed.


 
Similarly, if you want to connect to your SQL Azure server by using the sqlcmd utility and if the connections are blocked by the SQL Azure firewall, an error message is returned by the service: 

  

Note: When a computer attempts to connect to your SQL Azure server from the Internet, the SQL Azure firewall checks the originating IP address of the request against the full set of firewall settings. If the IP address of the request is not within one of the ranges specified, the connection attempt is blocked and does not reach the SQL Azure server.  If you want to connect to the SQL Azure server and the connection is blocked by the SQL Azure firewall, the service returns an error message.

Configuring SQL Azure Firewall

In order to begin using your SQL Azure server, you must specify one or more firewall settings that enable access to your SQL Azure server on the SQL Azure Portal. Use the firewall settings to specify which IP address ranges from the Internet are allowed, and whether or not Windows Azure applications can attempt to connect to your SQL Azure server.

To do that, click the Firewall Settings tab on the Server Administration page. 
 

If you want Windows Azure applications to be able to connect to your SQL Azure server, you must click Allow Microsoft Services access to this server. This will add a new firewall rule, which is called as MicrosoftServices and its IP Address Range would be 0.0.0.0 – 0.0.0.0 by default.

If you want to add a new firewall setting for Internet-based connections, click Add Rule. In the dialog box, specify a unique name in the Name field with the corresponding IP address range. Then select Submit. The IP address of your computer must be within the IP address range of one of the firewall settings. For more information, see SQL Azure Firewall and SQL Azure Connectivity Troubleshooting Guide.

 
The following images demonstrate the firewall rules that are enabled in this subscription.


 
To modify the existing firewall rule, select the rule and click Edit Rule
 

After you create your SQL Azure server, databases, and set the firewall rules, you can connect to your SQL Azure database either by using the sqlcmd utility or SQL Server 2008 R2 Management Studio. For more information, see Developing and Deploying with SQL Azure.

Just like SQL Server, SQL Azure allows you to create additional logins and users. For more information, see Managing Databases and Logins in SQL Azure.

In addition, SQL Azure allows you to use a subset of the Transact-SQL query language to query a database and to insert, update, and delete data in tables in a database. For more information, see Transact-SQL Reference.

When you write applications for SQL Azure, you can use one of the .NET Framework programming languages, which come with Visual Studio 2008 or later: Microsoft Visual Basic, Microsoft Visual C#, or Microsoft Visual C++. You can also use the ADO.NET data provider for SQL Server, the SQL Server 2008 Native Client ODBC driver, and the SQL Server 2008 Driver for PHP version 1.1. For more information, see ="http://msdn.microsoft.com/en-us/library/ee336235.aspx" title="Managing Databases and Logins in SQL Azure"> Managing Databases and Logins in SQL Azure.

In addition, SQL Azure allows you to use a subset of the Transact-SQL query language to query a database and to insert, update, and delete data in tables in a database. For more information, see Transact-SQL Reference.

When you write applications for SQL Azure, you can use one of the .NET Framework programming languages, which come with Visual Studio 2008 or later: Microsoft Visual Basic, Microsoft Visual C#, or Microsoft Visual C++. You can also use the ADO.NET data provider for SQL Server, the SQL Server 2008 Native Client ODBC dri Development Guide.


See Also