• About Us
  • Blog
  • Basket
  • Account
  • Sign In


Published on Tuesday, August 9, 2011

51Degrees.mobi Foundation and Windows Azure

Windows Azure is one of the latest Microsoft web technologies that offers fast cloud based web hosting to .NET web solutions. 51Degrees.mobi Foundation now supports the Azure cloud, allowing fast, accurate browser detection with all the capabilities anyone could ever need. Here is a guide on how to deploy the Foundation on Windows Azure. To The Cloud!

What's the Difference?

Windows Azure is powered by ASP.NET, so it was possible to use 51Degrees.mobi Foundation to detect mobile browsers same as before. However, there were issues with tracking redirections over multiple instances and keeping the log file. Azure doesn't have file system concept so keeping that information in a common file location cannot work. 

Instead, this update stores that information into a storage table. This enables all the instances to keep logs for debugging and to keep a record of previous device requests so 'firstRequestOnly=true' can work.

Setting up the Foundation

The code for Foundation can be found here. Anyone looking to deploy should also look at the release note. This release introduces a new conditional compiler symbol, 'AZURE'. Only AZURE builds will work on the cloud but will not work on regular ASP.NET. See the user guide and example website in the source code linked to above to see how to integrate Foundation with your web application.

To make use of the changes you must create a storage account and put the name into the AZURE_STORAGE_NAME string in the Constants class (this requires modifying the source). The foundation will then create two tables, one for previous devices, and another for logs. The names for the tables are taken from web.config where the file names are usually specified (‘redirect/devicesFile’ and ‘log/logFile’). Any invalid characters, such as ‘/’ are stripped out. If you don't need to use either of the tables then simply leave devicesFile/logFile out. If both tables have been omitted then a 'fiftyonedegrees' storage account isn't required. Otherwise an exception will be thrown.

Apart from that, the rest of the Azure configuration is the same as any other Azure configuration. The only caveat to that is that unlike some Azure deployments, the web.config must be deployed. Set the Build Type as 'Content' in the Properties of web.config to make sure the package is deployed with all the correct foundation settings.

Accessing the Data

The way to view the log in traditional deployments is to just open the text file. In the Azure environment though, the table must be read in code and then either shown in a browser or downloaded to a file. This code shows how to fill a string with the contents of the log table:

using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure.ServiceRuntime;
using FiftyOneDegrees;
//Access the storage account
var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("fiftyonedegrees"));
//Create the service context to access the table
var serviceContext = new TableServiceContext(
//Getting the table entries
foreach (var row in serviceContext.CreateQuery("log")) //"log" - the name of the table you wish to examine
OutputString += row.Message;
//Deleting all the table entries
foreach (var row in serviceContext.CreateQuery("log"))
serviceContext.SaveChanges(); //It is important to save changes to delete objects

Will this Cost Extra?

As always, the Foundation continues to be free and open source. However, the Foundation will also use a small amount of storage transactions to keep the tables up to date. The code has been designed to use as few queries as possible, so this shouldn't be a problem.

And with that you now have mobile detection on the Azure Cloud. If you run into problems make sure you have compiled the Foundation with both the 'AZURE' and 'VER4' compiler symbols, or you could leave a comment or go to our forums.

Comments (0)

Author: Anonym

Categories: Development




.NET 2013 2014 4G 51Degrees 5G A.C.Roma A7 ABI Acer Adtech Affiliate Marketing Afilias Alcatel Amazon AMP Analysis Analytics Android Android 5.0 Lollipop Android Kitkat Android Lollipop Android Media Stick Apache API Apple Apple TV Archos Asha Asian Market ASP.NET Asus Australia Big Data Black Friday Blackberry Blink Browser C C# Case Study CeBIT CES Chrome Cloud CMS combinations Comparison Competition CoolPad COTW Cron CSS3 Data Data Blog Data File Data Model Daydream Denver Design Desire Eye Desktop Detection Developers Device Device Data Device Detection Device Intelligence Device Popularity Device property Device Types Device Use DeviceAtlas Display dmexco DoCoMo Doogee DotNetNuke Download Drupal Email EReader E-Reader Ericsson Evaluation Event Examples EXPLAY Rio Facebook feature Firefox Firefox OS Fly Foundation Framework France Galaxy S3 Galaxy S5 Galaxy Tab A Galaxy Tab A 8.0 Galaxy Tab A 9.7 Germany git repositories Global Google Google Daydream GSMA HAProxy Hardware Hisense HTC HTC ONE MAX HTC OS HTML5 HTTP HTTP Headers Huawei HUAWEI. UPDATE HUDL Huwaei IBC Icemobile Prime 4.0 IE IFA IIS Image Optimiser Image Optimizer India Infographic Ingeniux Internet usage iOS iOS 7 iOS 8 ipad iPhone iPhone 6 IsEmailBrowser IsWebApp Italy Japan Java Javascript Jolla Kentico Keynote Kindle Kindle Fire Kindle Fire HD Leagoo Lenovo LG Location Log File Analysis LTE Lumia m.dot macOS Map Memory Meta Data Mi 4S Micromax Microsoft Miia Style Mobile Mobile Analysis Mobile Analytics Mobile Devices Mobile Marketing Mixer Module Motorola MVC4 MWC MWC 2017 MWC16 MyPhone Native Native Apps NET New Release News News Letter Nexus Nexus 6 Nexus 9 NFC NGINX Nokia Nokia 3310 Non-Mobile NVIDIA Omate On7 OnePlus 5 Opera Opera Mini Operating System Optimisation OS OSX 10.10 OTA Panasonic Patent PC Pebble Performance phablet phone PHP Poland Presentation Press Release Price Band PRIV programmatic PS4 Publishers Python QMobile QR Codes Redirection Research Reseller Responsive Images Responsive web design RESS Review reviews RIM Ringmark RTB RWD Safari Samsung Scala ScientiaMobile Screen Screen resolution Screen Size SEO Server Server-side optimisation Set Box Set Top Box Sharepoint Shark 1 SHIFT phones Sitecore Sitecore version 9 SLUSH Smart TV Smartphone Smartphones Smartwatches Snapdragon Sony Sony Xperia Spain Swedish Beers Symbian Tablet Tablets Tesco Testing Tips Top 5 TOTW Tutorial TV UDS UK Umbraco Update updates US User Agent UserAgent User-Agent Vendors Version 3 Video VoLTE VR Wearable Web Web Apps Web content management WebKit WebMatrix White Paper Widgets Widnows WiFi Wiko Wileyfox Windows Windows Phone WURFL Xbox XBox One Xiaomi Xperia Xperia z Yosemite Z10 ZenFon 2 ZOPO ZTE