Monthly Archives: December 2011

Post navigation

In this post we will focus on overview of SQL Azure along with a first look on SQL Azure Management Portal. Essentially we will cover in this part

What is Cloud Database

What is SQL Azure

Create and Manage Database in SQL Azure

Fire Wall 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 constitute CLOUD DATABASE. We are very much aware of term DATABASE whereas CLOUD may be newer or ambiguous to us.

In very broader term, 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 is performed by some third party. You only pay for the amount of data residing on the database provided by third party. You work on 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 cloud operating system offered by Microsoft. As part of Windows Azure, there are five services offered by Microsoft

Windows Azure

SQL Azure

Office 365

App Fabric and Caching services

Marketplace

In this three part article, we are going to focus our discussion to SQL Azure. We will focus on essential aspects need to know about SQL Azure as dot net developer. 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 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 setting for SQL Azure

What is SQL Azure?

SQL Azure is 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.

While creating Database in SQL Azure you can choose among either of 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 150 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 database using Data Base Manager.

Accept given term and conditions and click Ok. you will get popup asking password to connect to database. Provide password and click on Connect.

After logon you will get Mange user interface as below,

And in left hand panel you will have options as below,

For more on this watch the video of the post.

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.

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

f 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 on Add button.

To connect from other Windows Azure application for same subscription check the check box

An existing firewall rules can be edited and deleted also by selecting Edit and delete option respectively.

Conclusion

In this part we discussed various elementary concepts of cloud database and SQL Azure. In further part we will go deep to understand other essential concepts needed to know as developer.Follow @debug_mode

To start with let us create a WCF REST Service returning JSON as below. There is one operation contact named Add in the service and that is taking two strings as input parameters and returning integer.

In this post I will show you the way to consume JSON WCF REST Service in Windows Phone 7. This post is divided into four parts.

Creating simple WCF REST Service for ADD

Consuming JSON REST Service in Windows Phone 7 application.

Creating complex WCF REST Service with custom classes and types.

Consuming complex JSON REST Service in Windows Phone 7 application.

Creating simple Add Service

To start with let us create a WCF REST Service returning JSON as below. There is one operation contact named Add in the service and that is taking two strings as input parameters and returning integer.

After configuring, Service ready for hosting. You are free to host it either on Azure, IIS, or Cassini. For local ASP.Net Server hosting press F5. Do a testing of service in browser and if you are getting expected output, you are good to consume it in the Windows Phone 7 application.

Consuming Service in Windows Phone 7

To consume REST Service in Windows Phone 7 and then parse JSON, you need to add below references in Windows Phone 7 project.

As the design of the page I have put two textbox and one button. User will input numbers to be added in the textbox and on click event of button result would get displayed in message box. Essentially on click event of the button we will make a call to the service. Design of the page is as below,

On click event of the button we need to make a call to the service as below,

And ServiceURi is constructed as below,

There is nothing much fancy about above service call. We are just downloading JSON as string using WebClient. However parsing of JSON is main focus of this post. To parse we need to write below code in completed event.

In above code

Converting downloaded string as Stream

Creating instance of DataContractJsonSerializer. In that we are passing type as string since returned type of service is string.

Reading stream into instance of DataContractJsonSerializer

Displaying the result.

Putting all code together you should have below code to make a call and parse JSON in windows phone 7

In this post I will show you, how to create a WCF Service with both flavor of SOAP and REST paradigm . For purpose of this post , I am going to create a Calculator Service with following characteristics

Serivice will have both SOAP and REST enabled

REST Service will have JOSN Message format

In later part of the post , I will show you the way to consume both types of Service in a managed (console) client.

Idea

There would be two ServiceContract . One ServiceContract for SOAP and one for REST.

There would be one Service Defintion file

There would be two bindings enabled on the service. One binding corrosponds to SOAP and other to REST

For SOAP , basicHttpBinding would be used and for REST webHttpBinding would be used

Both SOAP and REST will have same base address

Note : I have taken different Service Contract for REST and SOAP. However you can have it on same ServiceContract also.

Create Service

Let us create two service contracts . One for SOAP and one for REST Service. I have created a Service Contract IService1 for SOAP as below,

In above service explictly I am setting message format to JSON. So above service is JSON enabled REST Service. Since REST based service does not take input parameter but string type so input parameters to functions is of string type.

Implementing Service

Service is implemented in simple way. All the operation contracts from the service are performing trivial calculating functions.

XAML is everywhere. Whether you are developing for Windows Phone 7, WPF, Silverlight or Windows 8, you need to have sound understanding of XAML. If you are looking to learn XAML in a systematic way then this book is for you.

This book is published by Microsoft Press and authored by Mamta D and Ashish Ghoda.

This book may be your expert guide to designing and building dynamic user interfaces

Sharpen your application design and development skills using XAML—the declarative markup language used in Microsoft® Silverlight®, Windows® Presentation Foundation (WPF), and the Windows 8 Runtime APIs. Led by two XAML experts, you’ll learn practical ways to build rich, interactive user interfaces with data integration capabilities and support for multimedia, graphics, and animation. This hands-on guide is ideal for Microsoft .NET developers and web designers alike.

Discover how to:

Control UI behavior and implement business logic with code-behind solutions

Manage UI element positioning with the XAML layout system

Use templates to customize UI elements—without affecting their functionality

Apply different types of property and event systems in WPF and Silverlight

Bind various kinds of data to your UI, and display them in the format you want

Implement 2D and 3D vector graphics and animations

Something about Authors

Mamta D

Mamta is senior community member and writes on various technologies. For her update you can follow her at TWITTER

Ashish Ghoda

Awarded with British Computer Society (BCS) Fellowship, ASHISH GHODA is a customer-focused and business values-driven senior IT executive with over 15 years of IT leadership, technical and financial management, and enterprise architect experience. Read more about Ashish here