Report on Community Tech Days Ahmedabad: 11th December 2010

clip_image001

It was a cold December morning but as usual energetic Ahmedabad crowd was there on the venue to attend the full day sessions from various speakers on various latest topics on Microsoft technologies.

There were 6 sessions scheduled for the day. And all speakers were veterans (Excluding me) and well known for their ability to articulate the complex technical stuff in simple word targeting all types of audiences.

This time in Ahmedabad hall was quiet big so all the audiences got accommodated very easily. And there were no shortage of space as of July CTD event of Ahmedabad.

clip_image003

SQL Tips for .Net Developers: This was the first session of the day and Jacob Sebastian was as usual at his best. Needless to say that he is best when it comes to delivering SQL Server to wide range of audience again he done justification to his name with great session. It was a very informative session.

Best Database Practice for SharePoint Server: Pinal Dave was speaking on this topics and he is just an inspiration when he is on dais preaching about technology. He is awesomely articulated. He knows the art of connecting audience. The way he demonstrated the topic, audience was unable to put their eyes off from the projector screens. The way he mixes light sentences in between intense technical discussion makes his session very unique and that what he known for. His session was great and audience face had smile after the session.

Self Service Business Intelligence: Speaker on this topic was Rushabh Mehta. What I can say about PASS president and international speaker. I was amazed seeing his very much demo oriented session. He made such a complex topic so easy in front of audience. He demonstrated BI in EXCEL to SharePoint. I consider myself lucky that I heard him live.

Managing your future, managing your time: This session was just after lunch on a lazy winter day. And to keep audience awake after lunch, you cannot get better speaker than Vinod Kumar. He is best in speaking all we know. He started with a great self-motivating video. He talked about all points we need to focus as professional. Crowd was so excited listening him that it was unable to find the session was just after lunch. After a great motivating talk, he stared talking about SQL server. He moved from basic to complex in SQL server talk. Session was more than best for any level of audience.

Improve Silverlight application with Threads and MEF: If you need to understand a very complex topic just listen a session on topic from Prabhjot Singh Bakshi . He is a story teller. How easily he explained MEF (a complex pattern) to audience. All we were excited listening him. His inclusion of Hindi language one liners in between is awesome. Session was very useful.

Integration of SharePoint 2010 with Windows 7 Phone : This demo based session was delivered by me. I show demo on

1. Creating first WCF REST Service

2. Consuming REST in Windows 7 Phone : Picture Gallery application

3. Fetching SharePoint 2010 list data in Windows 7 phone.

At the end of the day, it was a very useful event for the Microsoft community. I would like to thank Ahmedabad User group members for such a nice event.

Connecting from SQL Server 2008 management studio to SQL Azure

In this walkthrough we will see how to connect from Local SQL server management studio to SQL Azure. Follow the below steps.

Open SQL Server management studio

clip_image001

You will get Connect to server dialog box. Click cancel on that.

clip_image002

After cancelling the dialog box click on New Query from left top

clip_image003

On clicking New Query, you will get the connect to server dialog box again.

clip_image004

Now here you need to provide, Server name of SQL Azure and Login credential of SQL Azure.

To know what is database server name of SQL Azure portal, login to Windows Azure portal with your live credential and then click on SQL Azure tab

clip_image006

You will get the server name in form of

abc.database.windows.net

Where abc is name of your SQL Azure server. We need to provide this server name at local sql server management studio.

clip_image007

Make sure to select SQL Server Authentication and provide login user name and password of your SQL Azure database portal.

After that before clicking Connect click on Option

clip_image008

Provide the database name you want to connect by default. I am connecting to Student database.

clip_image009

Now click on Connect to connect to SQL Azure

On successful connection to test

select * from sys.databases

You will get listed all your SQL Azure databases.

image

Upcoming book titled “Pro WCF 4.0” by Nishith Pathak

Title :  Pro WCF 4.0 “Practical Microsoft SOA implementation”

Author : Nishith Pathak

Publisher : APress USA

Expected Release : Jan/Feb 2011

Link : http://apress.com/book/view/9781430233688

About book

The release of .NET 4.0 brought a wide range of new functionality to WCF. Developers and Architects with experience using WCF 3.5 or earlier who want to be able to apply this new functionality to their application will benefit greatly from the discussions and code samples in this book. This book is also a great resource for application developers and architects new to SOA or just new to the core concepts of WCF.

clip_image001

About author Nishtih Pathak

