Sunday, April 24, 2011

Windows Azure – Hosting multiple WCF services on Azure

Most of SOA applications in today’s world are using WCF. No doubt you may come across a situation wherein you will require hosting your WCF services in Azure.
Today I will discuss the approach, which I have used for hosting multiple WCF services on Azure.
General approach of hosting a web site or WCF service is using a web role or WCF web role. However, if I have say 5 WCF services then? Obviously thinking of 5 WCF web roles is not the cost effective solution.
So, how can I host multiple WCF services using single WCF web role?




The approach is very simple and many have already implemented it.

Scenario – 1 – Without using WCF Service Library –
Create a cloud service project in visual studio 2010 and add WCF web role to it. Then copy paste your SVC files and their associated contracts to this WCF web role project. Add references required by your WCF application to WCF web role.
Add binding information of your SVC files to web.config of WCF web role and YOU ARE DONE!!
Your cloud service project will have structure as shown below –


Publish this cloud service project to Windows Azure portal and you will have multiple WCF services hosted successfully using single web role on Azure.

Scenario -2 – Using WCF service Library –
Sometimes you may have all the contracts information of WCF project and business classes in WCF service library project. You are using “WCFServiceApplication” project type for hosting the multiple WCF services.  In such scenario, create a cloud service project in visual studio 2010and add WCF web role to it. Then add “WCFServiceLibrary” project to the same solution.


Copy your contracts and their implementation classes to this newly added WCF service library project. Then copy your SVC files from “WCFServiceApplication” project to WCFWebRole project.
Add reference of WCF Service Library project to WCF web role project. Add binding information of your svc files to only web.config of WCFweb role project. Don’t add any binding information to app.config of WCF service library project. You can add if you want to (may be for running library project in local environment) but it is not required.
That’s it. YOU ARE DONE!!
Your cloud service project will have structure as shown below –


Publish this cloud service project to Windows Azure portal and you will have multiple WCF services hosted successfully using single web role on Azure.
Cheers…

Please give food to all my fishes swimming at the bottom. It's fun!! Try it!!
Thanks for reading!!
Happy Coding!!



3 comments:

  1. This is first time i am reading about this concept and here i got complete information about this concept.Register a Domain

    ReplyDelete
  2. Great To Read Your Post!!! There are actually quite a few different types of Cheap Hosting services available today that will allow you to have your own domain name and host a website on the Internet. The type of web hosting that you need, including the amount of space and the specific functionality, will determine the amount of money that you’ll need to spend in order to be able to host your website.



    ReplyDelete
  3. We give you the complete package of domain and cloud hosting services that are the reliable one, compare to other providers.

    ReplyDelete