Creating a New SQL Database on Windows Azure

In my previous post, I showed you how to sign up for a Windows Azure subscription. Once you’ve got your subscription, it’s easy to create a SQL Database, which is very much like an ordinary SQL Server database hosted in the cloud. In this post, I’ll show you how. Essentially, you first need to create a server on Windows Azure, and then you can create the database on that server.

Creating a server

It’s easy to create a server, which is akin to an instance of SQL Server in the sense that it can host multiple databases. All you need to do is create an administrator account user name with a strong password, and specify the geographical region where the server should be located physically. To achieve the best performance, you should choose the region closest to your consumers. You will also want to be sure that any Windows Azure cloud Web sites and services you create are hosted in the same region as the SQL Database servers they communicate with. By locating both in the same region, you will avoid the bandwidth-based fee that gets incurred when your cloud sites, services, and databases communicate across different Azure regions. You will also reduce latency, which results in perceivably better performance.

SQL Database also has special firewall rules you can set to control exactly which computer or computers can access your database server in the cloud. Minimally, you’ll need to add a rule granting access to the IP address of your computer so that you can access the server from your local machine. For production, you might need to add rules granting access to blocks of IP addresses.

Follow these steps to create a new server:

  1. Log in to the Windows Azure portal at https://manage.windowsazure.com. This brings you to the main portal page showing ALL ITEMS.
    F01xx03
  2. Click SQL DATABASES in the vertical navigation pane on the left, then click SERVERS at the top of the page, and then click CREATE A SQL DATABASE SERVER.
    F01xx04-markedup
  3. Provide a new server login name—for example, saz.
  4. Supply a password for the new server, and then reenter it to confirm. Typical strong password guidelines apply, which require you to use a combination of mixed case, numbers, and symbols.
  5. Choose a region from the drop-down list—for example, East US. For best performance, pick the region you are located in or nearest to.
  6. Be sure to leave the ALLOW WINDOWS AZURE SERVICES TO ACCESS THE SERVER  check box selected. This makes the server accessible to other Windows Azure cloud services that you can create.
    F01xx05
  7. Click the checkmark icon on the lower-right side of the dialog to complete the settings. After just a few moments, the new server is provisioned and ready to use.
    F01xx06

If you’ve ever prepared a new server from scratch yourself, you can really appreciate the time and effort you just saved. This server is now available and ready to host databases in the cloud, and SQL Database has automatically assigned a randomly unique (but relatively short) name by which it can be accessed. But before access is granted, the server firewall must be configured. So the next step is to add a firewall rule so that you can connect to the server from your local machine.

The check box mentioned in step 6 added the special IP address 0.0.0.0, which allows cloud services running on Windws Azure to access the SQL Database server. However, you still need to add the IP address of your local machine to access the server from the SQL Database management portal and other tools (such as SQL Server Management Studio and SQL Server Data Tools in Microsoft Visual Studio).

To add a firewall rule for the IP address of your local machine, follow these steps:

  1. Click the server name, and then click the CONFIGURE link at the top of the page.
  2. To the right of your current detected IP address, click ADD TO THE ALLOWED IP ADDRESSES. A new firewall rule for your IP address is added.
    F01xx07-markedup
  3. Click SAVE at the bottom of the page.
  4. Click the back icon (the large back-pointing arrow) to return to the SQL DATABASES page for the new server.

You might need to wait a few moments for the new firewall rule to take effect, although typically it happens very quickly (often within five to ten seconds). If you don’t wait long enough, however, and the rule has not yet taken effect, you can be quite certain that you will not be able to connect to the server from your local machine until it does.

Creating a SQL Database instance

It will be just about as easy to create a database as it was to create the server. You simply need to choose a name for the new database, an edition, a database size, a default collation, and of course, the server to host the database on.

These settings can be easily changed later on. As part of the elastic scaling provided by SQL Database, you can freely switch back and forth between the Web and Business editions. You can also switch up and down between the sizes (1 GB or 5 GB for the Web edition, or 10 GB through 150 GB for the Business edition) as your changing needs dictate. And if 150 GB is still too small for you, you can partition your database using special sharding techniques.

Follow these steps to create a new SQL Database:

  1. In the Windows Azure portal, click the DATABASES link at the top of the page.
  2. Click CREATE A SQL DATABASE. This opens the NEW SQL DATABASE dialog.
  3. Type the name for the new database.
  4. Leave the default settings to create a Web edition database up to 1 GB in size using the SQL_Lating1_GeneralCP1_CI_AS collation.
  5. Choose the server you created in the previous procedure from the drop-down list.
    F01xx09
  6. Click the checkmark icon in the lower right of the dialog to complete the settings.

After a few more moments, the new database is created and ready to use.

F01xx10