When he was 21 he presented a session to 300+ audience. When he was 24 , he published his first book . When he was 27 , he published his second book. When he is 30 , he is going to publish his 3rd book . Microsoft WCF product team insider and architect at saipent. He is very well know speakers of various Microsoft events.

Being a connected system MVP , I am looking very forward for this book.

Creating Firewall rule for SQL Azure

All access to SQL azure is blocked by 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 azure application is blocked by firewall.

clip_image001

                                                                                         Image taken from MSDN

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. Click here to see how to do this?

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

a. SQL Azure checks the IP address of system making the request

b. If IP address is in between the range of IP address set as firewall rule of SQL Azure portal then connection get established.

Later in this article we will see how to create firewall rule on SQL Azure portal.

Follow below steps to create rules to

Step1

After login to SQL Azure portal, click on Firewall settings tab.

clip_image003

Step 2

Click on Add Rule. To see the IP address of your local system, you can check Your IP address. Make a note here is that IP address you see using IPCONFIG on local system and IP address registered with SQL Azure portal is different.

clip_image004

So check the Your IP address here and set the range such that your IP address lies in that range. After giving name and IP range click on Submit.

Connecting from Windows Azure

To connect from Windows Azure application you need to check the check boxes.

clip_image006

And set the Firewall rule for MicrosoftServices in the range of 0.0.0.0 to 0.0.0.0

clip_image008

After following the below steps

1. Creating Firewall rules by setting the range such that your IP address come under that range.

2. Creating the Exception at local firewall for port 1433.

You should able to connect to SQL Azure Data base. To test the connection select database from database tab and click on Test connectivity.

clip_image010

You would be prompted to provide user name and password

clip_image011

Provide user name and password and click on Connect . On successful connection you will get the below success message.

clip_image012

Walkthrough on creating a Database in SQL Azure

In this article, we will see how to create database in SQL Azure.

Step1

Login SQL Azure portal with your live credential

https://sql.azure.com/

Step 2

Click on SQL Azure tab. You will get the project , you have created for yourself.

clip_image002

Step3

Click on the project. In my case project name is debugmode. After clicking on project, you will get listed the entire database created in your SQL Azure account.

clip_image004

Here in my account there are two database already created. They are master and student database. Master database is default database created by SQL Azure for you.

Step 4

Click on Create Database

clip_image006

Step 5

Give the name of your database. Select the edition as Web and specify the max size of database.

clip_image007

You can select other option also for the edition as business

clip_image008

Step 6

After that click on Create you can see on Databases tab that Demo database has been created.

clip_image010

Setting up the Firewall on local system/computer to connect to SQL Azure

If we want to connect to SQL Azure from local system then we need to create an exception at local firewall for TCP port 1433.

Follow the below steps to create Exception on Windows 7 machine

Step 1

Click on Start button and then in Search text box type Firewall.

clip_image001

Step 2

You will able to see on top under Program tab , Windows Firewall with advanced security

clip_image002

Step 3

Right click on Windows firewall advanced security and select run as administrator

clip_image003

Step 4

You will get the below window

clip_image005

Step 5

Click on OutBound rules and then create on New Rules

clip_image007

Step 6

Now select PORT radio button and click Next

clip_image009

Step 7

Select TCP and Specific Remote port radio button.

In specific port address give port number 1433 to allow local system to connect to SQL Azure.

clip_image010

Step 8

Click Next , select Allow the Connection radio button.

clip_image012

Step 9

Click next and select all the option in check box.

clip_image014

Step 10

Click Next then give name and description to rule and click on Finish button

clip_image016

Now after this step we have created rule at local firewall to connect to SQL Azure

Default Protocol Mapping in WCF 4.0

In my previous post, I talked about Default End Point in WCF 4 . If we closely look at the output that by default WCF maps protocol to binding as below.

clip_image002

So if we are not configuring any EndPoint , then for http type base address in default EndPoint created by WCF will have basicHttpBinding.

If we see the above mapping , by default http type is mapped to basicHttpBinding , net.tcp type is mapped to netTcpBinding and so on.

If we want to change this, we can change this default mapping

clip_image004

Now when we do the above change in the Web.Config file then when we do not define any EndPoint then for HTTP type base address, WCF will create the EndPoint with wsHttpBinding.

So to understand more, what I am talking about

1. Create a WCF Service application

2. Create a Service contract as below

 [ServiceContract]
 public interface IService1
 {

[OperationContract]
 string GetData();
 }

3. Implement the Service as below

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfService1
{

 public class Service1 : IService1
 {
 public string GetData()
 {
 return "Hello From Iservice1 ";

}

 }
}

