Feeds

Surviving the Facebook app 'swamp' with Azure

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

Boost IT visibility and business value

“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. ®

The essential guide to IT transformation

More from The Register

next story
The Return of BSOD: Does ANYONE trust Microsoft patches?
Sysadmins, you're either fighting fires or seen as incompetents now
Microsoft: Azure isn't ready for biz-critical apps … yet
Microsoft will move its own IT to the cloud to avoid $200m server bill
Oracle reveals 32-core, 10 BEEELLION-transistor SPARC M7
New chip scales to 1024 cores, 8192 threads 64 TB RAM, at speeds over 3.6GHz
Docker kicks KVM's butt in IBM tests
Big Blue finds containers are speedy, but may not have much room to improve
US regulators OK sale of IBM's x86 server biz to Lenovo
Now all that remains is for gov't offices to ban the boxes
Flash could be CHEAPER than SAS DISK? Come off it, NetApp
Stats analysis reckons we'll hit that point in just three years
Nimble's latest mutants GORGE themselves on unlucky forerunners
Crossing Sandy Bridges without stopping for breath
prev story

Whitepapers

5 things you didn’t know about cloud backup
IT departments are embracing cloud backup, but there’s a lot you need to know before choosing a service provider. Learn all the critical things you need to know.
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Build a business case: developing custom apps
Learn how to maximize the value of custom applications by accelerating and simplifying their development.
Rethinking backup and recovery in the modern data center
Combining intelligence, operational analytics, and automation to enable efficient, data-driven IT organizations using the HP ABR approach.
Next gen security for virtualised datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.