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 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.
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 DatabaseIn 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
- 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 SchemaMS 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 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.