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

Blog

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(
storageAccount.TableEndpoint.ToString(),
storageAccount.Credentials);
//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.DeleteObject(row);
}
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

Tags:

Name:
Email:
Subject:
Message:
x

Tags

.NET 4G 51Degrees 5G Acer Adform Adtech Advertising Afilias Alcatel Amazon AMP Analysis Analytics Android Apache API Apple Asian Market ASP.NET Asus Blackberry Browser C C# Centro Chrome Cloud CMS CPU CSS3 Data Data Blog Data File Daydream Design Detection Developers Device Device Data Device Detection Device Intelligence Device Models Device property DeviceAtlas Disney dmexco DotNetNuke Download ebay Ericsson Event Facebook Firefox Foundation Framework Galaxy git repositories Google Google Analytics Google Daydream GPU GSMA Guess HAProxy Hash Trie HTC HTML5 HTTP HTTP Headers Huawei Infinix Ingeniux Internet usage iOS iOS 13 ipad iPadOS iPhone iPhone 11 Java Javascript Kentico LG Liferay LTE m.dot Memory Memory leak Meta Data Microsoft Mobile Mobile Analysis Mobile Analytics Mobile Devices Mobile Marketing Mixer Motorola Mozilla MWC MWC 2017 MWC16 Native Apps NET New Release News Nexus NFC NGINX Nokia OnePlus 5 Opera Operating System Oppo Optimisation OS Patent Performance PHP Press Release Price Band programmatic Publishers Python Redirection Research Responsive Images Responsive web design RESS Review RTB RWD Safari Samsung Scala ScientiaMobile SEO Server Server-side optimisation Seznam.cz Sitecore Smart TV Smartphone Smartwatches Sony Swedish Beers Tablet Tencent Testing Tips Tutorial Umbraco Update User Agent User-Agent Valgrind Varnish Varnish Cache Video Vodafone VoLTE Web Web Apps Web content management Webtrekk White Paper Widgets WiFi Windows WURFL Xiaomi Xperia ZTE