Wednesday, September 28, 2011

SQL Azure to Developers: Part 1


Objective

In this part we will focus on an overview of SQL Azure along with a first look at SQL Azure Management Portal. Essentially we will cover
  • What is Cloud Database
  • What is SQL Azure
  • Create and Manage Database in SQL Azure
  • Firewall in SQL Azure

What is Cloud Database?

For a developer a better perspective on database is always better and it helps to write different layers of application in effective and efficient way. Database in cloud is new buzz and very much appreciative technology. There are two words in CLOUD DATABASE. We are very much aware of term DATABASE whereas CLOUD may be newer or ambiguous to us.
In very broader terms, Cloud can be termed as next generation of Internet. On a normal scenario you find on which server your database is residing. You have very minute level administrative control on database server and you have a physical sense of database server. Whereas imagine if you are not aware of where your database is residing. You access and perform all operation on database via Internet. Scalability, Manageability and all other administration task on database are performed by some third party. You only pay for the amount of data residing on the database provided by third party. You work with a use and pay model. In that case you can say database is in cloud.
There are many cloud service providers like Microsoft, Amazon etc. to name a few. All vendors do have their own cloud servicing model and pricing. Microsoft cloud platform is known as Windows Azure. Essentially Windows Azure is a cloud operating system offered by Microsoft. As part of Windows Azure, there are five services offered by Microsoft
  1. Windows Azure
  2. SQL Azure
  3. Office 365
  4. App Fabric and Caching services
  5. Marketplace
In this three-part article, we are going to focus on SQL Azure. We will focus on essential aspects needed to know by .NET developers. To be very precise on SQL Azure, we can say "SQL Server in cloud is known as SQL Azure". When you have chosen to create a relational database in Microsoft data center then you can say your database is in cloud or in SQL Azure.
In this article, we will cover
  • What is SQL Azure?
  • A first look on SQL Azure Management portal
  • SQL Azure Database edition
  • Firewall settings for SQL Azure

What is SQL Azure?

SQL Azure is a cloud based service from Microsoft. It allows you to create your Database in one of the Microsoft Data center. In a very generic statement we can say SQL Azure allows creating Database on the cloud. It provides highly available database. It is based on SQL Server. It supports built in Fault tolerance and no physical administration is required. It supports TSQL and SSMS.
Advantage of using SQL Azure
  • In built Fault tolerance support
  • No Physical Administration required
  • Very high availability
  • Multitenant
  • Pay as you go pricing
  • Support of TSQL
  • Highly scalable
We have done enough of theoretical discussion, now let us login to SQL Azure portal and create a database in the cloud.

Create and Manage Database in SQL Azure

To create Database in SQL Azure, You need to follow below steps
Step1
Login SQL Azure portal with your live credential
Step 2
Click on SQL Azure tab and select Project
Step3
Click on the project. In this case project name is debugmode. After clicking on project, you will get listed the entire database created in your SQL Azure account.
Here in this account there are two database already created. They are master and student database. Master database is default database created by SQL Azure.
Step 4
Click on Create Database
Step 5
Give a name to the Database. Select the edition as Web or Business and specify the max size of database.
Step 6
After that click on Create you can see on Databases tab that Demo1 database has been created.

Different types of SQL Azure Database editions

At time of creating Database you might have seen, there were two Database editions.
Web Edition Relational Database includes:
  • Up to 5 GB of T-SQL based relational database*
  • Self-managed DB, auto high availability and fault tolerance
  • Support existing tools like Visual Studio, SSMS, SSIS, BCP
  • Best suited for Web application, Departmental custom apps
Business Edition DB includes:
  • Up to 50 GB of T-SQL based relational database*
  • Self-managed DB, auto high availability and fault tolerance
  • Additional features in the future like auto-partition, CLR, fanouts etc
  • Support existing tools like Visual Studio, SSMS, SSIS, BCP
  • Best suited for Saas ISV apps, custom Web application, Departmental apps
While creating Database in SQL Azure you can choose among two options.
If we choose Web Edition then Maximum size we can choose is 5 GB.
If we choose Business Edition then Maximum size we can choose is 50 GB.
SQL Azure portal is having very effective Silverlight based user interactive UI and many more operations can be performed through the UI. There is new database manager and it allows us to perform operations at table and row level.
Now we can perform many more operations through Database option of new Windows azure portal.
  • Create a database
  • Create/ delete a table
  • Create/edit/delete rows of table.
  • Create/edit stored procedure
  • Create/edit views
  • Create / execute queries etc. . .
You can manage a database using Data Base Manager.
Accept given term and conditions and click Ok.
After Ok, you will get popup asking password to connect to database. Provide password and click on Connect.
After a successful connection, you will get a cube providing all the information about the database you connected.
You can perform all the database operations from the top ribbon. You have option to create new query, new table, new view, and new stored procedure
If we want to create new table, click on New Table option from ribbon. We are creating a table with name Blogger. We are giving there columns ID, Name and Technology. From drop down we can select data type for the columns.
Then click on the save button at the top.
You can navigate between the Data Base and Table tabs. You can also create and delete a column. Once you click on save button, you can see table listed at left panel.
At the top you can see that you have the option to navigate either the design or the data view of the table. Click on Data tab to navigate to Data view.
Click on Row to add a Row to the table.
After adding two rows, you can see table as below. You can also add and delete rows from top button.
Now, to execute the query, select Data Base tab at the top and execute query as below.
When you click the Execute button at the top, you will get output as below.

Firewall in SQL Azure

In this way, you can perform almost all the basic operations from new SQL Azure Data Base Manager.
SQL Azure provides security via Firewall. By default Database created on SQL Azure is blocked by firewall for the security reason. Any try to external access or access from any other Azure application is blocked by firewall.

Figure 23: Image taken from MSDN

Image taken from MSDN

Connection Strings

You can copy Connection string from SQL Azure portal as well.

Connecting from Local system

When we want to connect SQL Azure portal from network system or local system then we need to configure firewall at local system. We need to create an exception for port 1433 at local firewall

Connecting from Internet

The entire request to connect to SQL Azure from Internet is blocked by SQL Azure firewall. When a request comes from Internet
  • SQL Azure checks the IP address of system making the request
  • If IP address is in between the range of IP address set as firewall rule of SQL Azure portal then connection get established.
Firewall rules can be Added, Updated and Deleted in two ways
  • Using SQL Azure Portal
  • Using SQL Azure API

Manipulating Firewall rules using SQL Azure Portal

After login to Windows Azure portal, click on Database option and select Database server from left tab. You can see firewall rules listed there.
A new rule can be added by clicking the Add button.
To connect from other Windows Azure applications for the same subscription check the check box as shown below.
An existing firewall rule can be edited and delted also by selecting the Edit and Delete options respectievly.

Summary

In this part we discussed various elementary concepts of cloud database and SQL Azure. In the next parts we will go deep to understand other essential concepts needed to know as a developer.

No comments:

Post a Comment