Hosting WCF services (with HTTP endpoints) in Windows Azure worker roles
"A highly recommended tool"

Beautiful REST services URLs in Windows Azure with WCF4’s routing integration feature

Update: It turns out that the necessary WCF4 config sections for standardEndpoints are not present in Windows Azure, although we are using a .NET 4-based Azure role :( Thanks for my readers Piotr and Rene for the hint! The config below has been updated.

We all know how certain people hate the .svc in URLs when they are designing and building REST services with WCF. Just because I had a question from a customer today how to have ‘beautiful’ URLs for a WCF service being hosted in Windows Azure I thought I will write up the very simple and straight-forward solution.

The only pre-requisite you need is .NET 4.0 (and thus WCF4).

WCF4 has a nice feature I like really a lot. It is the integration into the System.Web.Routing engine when it comes to hosting your services. You can simply add a route to your service implementations in the global.asax file – as seen in the code below. No need for .svc files, yiha!

<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.ServiceModel.Activation" %>
<%@ Import Namespace="Thinktecture.TecTeacher.MediaServices" %>
<script runat="server">
    void Application_Start(object sender, EventArgs e) 
               new ServiceRoute(
                   "media", new WebServiceHostFactory(),

Together with the also new automatic help page feature and the automatic response format selection in WCF4 you get a nice REST service hosted in IIS. And obviously this can also be used in a Windows Azure Web Role which leverages IIS’s hostable web core (HWC).

<?xml version="1.0"?>
    <sectionGroup name="system.serviceModel"
                  type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="standardEndpoints"
               type="System.ServiceModel.Configuration.StandardEndpointsSection, System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <compilation debug="false"
                 targetFramework="4.0" />
    <modules runAllManagedModulesForAllRequests="true"/>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <standardEndpoint helpEnabled="true"
          <security mode="None"/>

WCF REST service 

WCF REST service help 

WCF REST service call help

This is how the service’s response looks like in XML…

WCF REST service call result in XML

…and this is the JSON formatting:

WCF REST service call result in JSON

That’s it. As you can see there is nothing Azure-specific, just plain WCF4.
Download a small sample solution.

Hope this helps someone.


Feed You can follow this conversation by subscribing to the comment feed for this post.


Have you tried to deploy this solution in Windows Azure? When I have tried to deploy your aplication in Windows Azure it hang in "Busy" status. Only removing the section from the web.config has allowed to successfully deploy the solution in Azure environment.

-- Piotr


Regarding to the last comment. It was a standardEndpoints section. Only removing it allow to successful deployment.


I added the following section at the beginning of web.config file which fixed this issue:


configSections sectionGroup name=system.serviceModel
System.ServiceModel, Version=, Culture=neutral,
PublicKeyToken=b77a5c561934e089 section name=standardEndpoints
System.ServiceModel, Version=, Culture=neutral,
PublicKeyToken=b77a5c561934e089/ /sectionGroup /configSections


I've tried to follow this tutorial with my own web service, and to download the attached package. Both have the same result: when I try to run it in VS2010 it hangs on "Launching the browser" and global.asax.cs is never run.

Does the package run as is in VS or does it need to be deployed to azure hosting to see it operate ?

Christian Weyer

Hi Andiih,

yes, the sample from the download above works for me and several other people in the local dev fabric and in Azure.


Thanks for this. It helped me save a lot of time and worked on Azure rightaway..
I did however have to add a multipleSiteBindingsEnabled ="true" attribute in the tag for this to work in IIS...strange because even in Azure it would have gotten installed on IIS itself but i kept getting a multibindings error untill i added this attribute. Any clue why this error did not arise in Azure deployed version???


Christian Weyer


which Azure SDK version are you using?

Moncler Jackets

I thought I will write up the very simple and straight-forward solution.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment

Comments are moderated, and will not appear until the author has approved them.

Your Information

(Name is required. Email address will not be displayed with the comment.)