Skip to main content

Porting Nerddinner on IronFoundry

One of the new entrants in the .Net PaaS space is IronFoundry. Tier 3 an enterprise cloud platform for mid-tier, large enterprise and SaaS have come up with Iron Foundry(IF) a port of Cloud Foundry(CF) that is targeted towards Microsoft .Net platform. IF is an implementation of CF that is tightly integrated with the .NET Framework. It can support multiple frameworks, cloud providers, and application services all on a cloud scale platform.

The platform is currently thin on documentation so what better way to learn about it than to port some application to run on IF

Nerddinner - The application of choice
Nerddinner was a good fit for this exercise. It is a tiered application with an ASP.Net MVC based front end and MS SQL Server based data access, both supported by Iron Foundry out of box.

The Process
The process started with setting up an Iron Foundry account that would be used to deploy the application. Since the service is in beta there is no cost incurred during setting up the account. Registration process was trivial but account provisioning was not :) . I tried three email addresses before receiving an account approval mail.

The next step was to download the necessary tools to interact with the IF platform.
The following tools come in handy

Cloud Foundry Explorer: A windows app to manage your CF instances and services.
VMC .NET: Command Line tool for managing CF instances.
Visual Studio Extension: This extension allows directly integration of Visual Studio with the IF platform.

These tools need to be configured with the account details created earlier. Refer to the documentation for CF Explorer here to understand how to configure user account. Similar configurations are required for Visual Studio extension too.

Migrating Nerddinner codebase
I migrated the Nerddinner (changeset 70027) codebase to github due to my new found interest in git and github.
After setting up a new repository, migrating the existing codebase and setting up the clone locally it was time to open the Nerddinner solution in Visual Studio.

Deploying Nerddinner
The Nerddinner solution compiled successfully. I did a local run to make sure that there were no runtime errors. Nerddinner works well out of box without any manual configuration and same was true in my case. Nerddinner stores data in SQL server and the default codebase is configured to run with local SQL Express.

I ignored the database requirement for the time being and just went ahead and deployed the application onto Iron Foundry.

Deploying the application from Visual Studio was pretty straight forward.
Right click on the ASP.Net MVC project, click ‘Push Cloud Foundry Application..’ (For first time deployment).
On the subsequent dialog enter the new application details


All of the options in this dialog are self-explanatory except the “Application Services” section. I would come back to it later in this post.

