Feeds

Surviving the Facebook app 'swamp' with Azure

Cloud platform, cloud client. Is Facebook and Microsoft Azure the perfect fit?

High performance access to file storage

“Developing with Facebook is like building a house on a swamp,” says Microsoft’s Nathan Totten. He should know. He used to work at social media company Thuzi, and when the company needed to write a C# Facebook application, he and his colleague Jim Zimmerman were so disappointed by the existing C# SDKs that they built their own.

Nathan Totten, technical evangelist at Microsoft. Totten is now a technical evangelist at Microsoft, and his project has become the open source Facebook C# SDK with a measure of approval from Microsoft as the suggested way to build C# applications for Facebook.

So why is Facebook development swamp-like? The first problem is that the Facebook API changes over time, and any wrapper you build on top can soon get out of date. The second problem is that Facebook does not officially support C#. It has SDKs for JavaScript, Apple iOS, Android and PHP.

In mitigation, the dynamic features of C# 4.0 are actually well-suited to APIs that are in flux, as Totten explains in his post mentioned above. Some API changes and additions can be accommodated without changing the SDK at all. This has also made it possible to make the C# SDK somewhat similar to the PHP SDK, which is an advantage when you are consulting the Facebook documentation.

Nevertheless, there are challenges. I tried the SDK with a simple Facebook canvas application, hosted of course on Azure. A canvas application is one that is embedded into a Facebook page. I started with an ASP.NET MVC 2.0 application, then added a reference to the Facebook C# SDK using NuGet, Microsoft’s package manager.

Facebook and Azure screenshot

Up and running: a Facebook Canvas app written with C# and hosted on Azure

To develop the app, I configured the application on Facebook to link to the web page running on localhost. Facebook apps generally request permission from their users to access personal information. In principle, the Facebook C# SDK makes this easy by using attributes. My app queries user status, so I annotated a method with:

[CanvasAuthorize(Permissions = "user_status")]

At runtime, Facebook popped up a dialog requesting permission. Easy. Unfortunately I soon ran into problems. After the user grants permission, you have to include an access token in calls to the Facebook API. There are several kinds of access token, and getting this right can be tricky.

Simple attributes in the code prompt the correct Facebook permission prompts.

I also discovered that the Facebook C# SDK is barely documented. A documentation link on the open-source site has no reference material, just a few examples and links, some of them out of date. Another problem cropped up.

I deployed my working app to Azure and it no longer worked. The reason, I discovered, is that some browsers block cookies from sites running in iFrames. If you ever have to debug a problem like this, which works locally but not on Azure, you will be grateful for an Azure feature called Web Deploy.

Normally, whenever an application is published to Azure, the cloud platform creates a new virtual machine, copies it, and then spins up the copy. This is why publishing to Azure takes a long time. Web Deploy, by contrast, updates the application on an existing VM, which takes only a moment.

Once you have debugged successfully, you still need to publish properly as otherwise the VM may revert to the original upload. There are hassles then, and it is curious that Microsoft and Facebook have not done more to make it easy to build C# Facebook applications. Having an open-source library is all very well, but it needs proper documentation, as does the companion Windows Azure Toolkit.

Once you have the plumbing right though, there is some sense in it.

Nothing insurmountable

Enteraction, a UK games company, uses Azure and the C# for its social media gaming framework, called GameShaper. According to operations director Arthur Barker, Azure provides scalability while being compatible with familiar Microsoft-platform technologies.

Developing with Facebook is like building a house on a swamp

Enteraction uses the Facebook C# SDK to get round Facebook’s lack of support for C# and .NET. “We have experienced a few teething issues, but nothing insurmountable nor unexpected for an SDK of limited maturity,” Barker told me. “Overall we are very happy with Azure.”

It is not essential to use the Facebook C# SDK, and another developer told me that he prefers to roll his own; it may take longer, but at least you know how it works.

Nevertheless, from the point of view of Facebook integration, using C# instead of PHP does feel like rolling a ball uphill. Then again, the integration points are likely to be only a small part of the whole, and if Visual Studio and Microsoft SQL Server are familiar, the benefits of using them can outweigh a little pain at the Facebook end. ®

High performance access to file storage

More from The Register

next story
Seagate brings out 6TB HDD, did not need NO STEENKIN' SHINGLES
Or helium filling either, according to reports
European Court of Justice rips up Data Retention Directive
Rules 'interfering' measure to be 'invalid'
Dropbox defends fantastically badly timed Condoleezza Rice appointment
'Nothing is going to change with Dr. Rice's appointment,' file sharer promises
Cisco reps flog Whiptail's Invicta arrays against EMC and Pure
Storage reseller report reveals who's selling what
Just what could be inside Dropbox's new 'Home For Life'?
Biz apps, messaging, photos, email, more storage – sorry, did you think there would be cake?
IT bods: How long does it take YOU to train up on new tech?
I'll leave my arrays to do the hard work, if you don't mind
Amazon reveals its Google-killing 'R3' server instances
A mega-memory instance that never forgets
USA opposes 'Schengen cloud' Eurocentric routing plan
All routes should transit America, apparently
prev story

Whitepapers

Mainstay ROI - Does application security pay?
In this whitepaper learn how you and your enterprise might benefit from better software security.
Five 3D headsets to be won!
We were so impressed by the Durovis Dive headset we’ve asked the company to give some away to Reg readers.
3 Big data security analytics techniques
Applying these Big Data security analytics techniques can help you make your business safer by detecting attacks early, before significant damage is done.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Mobile application security study
Download this report to see the alarming realities regarding the sheer number of applications vulnerable to attack, as well as the most common and easily addressable vulnerability errors.