Azure DevFabric: clean out old deploments

During development of an Azure application, I noticed that my disk kept running full. First time it happended, I thought nothing of it and just ran disk cleanup to clear out some obsolent files. Problem solved. At least, so I thought. Some hours later, I got a disk full warning once again. It turned out that it was caused by old local DevFabric deployments that used up disk space. Even though the deployments have been shut off, the deployment files lingered on. This is how the %USERPROFILE%AppData directory looked like:

What I had to do to fix this, was to run the following command:

csrun /devfabric:clean

Then, the old deployment files were deleted:

Adding WCF REST services to existing ASP.NET web application

If you want to create a new WCF services application with REST support, the WCF REST Templates are brilliant. However, if you have an existing ASP.NET application from which you want to expose REST services, there are a few manual steps you need to take to get it up and running:

Add assembly references

Add references to the following assemblies in your existing web project:

  • System.ServiceModel
  • System.ServiceModel.Activation
  • System.ServiceModel.Web

Create service class

Create a new service class where you will implement the service:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class LetterService
    [WebGet(UriTemplate = "")]
    public List<string> GetList()
        return new List<string>{"a", "b", "c"};

Register service route

In Global.asax.cs, define a route to the service:

void Application_Start(object sender, EventArgs e)
    RouteTable.Routes.Add(new ServiceRoute("letter", new WebServiceHostFactory(), typeof(LetterService)));

Enable ASP.NET compatability

Add the following to web.config:

      <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

…and you are good to go! The service will be available on http://<server>/letter

Optional: enable help

In order to get a nice help page for clients connecting to the service, add the following under the system.serviceModel element in web.config:

      <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />

Then, help will be available on http://<server>/letter/help