Enterprises invest in Platform as a Service (PaaS) solutions like Apprenda because no one can afford to throw out or rewrite existing applications. Realizing a seamless return on an existing investment requires migrating those apps to the platform.
This is a use case where the Apprenda platform excels. With a few strategic uses of platform API functions, developers can easily adapt existing apps to cloud-ready platform apps.
For a recent project, we adapted Survey Project to run on the Apprenda platform. This blog post recaps that process. Survey Project is an open-source C#.Net program for creating and administering web-based surveys. The original source on GitHub is comprised of roughly 30 kLOC of C#, 20 kLOC of SQL, and 145 kLOC of XML. The build output is approximately 8 megabytes.
You can see this change in commit 1809abf870, a one-line change to the solution file.
Survey Project’s database provisioning script was encoded in UTF-16, the default used by SQL Server Management Studio. Git, the Apprenda platform, and other tools treat this encoding as a binary format. This causes issues such as Git not being able to properly show the changes between two versions of a file with this encoding. Fortunately, UTF-16 encoding can be converted to UTF-8 without loss of content and that format is treated as text by Git and the platform.
You can see this change in commit cc82e526a2, though the before file is “binary” so the change isn’t very interesting.
One of the advantages of PaaS is that the platform handles details of deploying your services to appropriate servers. A consequence of this is that a static connection string or fixed database names can’t be used to access the application data.
The first change this requires is simply removing the USE clause from the top of the provisioning script. Second, Survey Project uses a forward alias in one of its stored procedures. This construction is somewhat non-portable and was remediated with a one-line change.
You can see these changes in commit 24922922b8.
The last change required for using databases on the platform is to add a platform-based connection string in web.config. The platform additions are done in such a way that the configuration file can still be used as before for local debugging and direct deployment.
This change can be seen in commit d9d435ff72.
The advantages of PaaS aren’t completely free. One necessary change in Survey Project was getting the connection string from the context provided by the platform rather than static text in a configuration file. The configuration change referenced above has a companion change in the code which gets the connection string from the platform when available and falls back to the existing configuration if it is not. You can see this small change in commit f79dc488de.
Survey Project has built-in authentication and authorization with which you can create users, manage passwords, and determine which users have what rights (creating surveys, creating reports, etc.). The platform also provides for authentication and authorization (and can delegate them to external services). To make a seamless experience when using surveys on the platform, we made one more small change to use the platform authentication when available.
For now, Survey Project on the Apprenda platform uses a very simple authorization model: you are either an administrator with all rights or a survey taker who can only provide answers.
The change to use platform authentication is in commit 7aa6bbfd0c.
With the changes described so far, you can manually build Survey Project and deploy it to Apprenda, letting the platform take care of authentication and database server selection. You can automate that process somewhat by putting some app configuration into a deployment manifest and packaging it with the app.
You can create the manifest from scratch or configure the app in the Developer Portal and export the settings for later reuse. For this simple case, the manifest specifies that the app is multi-tenant and uses the SurveyAdmin securable to control Survey Project rights.
You can see the manifest in commit 17b46f3e34.
In all, we changed or added approximately 70 lines in eight existing files to make the Survey Project platform ready. We also added a deployment manifest to make rebuilding and redeploying easy and automatic. While every application presents different challenges when onboarding to the Apprenda platform, many can be quite straight forward. Here we changed just 0.2% of the C# code and got the benefit of platform data management, authentication, and authorization.
If you want to use Survey Project on your Apprenda platform, the cloud-ready source can be downloaded from GitHub.