In the previous article we have experimented the ways of WCF hosting in Windows
Azure. In this article I would like to summarize the important points of WCF
service exposing in Windows Azure.
There are multiple ways of hosting WCF service in Windows Azure.
Let us examine them closely.
Method 1: Web Role Hosting
In the Web Role hosting, the WCF service is hosted inside IIS. This will give
the advantages of IIS to the WCF service.
- Identity Management
- Recycling
- Caching
- Pooling
- Logging
The Service creation will be much easier in
this method as Visual Studio provides the templates for Service (.svc files). We
need to create a new .svc file and place it in the web role project. The host
names and ports are configured by the deployment and we can access the service
through a browser.
The metadata end points are also automatically added. This saves a lot of amount
of work from the developer side.
Method 2: Worker Role Hosting
Here the developer has to perform more work in creating the service contracts by
defining the attributes in the contracts and implementation.
This method is advised if more control is needed over the service. We can easily
configure the protocols in this way. In this case a corporate port has to be
opened to expose the service while using the worker role.
Method 3: Hosting through AppFabric
In this method the WCF service is exposed through the Service Bus service
feature of Windows Azure AppFabric. We can choose this option if we need to
connect two disconnected applications.
This method is self hosted and more configurations needed. Here we can connect
two disconnected applications using the Service Bus namespace. The namespace
identifies the subscription and will be used for billing purposes on the cloud.
The Service Bus provides the following features:
- Connectivity between disconnected applications
- Higher Availability
Relay Service
There are two modes of connectivity in the Relay Service.
- TcpRelayConnectionMode.Relayed
- TcpRelayConnectionMode.Hybrid
The default mode is Relayed and here the
service and client is connected through the relayed service.
Relayed Mode Connectivity
The following picture depicts the process in the Relayed mode.
The steps involved are following:
Step 1: The WCF Service authenticates and registers with the Relayed
Service using the namespace and Provider keys.
Step 2: The Client authenticates with the Relay Service
Step 3: Client invokes a method using the Relay Service
Step 4: The Relay Service redirects the call to the registered WCF
service.
Hybrid Mode Connectivity
In the Hybrid way of connectivity the client can communicate directly to the
service. First the client connectivity starts as Relayed as usual and then if
there is possibility of connecting directly to the service it will be provided.
Summary
In this article we have discussed the various WCF exposing methods in Windows
Azure like web role, worker role and through AppFabric Service Bus.