On clicking Push button, following actions are performed behind the scene

  • The application is pre-compiled.
  • The application is pushed to IF infrastructure for deployment. 
  • The application gets deployed based on the selected configuration and is ready to be used.

    The last step has its own workflow which I would not dwell in this post. Since IF is a port for CF see this video to understand the deployment complexities involved.

    Once deployed I fired the CF Explorer and double clicked the deployment node on the left side


    The highlighted area shows the instances of my application running (one in this case).

    I Fired my browser and typed http://nerddinner.gofoundry.net and voila!!! the application was up and running.

    Tip: When trying to deploy the application from Visual Studio, if pre-compilation fails, you may not be able to determine the exact reason of failure as the failure message gets truncated in the error message window.  Use the VMC.Net client tools or aspnet_compiler.exe (part of .net framework) to precompile the application from command line to get detailed error. The aspnet_compiler switches used internally by VMC.Net client are 

    -nologo -v  -p  -f -u -c

    Linking Database
    In spite of my initial success, I still needed to tackle database integration.
    Since file based database and SQL Express are not supported I required some alternative. Iron Foundry Services came to rescue. These services are infrastructure components that can be consume by any host within the IF environment. Currently IF supports two services

    • MongoDB
    • MS SQL Database Service

    As compare to CF services the service offerings in IF are limited and would evolve over time as the platform matures.

    Meanwhile SQL Database service was available for me to get started. The Services section on the CF explorer allows us to create services for our account.



    Once a service is created it can be used by multiple deployments.

    I went ahead and created two MS SQL data service.

    • One to store Nerddinner data
    • Another to store SQL Profile, Role and Membership data. Nerddinner uses the standard ASP.Net Membership provider API to support authentication \ authorization.

    The next step was to associate the two services with my current deployment. This too can be done from the CF explorer. Drag the service to the right hand side to create an association.

    Although the step above provisioned and associated the database service with my application, I still did not receive any connection information that is needed to connect to the newly provision database.
    When we associate a service with our application, IF adds the connection information to web.config file of the associated application. To get details about the connection string I had to

    • Download the web.config for my application from CF Explorer.
    • Locate connection string with name=”Default” and copy the connection string value
    • Replace the existing connection information within the local web.config with the value copied

      Future Improvement: CF explorer should provide a easier mechanism to download connection details.

      After the web.config changes i had to update the deployment. Updating deployment in IF is as easy as deploying a new application in IF. To update an application

      From Visual Studio select “Update Cloud Foundry Application…”
      This brings up a dialog which helps us select the application that we want to update.



      After selecting the appropriate ‘Cloud’ and ‘Application Name’ options click update.

      My deployment was updated and I had linked my application with correct database but still the database had no schema or data.

      Creating DB Schema
      MS SQL database service currently cannot be access from outside and hence tools such as Management Studio would not work. This made the task of creating database schema on the newly provisioned database little challenging.

      To solve this problem I went ahead and create database schema script using the existing database provided as part of Nerddinner codebase. I created two scripts one for each Nerddinner DB and aspnet DB. The new scripts have been added to the solution and are part of codebase I have shared at the end of this post.

      A DatabaseCreator class was created containing methods to run both of these scripts. The method calls were added to global.asax.cs Application_Start event to make the scripts run on application first load.

      I pushed the changed to IF once again and prayed:)

      Everything ran smoothly and I now had Nerddinner running smoothly, Hurray !!! You can check out the application at http://nerddinner.gofoundry.net. The code base is available at GitHub here.

      As you can see this was a lengthy exercise but I am glad with the results. Porting Nerddinner help me understand the good, bad and ugly of the new platform. I share some on my observation in the last section of this post

      The Verdict

      The Goods Parts
      • Microsoft Azure has more competition. Competition is always good :)
      • Upgrades + configuration changes are fast, really fast as compared to Azure.
      • Open Source.
      • Visual Studio integration.
      • Well suited for web applications.

      Things to Improve
      • Lack of error logs. There were time when the instances showed down and did not start at all but there was no way to determine what happened.
      • Lack of direct access to database. This makes schema changes difficult.
      • Limited documentation.
      • Supports only web apps. Concepts similar to Azure worker roles not available
      • Limited availability of  ‘Services’ as compared to CF.
      • Instance customization not available at present. Windows Azure achieves this through startup tasks.
      • IF does not have a storage service similar to Azure (table, blobs) or EC2.
      • As the framework mature I would love to see a migration guide for migrating solutions from Windows Azure to IF.

      To sum it up Iron Foundry is a promising offering but it is still not ready for prime time consumption.
      The success of Iron Foundry depends upon its adoption within enterprise, its developer community and the Hosting providers (including Tier 3) who can provide hosted solution over Iron Foundry.

      Comments

      Popular posts from this blog

      Caching Images downloaded from web on Windows Phone Isolated storage

      I was helping on a Windows Phone application where the requirement was to cache the images the phone downloads on the isolated storage for offline viewing.
      I wanted a solution which was simple and as transparent as possible. While researching I found  someone wrote a Silverlight converter for loading images from isolated storage. Taking that as a base I created a converted which can
      Load image from web (http + https), and persist it to isolated storage.In case of network connectivity issues can load the same image from isolated storage. It does that by mapping the http url to a isolated storage location.In case the network is down and the image is neither there in cache, loads a default image, passed as parameter to converter.Here is the gist for the implementation.


      To use the converter
      Import the name space.Declare the converter as resource.Set the Image Source Property to use this converter like this 

      AngularJS Model - ViewModel

      Recently Robin Ward did a comparison between AngularJS and Ember (both the post and the comments are interesting read). One of the complaint that Robin had that AngularJS does not provide any specialized model class. As described in the blog

      There is no standard Model base class, nor is there a component or interface in AngularJS that defines what a model is supposed to be.
      What that means is that anything defined on $scope can acts as model, as this sample on the blog describes




      For some (like me) this is the flexibility where as for others who want a more structural approach this is a nuisance.AngularJS does not even provide any definite guidelines around how the model should be actually designed to be effective with AngularJS

      This leads to what we call as $scope pollution. We define multitude of properties on the $scope object and managing it becomes difficult.  Looking at the code one cannot tell what is the actual model and what properties are just to support UI logic.

      Model Desig…