4. Now we will host this service in a console application, Create a new console application project. Add reference of WCF service application project and also add reference of System.serviceModel in the console application project.

5. Right click on the console project and add app.config file to console project. Right the below configuration in App.Config

 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <system.serviceModel>
 <protocolMapping >
 <add  scheme ="http" binding ="wsHttpBinding" bindingConfiguration ="" />
 </protocolMapping>
 </system.serviceModel>
</configuration>

6. Now write the below code to fetch the default Endpoint created by WCF

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using WcfService1;

namespace ConsoleApplication1
{
 class Program
 {
 static void Main(string[] args)
 {

ServiceHost host = new ServiceHost(typeof(WcfService1.Service1),
 new Uri("<a href="http://localhost:8080/service">http://localhost:8080/service</a>"));

host.Open();
 foreach (ServiceEndpoint se in host.Description.Endpoints)
 {
 Console.WriteLine("Address: " +  se.Address.ToString() +
 "  Binding: " + se.Binding.Name +
 " Contract :"+ se.Contract.Name);
 }

Console.ReadKey(true);
 }
 }
}

And output we would get is

clip_image006

So we can see that how we modified the default mapping using Protocol mapping in System.ServiceModel

Default End Points in WCF 4.0

For a normal developer like me, had a great challenge working with WCF 3.x was configuration of End Points in config file. Developer had to add endpoints to setup a WCF service. In WCF 4, Defualt End Point is associated with the service, if we don’t configure any WCF endpoint.

To see how Default EndPoint works follow the steps below ,

Step1

Create a WCF service application.

Let us create two service contracts

IService1.cs

[ServiceContract]
 public interface IService1
 {

[OperationContract]
 string GetData();
 }

IService2.cs

[ServiceContract]
 public interface IService2
 {
 [OperationContract]
 string GetMessage();
 }

 

Now let us implement the service as below,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfService1
{

 public class Service1 : IService1, IService2
 {
 public string GetData()
 {
 return "Hello From Iservice1 ";

}

public string GetMessage()
 {
 return " Hello From Iservice2";
 }

 }
}

 

Step 2

Now we will host this service in a console application, Create a new console application project.

Add reference of WCF service application project and also add reference of System.serviceModel in the console application project.

Note: There is no App.Config associated with console application.

clip_image002

Here, we are registering two base addresses with the servicehost. One for http binding and other for nettcp binding.

Now we don’t have any configuration for the service EndPoint . ServiceHost will create default EndPoints .

Now ServiceHost will configure EndPoints for two base addresses

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using WcfService1;

namespace ConsoleApplication1
{
 class Program
 {
 static void Main(string[] args)
 {

ServiceHost host = new ServiceHost(typeof(WcfService1.Service1),
 new Uri("<a href="http://localhost:8080/service">http://localhost:8080/service</a>"),
 new Uri("net.tcp://localhost:8081/service"));

host.Open();
 foreach (ServiceEndpoint se in host.Description.Endpoints)
 {
 Console.WriteLine("Address: " +  se.Address.ToString() +
 "  Binding: " + se.Binding.Name +
 " Contract :"+ se.Contract.Name);
 }

Console.ReadKey(true);
 }
 }
}

 

Output would be

clip_image004

The default protocol mapping is as below,

clip_image006

Since HTTP is mapped with basicHttpBinding , so we got the default EndPoint with basicHttpBinding.

Default EndPoint will only get created if there is not a single Endpoint configured. If we add any single EndPoint then all then there won’t be any default EndPoint get configured.

If we add one EndPoint as below,

clip_image008

We added one service EndPoint and now the output we would get for below code ad below,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using WcfService1;

namespace ConsoleApplication1
{
 class Program
 {
 static void Main(string[] args)
 {

ServiceHost host = new ServiceHost(typeof(WcfService1.Service1),
 new Uri("<a href="http://localhost:8080/service">http://localhost:8080/service</a>"),
 new Uri("net.tcp://localhost:8081/service"));
 host.AddServiceEndpoint(typeof(IService1),
 new WSHttpBinding(),
 "myBinding");

host.Open();
 foreach (ServiceEndpoint se in host.Description.Endpoints)
 {
 Console.WriteLine("Address: " +  se.Address.ToString() +
 "  Binding: " + se.Binding.Name +
 " Contract :"+ se.Contract.Name);
 }

Console.ReadKey(true);
 }
 }
}

 

Output

clip_image010

Now we see that if we configure a EndPoint then WCF does not support default Endpoints.