And that’s all there is to creating a new SQL Database on Windows Azure!

 

 

 

 

Advertisements

Signing Up for Windows Azure

It’s easier than you think to get started with Windows Azure, and in this blog post, I’ll walk you through the steps. Once you’re signed up with a trial subscription, you’ll be able to explore all of the services available on Azure.

Basically, you need two things: a Microsoft account and a Windows Azure subscription. It’s quite possible that you already have a Microsoft account, which was formerly known as a Windows Live ID. This is the same account you might be using today for logging in to various Microsoft websites and services, such as Outlook.com, Hotmail, Xbox LIVE, Windows Phone, OneDrive (formerly SkyDrive), and other Microsoft offerings.

Creating a Microsoft account

The very first step before you can use any Windows Azure service is to acquire a Microsoft account if you don’t already have one. This is essentially an email address and password combination you will use to create and access your Windows Azure subscription. If you already have a Microsoft account, you can use it now to create a new Azure subscription. There’s no need to create another account, so you can just skip ahead to the next section, “Creating a Windows Azure subscription.” Otherwise, you’ll need to create one now.

If you already have a Microsoft account but you want to use a different email address for any reason, you still don’t need to create a new account. You can either rename the existing account or create an alias. See http://windows.microsoft.com/en-US/hotmail/get-new-outlook-address for more information.

If you do create a new Microsoft account, the user name can be an email address you already own. Alternatively, you can create a new email address for the account that ends either with @outlook.com or @hotmail.com. It really makes no difference which you choose, as long as the name you provide has not already been taken by someone else at either @outlook.com or @hotmail.com. If you do choose to create a new email address, you will also get a new mailbox account at that address, and Microsoft will communicate with you via that mailbox any time it needs to notify you about important information regarding your account.

Whether you use an existing email address or create a new one, you’ll also need to assign a strong password to protect the Microsoft account. Some additional personal information is also required, such as your name, gender, one of two forms of identity confirmation, your country, and your postal/Zip code.

Follow these steps to create your new Microsoft account:

  1. Using Internet Explorer, browse to http://signup.live.com. This displays the Create An Account page:
    F01xx01
  2. Provide your first and last names.
  3. For the Microsoft account user name (which is what you will be logging on to the Windows Azure portal with), provide an existing email address. Or click the Or Get A New Email Address link to create a new one available on either @outlook.com, @hotmail.com or @live.com.
  4. Supply a password, and then reenter it to confirm. The account requires a strong password of at least eight characters that must contain a combination of mixed case, numbers, and symbols.
  5. Provide your country and postal/Zip code, birthdate, and gender.
  6. Provide a phone number or alternate email address. You must provide at least one of these identity-confirmation methods.
  7. Type the random characters generated to prove that you’re a real person.
  8. Click the Create Account button.

If you created a new email address in step 3, a mailbox for it is immediately created and you are directed immediately to the Account Summary page. If you provided an existing email address, you will receive an email at that address from the Microsoft account team shortly after clicking Create Account. This email is sent to verify that you do, in fact, own the email address you provided. Your new Microsoft account will not become activated until you click on the verification link provided in the email.

Creating a Windows Azure subscription

Now that you have your Microsoft account, it’s time to create an Azure subscription. The subscription is essentially your Windows Azure billing account, and that opens the gateway to the full range of services available on Windows Azure.

In the procedure that follows, you will create a free trial subscription to Windows Azure. Currently, the free trial gives you $200 of credit for 30 days with access to all services. This requires providing credit card information that will be used to bill your subscription after your trial expires.

Note that Microsoft Azure pricing and special offers are subject to ongoing change. I strongly recommend that you visit http://www.windowsazure.com/en-us/pricing/purchase-options/ to review the latest pricing structures available. Furthermore, special pricing is available for MSDN subscribers. See http://www.windowsazure.com/en-us/pricing/member-offers/msdn-benefits/ for more information.

Follow these steps to create your new Windows Azure subscription:

  1. Using Internet Explorer, browse to http://www.windowsazure.com.
  2. Click the green Try For Free button.
  3. On the next page, click the green Try It Now button.
  4. If you are not already logged in to your Microsoft account, log in now.
  5. You will be taken to the Free Trial Signup page, as shown below.
    F01xx02
  6. Choose to either receive a text message or phone call as the method to receive a verification code.
  7. Enter the code received via the text message or phone call, and click Verify Code.
  8. Provide the credit card payment details for billing after the free trial expires.
  9. Select the box to indicate that you agree to all the terms.
  10. Click the green Sign Up button.

It takes just a few moments to complete setting up your new Azure subscription, and then you’re ready to get started working with Windows Azure services.

In future posts, I’ll show you how to get started with Windows Azure SQL Database, the cloud version of SQL Server.