<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Carlos Figueira MSDN blog</title><link>http://blogs.msdn.com/b/carlosfigueira/</link><description>General thoughts and usage examples about WCF, ASP.NET Web API, Windows Azure Mobile Services, testing and programming in general.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Preserving date time offsets in Azure Mobile Services</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2013/05/13/preserving-date-time-offsets-in-azure-mobile-services.aspx</link><pubDate>Mon, 13 May 2013 21:49:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10418245</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10418245</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10418245</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2013/05/13/preserving-date-time-offsets-in-azure-mobile-services.aspx#comments</comments><description>&lt;p&gt;In my &lt;a href="http://blogs.msdn.com/b/carlosfigueira/archive/2013/04/22/large-numbers-and-azure-mobile-services.aspx"&gt;last post&lt;/a&gt; I mentioned that due to the heterogeneous nature of Azure Mobile Services (JavaScript in the server, other languages / frameworks in the client), some data types have some problems with the conversion between the two environments. Numbers and dates are the most common, but &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/azuremobile/thread/7d612012-2582-4cf6-8b03-58577ab620d6"&gt;this post from the MSDN forum&lt;/a&gt; pointed out that &lt;a href="http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx"&gt;DateTimeOffset&lt;/a&gt; values also have issues. Basically, &lt;a href="http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx"&gt;DateTimeOffset&lt;/a&gt; values are interpreted in the server side as JavaScript Date objects, and as such they don’t have any information about offsets (in JS dates are represented as a number of milliseconds since the “Unix 0”, 1970/01/01:00:00:00 UTC). The result was that the offset was lost in translation, and that was a problem for the forum poster.&lt;/p&gt;  &lt;p&gt;There are ways to work around this limitation, however. The simplest alternative would be to split the &lt;a href="http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx"&gt;DateTimeOffset&lt;/a&gt; property into two properties in the client side – one for the DateTime itself, and one for the offset from UTC. In this case, the class would have two properties equivalent to the DateTimeOffset property – and the type can even continue with the original property (properly marked with &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonIgnoreAttribute.htm"&gt;[JsonIgnore]&lt;/a&gt; to prevent it from being sent to the server and creating a new column – notice that this code is already using the version 0.3.x of the client SDK, &lt;a href="http://blogs.msdn.com/b/carlosfigueira/archive/2013/03/14/azure-mobile-services-managed-client-upcoming-breaking-changes.aspx"&gt;the Portable Library-based SDK from the NuGet feed&lt;/a&gt;). The code below shows the before and after version of a type with a DateTimeOffset property.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2d574689-1ac7-40c7-a4d7-d1752f537134" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Event&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Id { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Name { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Location { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeOffset&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Time { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ModifiedEvent&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Id { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Name { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Location { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; UtcTime { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; UtcTimeOffsetMinutes { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonIgnore&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;]&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeOffset&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Time&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeOffset&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.SpecifyKind(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.UtcTime.ToUniversalTime(), &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeKind&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Unspecified),&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;TimeSpan&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.FromMinutes(UtcTimeOffsetMinutes));&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.UtcTime = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;value&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.DateTime.Kind == &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeKind&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Unspecified ?&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.SpecifyKind(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;value&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.DateTime, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeKind&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Utc) :&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;value&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.DateTime.ToUniversalTime();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.UtcTimeOffsetMinutes = (&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;value&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Offset.TotalMinutes;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;   &lt;p&gt;That solution works fine, but it forces us to change the domain object on the client side to deal with a distributed problem. If other people are using this type, they will get affected by it (we can mitigate it by using something like decorating the UtcTime and UtcTimeOffsetMinutes with &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsableattribute.aspx"&gt;[EditorBrowsable(EditorBrowsableState.Never)]&lt;/a&gt;, but that’s again just working around the problem. What we can do is to change the way we serialize the original Time field, so that only during the serialization (and deserialization) of the type we need to worry about deconstructing (and reconstructing) the value. I &lt;a href="http://blogs.msdn.com/b/carlosfigueira/archive/2012/09/06/supporting-arbitrary-types-in-azure-mobile-services-managed-client-complex-types.aspx"&gt;posted before&lt;/a&gt; about how we can do it with the original managed client SDK, and the idea with the new version of the SDK (based on JSON.NET) is similar, as I’ll show below.&lt;/p&gt;    &lt;p&gt;First, we don’t need to split the parameter in multiple values – all we need to do is to decorate the property with the &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonConverterAttribute.htm"&gt;[JsonConverter]&lt;/a&gt; attribute to tell the client runtime that we want to use our own code to convert that value to and from JSON.&lt;/p&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:86e89a64-f0e0-4b57-95d5-2b3842bef968" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Event&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Id { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Name { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Location { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonConverter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;typeof&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DtoPreservingOffsetConverter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;))]&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeOffset&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Time { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;    &lt;p&gt;We can now go about implementing the converter – a type deriving from the &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonConverter.htm"&gt;JsonConverter class&lt;/a&gt; from JSON.NET, with three abstract methods. The implementation of &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/M_Newtonsoft_Json_JsonConverter_CanConvert.htm"&gt;CanConvert&lt;/a&gt; is trivial, as shown below.&lt;/p&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5aa91dce-3d56-43aa-817a-514381fc03a5" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DtoPreservingOffsetConverter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; : &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonConverter&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;override&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;bool&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; CanConvert(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Type&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; objectType)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; objectType == &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;typeof&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeOffset&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;override&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ReadJson(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonReader&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; reader, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Type&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; objectType, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; existingValue, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonSerializer&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; serializer)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;null&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;override&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; WriteJson(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonWriter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; writer, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; value, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonSerializer&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; serializer)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;    &lt;p&gt;To write the object into JSON we could call the appropriate methods into the JsonWriter parameter, but the simplest way is to wrap them into a dictionary, and let the JSON.NET serializer deal with that for us. What we’re doing here is to write the DateTimeOffset value as a &lt;em&gt;JSON object&lt;/em&gt; with two members, one for the UTC value date component, one for the offset component.&lt;/p&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:219d95c5-a3c4-412d-b28c-cb911a3dfbdb" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;override&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; WriteJson(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonWriter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; writer, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; value, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonSerializer&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; serializer)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeOffset&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dto = (&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeOffset&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)value;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dt = dto.DateTime.Kind == &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeKind&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Unspecified ?&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.SpecifyKind(dto.DateTime, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeKind&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Utc) :&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;dto.DateTime.ToUniversalTime();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Dictionary&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt; temp = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Dictionary&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{ &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;DateTimeUTC&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, dt },&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{ &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;OffsetMinutes&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, dto.Offset.TotalMinutes }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;};&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;serializer.Serialize(writer, temp);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;    &lt;p&gt;And since we write it, we need to read it back, so here’s the implementation of ReadJson:&lt;/p&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a1279710-5ece-49d9-8c7a-62466e6bb297" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;override&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ReadJson(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonReader&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; reader, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Type&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; objectType, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; existingValue, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonSerializer&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; serializer)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Dictionary&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt; temp = serializer.Deserialize&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Dictionary&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt;&amp;gt;(reader);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dateTimeUTC = ((&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)temp[&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;DateTimeUTC&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;]).ToUniversalTime();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; offsetMinutes = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Convert&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.ToInt32(temp[&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;OffsetMinutes&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;]);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeOffset&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.SpecifyKind(dateTimeUTC, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeKind&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Unspecified),&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;TimeSpan&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.FromMinutes(offsetMinutes));&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;    &lt;p&gt;At this point, the client is all set. However, if we try to insert any instance of the Event class into an Azure Mobile Service, we’ll have an error at the runtime – the runtime doesn’t know how to insert &lt;em&gt;objects&lt;/em&gt; into the database, so we need to update the insert (and update and read) scripts to “tell” it what to do with those. The full explanation can be found in the &lt;a href="http://blogs.msdn.com/b/carlosfigueira/archive/2012/09/06/supporting-arbitrary-types-in-azure-mobile-services-managed-client-complex-types.aspx"&gt;post about supporting complex types in mobile services&lt;/a&gt;. The insert script would look similar to the one below – if the incoming item has a ‘Time’ property of type object, that (likely) means that our converter is the one supplying the values, so we know which fields to look for. And after the insertion is completed, we recreate the original object, which will then be read by the converter at the client.&lt;/p&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9f579be8-6237-4bd8-b4ff-bd6f7fd8a72f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 400px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; insert(item, user, request) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dto = item.Time;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;typeof&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dto === &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;object&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;delete&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item.Time;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;item.Time = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Date(dto.DateTimeUTC);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;item.Offset = dto.OffsetMinutes;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// Either null or old clients; assuming object, and setting offset to 0&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;item.Offset = 0;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;request.execute({&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;success: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; () {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// Need to recreate the object back&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dtoObject = { DateTimeUTC: item.Time, OffsetMinutes: item.Offset };&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;delete&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item.Offset;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;item.Time = dtoObject;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;request.respond();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;      &lt;p&gt;The update handler is exactly the same – break the object before the operation, recreate it afterwards:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:521a8f4b-32ba-43da-afdb-d4de19f8e8af" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 400px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; update(item, user, request) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dto = item.Time;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;typeof&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dto === &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;object&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;delete&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item.Time;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;item.Time = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Date(dto.DateTimeUTC);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;item.Offset = dto.OffsetMinutes;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// Either null or old clients; assuming object, and setting offset to 0&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;item.Offset = 0;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;request.execute({&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;success: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; () {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// Need to recreate the object back&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dtoObject = { DateTimeUTC: item.Time, OffsetMinutes: item.Offset };&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;delete&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item.Offset;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;item.Time = dtoObject;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;request.respond();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Finally, for reading we need, for all objects to be returned, to reassemble the object from the two columns in the database, which can be easily implemented by ‘forEach’-ing the results as shown below.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fc09bc5c-b235-4672-8059-58d79600ac9d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; read(query, user, request) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;request.execute({&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;success: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (results) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;results.forEach(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (item) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; dtoObject = { DateTimeUTC: item.Time, OffsetMinutes: item.Offset };&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;delete&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item.Offset;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;item.Time = dtoObject;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;request.respond();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;That’s it. We don’t need to update the delete script since it is based on the object id.&lt;/p&gt;  &lt;p&gt;This post is almost an update to the &lt;a href="http://blogs.msdn.com/b/carlosfigueira/archive/2012/09/06/supporting-arbitrary-types-in-azure-mobile-services-managed-client-complex-types.aspx"&gt;post about supporting complex types in mobile services&lt;/a&gt; using the new client API (based on JSON.NET), and hopefully it has shown that although some times the “impedance mismatch” between the runtime and the various client SDKs can cause problems, the Azure Mobile Services platform is extensible enough that we can, without a huge amount of code, work around the issues caused by the framework differences.&lt;/p&gt;  &lt;p&gt;And as usual, please raise any concerns and suggestions in our &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/azuremobile/threads"&gt;MSDN forums&lt;/a&gt; or in the comments for those blogs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10418245" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Extensibility/">Extensibility</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Service/">Mobile Service</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/WAMS/">WAMS</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Services+SDK/">Mobile Services SDK</category></item><item><title>Large numbers and Azure Mobile Services</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2013/04/22/large-numbers-and-azure-mobile-services.aspx</link><pubDate>Mon, 22 Apr 2013 08:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10410190</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10410190</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10410190</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2013/04/22/large-numbers-and-azure-mobile-services.aspx#comments</comments><description>&lt;p&gt;In any distributed system with different runtime environments, the way that data is represented in all nodes of the system, and transferred between them, can cause some problems if there is a mismatch between the nodes. In Azure Mobile Services we often have this issue - the server runtime runs on a JavaScript (or more precisely, node.js) engine, while the client can run in many different platforms (CLR managed code, Objective-C, Java, JavaScript, or any other client using the REST interface). With JavaScript - the mobile service runtime - there are two data types which usually cause problems: dates and numbers. Let's look at them in this post. &lt;/p&gt;  &lt;p&gt;Dates problems aren't common to JavaScript - dealing with conversions between local time (what people would most like to see in their applications) and standard time (usually UTC, how we'd store data) has been a problem in many frameworks, including .NET, and many smart people have &lt;a href="http://noda-time.blogspot.com/2011/08/what-wrong-with-datetime-anyway.html"&gt;written about it&lt;/a&gt;. Besides the framework-specific issues with dates, the main problem with the fact that Azure Mobile Services as a distributed system uses JavaScript in the backend is that dates in JS are represented as the number of &lt;em&gt;milliseconds&lt;/em&gt; from the Unix zero date (1970-01-01T00:00:00.000 UTC) is that dates with sub-millisecond precision are truncated, which is rarely a big problem.&lt;/p&gt;  &lt;p&gt;Numbers, on the other hand, tend to cause some problem with heterogeneous systems with JavaScript in one side and another language on another. In JS, all numbers are represented as &lt;a href="http://en.wikipedia.org/wiki/Binary64"&gt;64-bit (double precision) floating point values&lt;/a&gt;. In the managed world, that means that every number would be represented as a Double. But in the managed (or other languages with strong typing), other numeric types exist and are often used (with good reason) in defining the data types used by the application. Integers (usually 32 and 64 bits, but also in other sizes), single and double precision floating point numbers and fixed-point (with fixed or arbitrary precision) numbers are represented by a large variety of types in different languages. That means that there are many numbers which cannot be represented, without loss of precision, in JavaScript, so any time one of those numbers is sent from the client to the service (e.g., as part of an object being inserted into the database), when it’s sent back to the client, its value will be different. For example, any odd numbers beyond 2^53 cannot be represented as a 64-bit floating point value.&lt;/p&gt;  &lt;p&gt;So what do the client SDKs for Azure Mobile Services do when facing with numbers which can potentially be corrupted by going to the server? The answer depends on the how the application is interacting with the SDK, or more specifically, the data types which are being stored into / retrieved from the backend service. In many languages, there are two possible ways for an application save data, so let’s look at how the SDK deals with numbers on those two separately.&lt;/p&gt;  &lt;h3&gt;Typed mode&lt;/h3&gt;  &lt;p&gt;In the typed mode, we use “regular”, user-defined data types (e.g., User, Product, Order, TodoItem, etc.), and the SDK handles the serialization / deserialization of those types into / from the format used in the wire (JSON). The clients for managed platforms (Windows Store, Windows Phone, Desktop .NET 4.5) and Android both have this mode. JavaScript-based clients (where there really are no user-defined data types – and I’m not going here into the argument of prototypes versus real object-orientation) doesn’t have this mode (and it really doesn’t matter for this specific post, since there’s no difference in number representation between the JavaScript on the client and on the server). The iOS client SDK also doesn’t have it, since there’s no widely-used, generic serialization mechanism to translate between Objective-C @interfaces and JSON.&lt;/p&gt;  &lt;p&gt;In the typed mode, the SDK does a lot of data manipulation under the covers, so it was coded in a way that, if data loss were to happen, an exception is thrown to the user. The idea is that the developer is trusting the SDK with its data, and we don’t want to corrupt it without warning the user. Let’s take the code below. &lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5052988d-48f1-454c-8480-ef5efc386325" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;sealed&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;partial&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MainPage&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; : &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Page&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;static&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MobileServiceClient&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; MobileService = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MobileServiceClient&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;https://YOUR_SERVICE_HERE.azure-mobile.net/&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;YOUR_APPLICATION_KEY_HERE&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; MainPage()&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.InitializeComponent();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;async&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; btnStart_Click_1(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; sender, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; e)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;try&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table = MobileService.GetTable&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Test&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt;();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Test&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Test&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { Str = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, Value = (1L &amp;lt;&amp;lt; 53) + 1 };&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table.InsertAsync(item);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Inserted: {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, item);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;catch&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Exception&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ex)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Error: {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, ex);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; text, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;params&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;[] args)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (args != &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;null&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &amp;amp;&amp;amp; args.Length &amp;gt; 0) text = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Format(text, args);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.txtDebug.Text = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.txtDebug.Text + text + &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Environment&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.NewLine;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Test&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Id { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Str { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;long&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Value { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;override&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ToString()&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Format(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Id={0},Str={1},Value={2}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, Id, Str, Value);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;When the btnStart_Click_1 handler is invoked, the code tries to insert a typed item (Test) into a table with a long value which would be corrupted if the operation were to complete. Instead, the code throws the following exception&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.InvalidOperationException: The value 9007199254740993 for member Value is outside the valid range for numeric columns.&lt;/p&gt;  &lt;p&gt;The validation ensures that integers have to fall in the range [-2^53, +2^53]; numbers outside that range are rejected, and the exception is thrown.&lt;/p&gt;  &lt;p&gt;Now, what if you really want to use numbers beyond the allowed range? There are a few possibilities. In the .NET-based SDKs, you can actually remove the validation, which is made by a JSON.NET converter, by using a code similar to the one below. Notice that this will cause data corruption, but if precision can be sacrificed for a wider range of numbers, then that’s an option.&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3dd6e342-8ee1-44f0-8632-c530e49d8464" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; settings = MobileService.SerializerSettings;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; mspcc = settings.Converters.Where(c =&amp;gt; c &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;is&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MobileServicePrecisionCheckConverter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).FirstOrDefault();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (mspcc != &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;null&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;settings.Converters.Remove(mspcc);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table = MobileService.GetTable&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Test&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt;();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Test&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Test&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { Str = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, Value = (1L &amp;lt;&amp;lt; 53) + 1 };&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table.InsertAsync(item);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Inserted: {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, item);&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Another alternative is to change the data type for the value. Double is represented exactly like numbers in the server, so all numbers that can be represented in the client can be transferred to the server and back. But double values may lose precision as the numbers grow big as well.&lt;/p&gt;  &lt;p&gt;Yet another alternative is to use strings instead of numbers. With strings you can actually have arbitrary precision, but you may lose the ability to do relational queries on the data (unless you use some sort of zero-left-padding to normalize the values), and they take up more storage on the server.&lt;/p&gt;  &lt;p&gt;The main take away is that if you’re dealing with large numbers and user-defined types, there will be cases where those numbers won’t be able to be represented in the server. The client SDK will try its best to warn the user (via exceptions) that a data loss would occur, but there are alternatives if the application really requires large numbers to be stored. &lt;/p&gt;  &lt;h3&gt;Untyped mode&lt;/h3&gt;  &lt;p&gt;The second way for an application to exchange data with the service is via an “untyped” model, where instead of dealing with “user types”, the application works with simpler types (dictionaries, arrays, primitives) which map directly to JSON. The untyped model appears in different ways in different platforms:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;for the SDKs based on the managed code, they’re represented by types in the &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/N_Newtonsoft_Json_Linq.htm"&gt;Newtonsoft.Linq.Json namespace&lt;/a&gt; from &lt;a href="http://json.net"&gt;JSON.NET&lt;/a&gt;, the JSON serializer used by the managed clients (in the original client SDK for Windows Store / managed languages the types were from the &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/br240639.aspx"&gt;Windows.Data.Json namespace&lt;/a&gt;, but in &lt;a href="http://blogs.msdn.com/b/carlosfigueira/archive/2013/03/14/azure-mobile-services-managed-client-upcoming-breaking-changes.aspx"&gt;the latest portable library-based SDK, which will replace the original one, it was replaced with JSON.NET&lt;/a&gt;)&lt;/li&gt;    &lt;li&gt;for JavaScript clients (both Windows Store and “plain” HTML), they’re represented by JavaScript arrays, objects and primitives (strings, Boolean, numbers and dates)&lt;/li&gt;    &lt;li&gt;for the Android client they’re represented by the &lt;a href="http://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/JsonElement.html"&gt;JsonElement class&lt;/a&gt; (and its subclasses) on the &lt;a href="http://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/package-summary.html"&gt;com.google.gson package&lt;/a&gt;.&lt;/li&gt;    &lt;li&gt;on the iOS client they’re represented by the following classes: &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsdictionary_Class/Reference/Reference.html"&gt;NSDictionary&lt;/a&gt; (maps to JSON objects), &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsarray_Class/Reference/Reference.html"&gt;NSArray&lt;/a&gt; (maps to JSON arrays), &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsnull_Class/Reference/Reference.html"&gt;NSNull&lt;/a&gt; (maps to the JSON null value), &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsstring_Class/Reference/Reference.html"&gt;NSString&lt;/a&gt; (maps to JSON strings), &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsnumber_Class/Reference/Reference.html"&gt;NSNumber&lt;/a&gt; (maps to JSON Boolean or numbers, depending on its value) and &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsdate_Class/Reference/Reference.html"&gt;NSDate&lt;/a&gt; (maps to JSON strings, with a format which is recognized in the server as a date object)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Unlike on the typed mode, where there is a step which is taken to convert the object into the JSON-like structure which is sent to the server, this step is unnecessary in the untyped mode. Therefore, we had to make a choice: validate that the numbers could be faithfully represented in the server and return an error (such as returning exceptions or the appropriate error callback), and incur the penalty of the additional validation for a scenario which isn’t too common; or bypass the validation, and let the user (in the scenarios where it’s applicable) deal with the large numbers themselves. After some internal discussion, we made the second choice (I don’t think there’s really a right or wrong approach, just some decision that had to be made – but if you disagree, you can always send a suggestion in our &lt;a href="https://mobileservices.uservoice.com/forums/182281-feature-requests"&gt;UserVoice page&lt;/a&gt; and we can consider it for the updates to the client SDKs).&lt;/p&gt;  &lt;p&gt;What that decision entails is that if you try to run the following code, you’ll not get any error:&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:82456ff2-3ec3-46b8-bbe5-d20ce82d330d" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JObject&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JObject&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;item.Add(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Str&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;item.Add(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Value&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, 1234567890123456789L);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table = MobileService.GetTable(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; inserted = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table.InsertAsync(item);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Original: {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, item);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Inserted: {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, inserted);&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;What will happen instead is that the output will be shown as follows:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Consolas"&gt;Original: {       &lt;br /&gt;&amp;#160; &amp;quot;Str&amp;quot;: &amp;quot;hello&amp;quot;,        &lt;br /&gt;&amp;#160; &amp;quot;Value&amp;quot;: 1234567890123456789        &lt;br /&gt; }        &lt;br /&gt; Inserted: {        &lt;br /&gt;&amp;#160; &amp;quot;Str&amp;quot;: &amp;quot;hello&amp;quot;,        &lt;br /&gt;&amp;#160; &amp;quot;Value&amp;quot;: 1234567890123456800,        &lt;br /&gt;&amp;#160; &amp;quot;id&amp;quot;: 36        &lt;br /&gt; }&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Similarly, this Objective-C code shows the same result&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Consolas"&gt;- (&lt;font color="#ff0080"&gt;IBAction&lt;/font&gt;)clickMe:(&lt;font color="#ff0080"&gt;id&lt;/font&gt;)sender {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color="#008000"&gt;MSTable&lt;/font&gt; *table = [client &lt;font color="#008000"&gt;tableWithName&lt;/font&gt;:@&lt;font color="#ff0000"&gt;&amp;quot;Test&amp;quot;&lt;/font&gt;];        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color="#800040"&gt;NSDictionary&lt;/font&gt; *item = &lt;font color="#0000ff"&gt;@{&lt;/font&gt;&lt;font color="#ff0000"&gt;@&amp;quot;Str&amp;quot;&lt;/font&gt; : &lt;font color="#ff0000"&gt;@&amp;quot;Hello&amp;quot;&lt;/font&gt;, &lt;font color="#ff0000"&gt;@&amp;quot;Value&amp;quot;&lt;/font&gt; : &lt;font color="#0000ff"&gt;@(1234567890123456789L)}&lt;/font&gt;;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [table &lt;font color="#008000"&gt;insert&lt;/font&gt;:item &lt;font color="#008000"&gt;completion&lt;/font&gt;:^(&lt;font color="#800040"&gt;NSDictionary&lt;/font&gt; *inserted, &lt;font color="#800040"&gt;NSError&lt;/font&gt; *error) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color="#800080"&gt;NSLog&lt;/font&gt;(&lt;font color="#ff0000"&gt;@&amp;quot;Original: %@&amp;quot;&lt;/font&gt;, item);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color="#800080"&gt;NSLog&lt;/font&gt;(&lt;font color="#ff0000"&gt;@&amp;quot;Inserted: %@&amp;quot;&lt;/font&gt;, inserted);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }];        &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;And the logs:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Consolas"&gt;2013-04-10 13:36:18.009 MyApp[9289:c07] Original: {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Str = Hello;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Value = 1234567890123456789;        &lt;br /&gt; }        &lt;br /&gt; 2013-04-10 13:36:18.009 MyApp[9289:c07] Inserted: {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Str = Hello;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Value = 1234567890123456800;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; id = 58;        &lt;br /&gt; }&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Now, what if we actually want to enforce the limit checks on untyped operations? One simple alternative is to, prior to making the CRUD call, to traverse the object to see if it contains a long value which cannot be represented at the server side. Another alternative is to add a message handler (on the managed clients) or a filter (on the other platforms) which will look at the outgoing JSON request and fail if it has some numbers which can cause trouble if sent to the server side. This is one simple implementation of the validation for the managed client:&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1fb3d636-de64-4670-a179-26b1951379a7" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;      &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;bool&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; WillRoundTripWithNoDataLoss(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JToken&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;      &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (item == &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;null&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;) &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;          &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;switch&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (item.Type)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;              &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;case&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JTokenType&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Array:&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JArray&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ja = (&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JArray&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)item;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ja.All(jt =&amp;gt; WillRoundTripWithNoDataLoss(jt));&lt;/span&gt;&lt;/li&gt; &lt;li&gt;              &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;case&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JTokenType&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Object:&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JObject&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; jo = (&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JObject&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)item;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; jo.PropertyValues().All(jt =&amp;gt; WillRoundTripWithNoDataLoss(jt));&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;              &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;case&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JTokenType&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Boolean:&lt;/span&gt;&lt;/li&gt; &lt;li&gt;              &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;case&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JTokenType&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Float:&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;                &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;case&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JTokenType&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Null:&lt;/span&gt;&lt;/li&gt; &lt;li&gt;              &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;case&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JTokenType&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.String:&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;              &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;case&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JTokenType&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Integer:&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JValue&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; jv = (&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JValue&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)item;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;long&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; value = jv.Value&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;long&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt;();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;long&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; maxAllowedValue = 0x0020000000000000;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;long&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; minAllowedValue = 0;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;unchecked&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                      &lt;span style="background:#ffffff;color:#000000"&gt;minAllowedValue = (&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;long&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)0xFFE0000000000000;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; minAllowedValue &amp;lt;= value &amp;amp;&amp;amp; value &amp;lt;= maxAllowedValue;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;              &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;default&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;:&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                  &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;throw&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ArgumentException&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Validation for type &amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + item.Type + &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot; not yet implemented&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;          &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;In summary, it’s possible that you’ll never need to worry about this “impedance mismatch” between the client and the server for large numbers, and all values will just work. But it’s always nice to go into a framework knowing some of its pitfalls, and this one is in my opinion one which could be hard to identify.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10410190" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Service/">Mobile Service</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/SDK/">SDK</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Services/">Mobile Services</category></item><item><title>Updates (some API changes) to the Azure Mobile Services iOS SDK</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2013/04/10/updates-some-api-changes-to-the-azure-mobile-services-ios-sdk.aspx</link><pubDate>Wed, 10 Apr 2013 21:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10410176</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10410176</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10410176</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2013/04/10/updates-some-api-changes-to-the-azure-mobile-services-ios-sdk.aspx#comments</comments><description>&lt;p&gt;Another quick one today. After some feedback from the community, we released a new version of the Azure Mobile Services iOS SDK which contains, in addition to a few bug fixes, some changes in the method names of some of the classes. Those changes were made to make the iOS SDK more in sync with the design and naming guidelines for other iOS libraries. The new SDK is live, and the Quickstart app which can be downloaded from the Azure Portal is also using the new APIs as well. Finally, our tutorials have also been updated to reflect the naming changes.&lt;/p&gt;  &lt;p&gt;The changes are listed below. You can also find the changes to the SDK in our public GitHub repository. The changes were made in &lt;a href="https://github.com/WindowsAzure/azure-mobile-services/commit/ff817969472533d667d962fba2722e75d3ca99c8#sdk/iOS"&gt;this commit&lt;/a&gt;.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;MSClient interface      &lt;ul&gt;       &lt;li&gt;Class method &lt;font face="Consolas"&gt;clientWithApplicationURLString:&lt;strong&gt;withApplicationKey&lt;/strong&gt;:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;clientWithApplicationURLString:&lt;strong&gt;applicationKey&lt;/strong&gt;:&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;Class method &lt;font face="Consolas"&gt;clientWithApplicationURL:&lt;strong&gt;withApplicationKey&lt;/strong&gt;:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;clientWithApplicationURL:&lt;strong&gt;applicationKey&lt;/strong&gt;:&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;Initializer &lt;font face="Consolas"&gt;initWithApplicationURL:&lt;strong&gt;withApplicationKey&lt;/strong&gt;&lt;/font&gt;: ==&amp;gt; &lt;font face="Consolas"&gt;initWithApplicationURL:&lt;strong&gt;applicationKey&lt;/strong&gt;:&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;Instance method &lt;font face="Consolas"&gt;loginWithProvider:&lt;strong&gt;onController&lt;/strong&gt;:animated:completion:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;loginWithProvider:&lt;strong&gt;controller&lt;/strong&gt;:animated:completion:&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;Instance method &lt;font face="Consolas"&gt;loginWithProvider:&lt;strong&gt;withToken&lt;/strong&gt;:completion:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;loginWithProvider:&lt;strong&gt;token&lt;/strong&gt;:completion:&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;Instance method &lt;font face="Consolas"&gt;&lt;strong&gt;getTable&lt;/strong&gt;:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;&lt;strong&gt;tableWithName&lt;/strong&gt;:&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;Instance method &lt;font face="Consolas"&gt;&lt;strong&gt;clientwithFilter&lt;/strong&gt;:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;&lt;strong&gt;clientWithFilter&lt;/strong&gt;:&lt;/font&gt; (capitalization of the ‘W’)&lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;MSClientConnection interface (mostly internal usage)      &lt;ul&gt;       &lt;li&gt;Initializer &lt;font face="Consolas"&gt;initWithRequest:&lt;strong&gt;withClient&lt;/strong&gt;:completion:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;initWithRequest:&lt;strong&gt;client&lt;/strong&gt;:completion:&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;MSFilter protocol      &lt;ul&gt;       &lt;li&gt;Method &lt;font face="Consolas"&gt;handleRequest:&lt;strong&gt;onNext&lt;/strong&gt;:&lt;strong&gt;onResponse&lt;/strong&gt;:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;handleRequest:&lt;strong&gt;next&lt;/strong&gt;:&lt;strong&gt;response&lt;/strong&gt;:&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;MSLogin interface (mostly internal usage)      &lt;ul&gt;       &lt;li&gt;Instance method &lt;font face="Consolas"&gt;loginWithProvider:&lt;strong&gt;onController&lt;/strong&gt;:animated:completion:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;loginWithProvider:&lt;strong&gt;controller&lt;/strong&gt;:animated:completion:&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;Instance method &lt;font face="Consolas"&gt;loginWithProvider:&lt;strong&gt;withToken&lt;/strong&gt;:completion:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;loginWithProvider:&lt;strong&gt;token&lt;/strong&gt;:completion:&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;MSQuery interface      &lt;ul&gt;       &lt;li&gt;Instance method &lt;font face="Consolas"&gt;initWithTable:&lt;strong&gt;withPredicate&lt;/strong&gt;:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;initWithTable:&lt;strong&gt;predicate&lt;/strong&gt;:&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;MSTable interface      &lt;ul&gt;       &lt;li&gt;Initializer &lt;font face="Consolas"&gt;initWithName:&lt;strong&gt;andClient&lt;/strong&gt;:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;initWithName:&lt;strong&gt;client&lt;/strong&gt;:&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;Instance method &lt;font face="Consolas"&gt;&lt;strong&gt;readWhere&lt;/strong&gt;:completion:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;&lt;strong&gt;readWithPredicate&lt;/strong&gt;:completion:&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;Instance method &lt;font face="Consolas"&gt;&lt;strong&gt;queryWhere&lt;/strong&gt;:&lt;/font&gt; ==&amp;gt; &lt;font face="Consolas"&gt;&lt;strong&gt;queryWithPredicate&lt;/strong&gt;:&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;That’s it. As usual, please let us know if you have any suggestions / comments / question either by using our &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/azuremobile/threads"&gt;MSDN forum&lt;/a&gt; or our &lt;a href="https://mobileservices.uservoice.com/forums/182281-feature-requests"&gt;UserVoice page&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10410176" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Service/">Mobile Service</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/iOS/">iOS</category></item><item><title>Azure Mobile Services Windows Store / JavaScript SDK – now also from NuGet</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2013/04/09/azure-mobile-services-windows-store-javascript-sdk-now-also-from-nuget.aspx</link><pubDate>Mon, 08 Apr 2013 23:39:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10409511</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10409511</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10409511</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2013/04/09/azure-mobile-services-windows-store-javascript-sdk-now-also-from-nuget.aspx#comments</comments><description>&lt;p&gt;Quick post today. &lt;a href="http://blogs.msdn.com/b/carlosfigueira/archive/2013/03/09/azure-mobile-services-managed-client-now-also-from-nuget.aspx"&gt;About a month ago&lt;/a&gt; we released a &lt;a href="http://nuget.org/"&gt;NuGet&lt;/a&gt; version of the managed client SDK. Last week we released the SDK for Windows Store applications / JavaScript also on NuGet, so you can develop applications using that platform without needing any installation (MSI). Building Windows Store / JavaScript applications with the NuGet package is almost the same as building with the current, MSI-based SDK. After creating a new project, right-click the project and select the “Manage NuGet Packages…” option.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3632.ManageNugetPackages_5F00_2921AD3C.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ManageNugetPackages" border="0" alt="ManageNugetPackages" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6864.ManageNugetPackages_5F00_thumb_5F00_5B194DC6.png" width="324" height="168" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;On the search window, type “mobileservices.winjs”, and that will show the NuGet package for the Windows Store / JS. The current “stable” version (0.2.0) is exactly the same one as the one which is on the current MSI-based SDK. We also have one version (0.3.0-alpha) which is a preview of the next version. It’s similar to the 0.2.0, with some bug fixes. It will appear if you select the “include prerelease” option as shown below; after a few weeks of testing we’ll mark that package “stable”). Select the package and click “Install”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/7444.PackageName_5F00_4FEFC37C.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="PackageName" border="0" alt="PackageName" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/1172.PackageName_5F00_thumb_5F00_1AE3344C.png" width="539" height="272" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s it. On the version 0.2.0, one file will be added to your project: MobileServices.js; on the next version, two files will be added to your project: MobileServices.js and MobileServices.pri – the first being the code for the SDK itself, and the second one is a compiled file containing the resources for the library (basically, exception strings). To use the library, open the file “default.html”, then click and drag the file “MobileServices.js” into the list of app references. That’s very similar to what was done with the MSI-based SDK, but the file was dragged from the references folder.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/2642.DragReference_5F00_41B14A8C.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="DragReference" border="0" alt="DragReference" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3731.DragReference_5F00_thumb_5F00_3A920E14.png" width="539" height="386" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And that’s it. As always, please let us know if you have any comments / suggestions on the new features which we’re shipping.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10409511" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Service/">Mobile Service</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/WAMS/">WAMS</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/NuGet/">NuGet</category></item><item><title>Azure Mobile Services managed client – portable libraries and breaking changes</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2013/03/14/azure-mobile-services-managed-client-upcoming-breaking-changes.aspx</link><pubDate>Thu, 14 Mar 2013 00:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10402163</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10402163</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10402163</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2013/03/14/azure-mobile-services-managed-client-upcoming-breaking-changes.aspx#comments</comments><description>&lt;p&gt;Among the requested features in the various forums for Azure Mobile Services, the usage of &lt;a href="http://mobileservices.uservoice.com/forums/182281-feature-requests/suggestions/3369783-portable-class-library-targeting-winphone-winrt-a"&gt;portable libraries&lt;/a&gt; has &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/azuremobile/thread/e7bcd0bf-2de2-4404-91a1-05d7259a1def"&gt;popped&lt;/a&gt; up &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/azuremobile/thread/b84546cb-e2cf-4366-96a8-083d4914bd14"&gt;quite&lt;/a&gt; often. We now have that support, which unifies the managed clients for the Windows Store and Windows Phone 8 platforms &amp;ndash; and we&amp;rsquo;re also adding support for Windows Phone 7.5 as well. &lt;a href="https://twitter.com/jplaanstra"&gt;Johan Laanstra&lt;/a&gt; wrote a &lt;a href="http://www.johanlaanstra.nl/?p=217"&gt;great post&lt;/a&gt; explaining the architecture of the new packages, so I won&amp;rsquo;t repeat what he wrote.&lt;/p&gt;
&lt;p&gt;However, since there were some differences between the Windows Phone 8 and the Windows Store SDKs, unifying them meant some breaking changes. We felt that the grief we&amp;rsquo;ll take for them is worth, given the gains we can get by the platform unification, and we also used this opportunity to make some other changes to the client SDK to make it more polished before the general availability of the service. This post will try to list to the best of my knowledge the changes which will need to be addressed for apps using the new client. Notice that we&amp;rsquo;ll still support the &amp;ldquo;non-portable&amp;rdquo; clients for some more time, but it will be discontinued likely before the Azure Mobile Services goes out of preview mode and into a general availability,&lt;/p&gt;
&lt;h2&gt;Breaking changes / functionality changes&lt;/h2&gt;
&lt;p&gt;This is the grouped list of changes, along with the updates one needs to make to their projects to account for them.&lt;/p&gt;
&lt;h3&gt;Serialization changes&lt;/h3&gt;
&lt;p&gt;This is the place where the majority of the changes were made. For the Windows Store SDK, conversion between the typed objects and the JSON which was actually transferred over the wire was done via a custom serializer which converted between the two formats. The serializer was fairly simple, and could only deal with simple types (numbers, strings, dates and,Boolean values). To support more complex types (unsupported primitives, arrays, complex objects), we&amp;rsquo;d need to provide a custom implementation of the IDataMemberJsonCoverter interface, and decorate the appropriate member with the [DataMemberJsonConverter] attribute. Even simple things such as enumerations were not supported. With this new client, all the custom serialization code goes away, as we&amp;rsquo;ll be using the &lt;a href="http://json.net"&gt;JSON.NET&lt;/a&gt; serializer, and by that move we gain all of the support of that great serializer. That means that complex types, arrays, enumerations will just work. The new client also exposes the &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonSerializerSettings.htm"&gt;serializer settings&lt;/a&gt; which allow the developer to fine-tune the output data, including adding custom converters and changing policies such as default value serialization.&lt;/p&gt;
&lt;p&gt;Now for the list of changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;JSON.NET&lt;/strong&gt;: that&amp;rsquo;s the serializer used for all platforms (not only for Windows Phone 8 as before). That causes the following behavioral changes from the current Windows Store SDK&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;strong&gt;JSON bool values cannot be parsed as integers&lt;/strong&gt;; false was interpreted as 0, and true as 1; now an exception will be thrown&lt;/span&gt;. &lt;em&gt;This has since been modified to preserve the original behavior&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Better / consistent exception messages for failed JSON parsing&lt;/strong&gt;: there was a lot of code in the custom serializer for dealing with bad data; now this is all taken care of by JSON.NET, and its exception messages include more data such as the path in the JSON document, and position of the error&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;All floating point members (even those with integer values) will be serialized with a decimal point&lt;/strong&gt;: a JSON.NET behavior. Before a float / double with value 2 would be serialized as {&amp;ldquo;number&amp;rdquo;:2}; now it will be serialized as {&amp;ldquo;number&amp;rdquo;:2.0}.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;To maintain the previous behavior, one possibility is to use a custom &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonConverter.htm"&gt;JsonConverter&lt;/a&gt; class that first casts the values to integers if they are indeed integers.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;strong&gt;Float (System.Single) will be serialized with its &amp;ldquo;native&amp;rdquo; precision&lt;/strong&gt;: before a member of type float (Single) would be serialized as if it had double precision. For example, the object &lt;span style="font-family: Consolas;"&gt;new MyType { fltValue = float.MinValue }&lt;/span&gt; would be serialized as {&amp;ldquo;fltValue&amp;rdquo;:1.4012984643248171E-45}; now it will be serialized as {"fltValue":1.401298E-45}.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;To maintain the previous behavior, use a &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonConverter.htm"&gt;JsonConverter&lt;/a&gt; class that serializes float values as doubles (or change the property type to double)&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;strong&gt;Float and double values less than their respective Epsilon now deserialize as 0.0&lt;/strong&gt;: before it used to throw an exception. Now deserializing something like {&amp;ldquo;dblValue:1.23E-1000} will cause the dblValue member to be set to zero, instead of an exception being thrown.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fields are now serialized before properties&lt;/strong&gt;: before properties were serialized before fields; now is the opposite. Since JSON objects are supposed to be unordered sets of members, this shouldn&amp;rsquo;t affect existing apps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Finer control of serialization via settings&lt;/strong&gt;: the MobileServiceClient now exposes the &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonSerializerSettings.htm"&gt;JsonSerializerSettings&lt;/a&gt; object which is used by the JSON.NET serializer, so you can now have greater control of the serialization.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Miscellaneous bugs fixed&lt;/strong&gt;:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Tab / newline characters can now be deserialized (before it would result in an exception)&lt;/li&gt;
&lt;li&gt;Integer values can now be deserialized to members of type char.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;strong&gt;Miscellaneous scenarios which are now supported&lt;/strong&gt;:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Uri / TimeSpan members don&amp;rsquo;t need a special converter anymore: they&amp;rsquo;re serialized as JSON strings&lt;/li&gt;
&lt;li&gt;Arrays / objects also now just work. They&amp;rsquo;re serialized as JSON array / object respectively. Notice that the server runtime still needs to process that value, since they cannot be inserted into the database directly.&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;li&gt;Non JSON.NET specific changes:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Enumeration support&lt;/strong&gt;: it was enabled by the move to JSON.NET, but our code now serializes the string value of the enumerations. Enums can also be used in &amp;lsquo;Where&amp;rsquo; clauses while querying data from the service.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Loss of precision handling&lt;/strong&gt;: the runtime for Azure Mobile Services is based on JavaScript (node.js), which only stores numbers in a double-precision floating representation. That means that there are some integer and decimal values which cannot be represented accurately. Basically, any long number less than 2^53 can be represented, without loss of precision, in the server, so those are serialized correctly; any values larger than that (or smaller than -2^53) will cause an exception to be thrown. Notice that this is the current behavior, although it was a little buggy in which it would report some numbers within the valid range as invalid as well. Decimal values can also lose precision, and now this validation (exception thrown if precision would be lost) is applied to them as well. If you want to bypass the validation, either change the data type of the properties to double, or remove the converter (MobileServicePrecisionCheckConverter) from the serializer settings.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;One minor breaking change: before the exception thrown for long values outside the non-precision-loss range was ArgumentOutOfRangeException; now the exception type is InvalidOperationException.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;strong&gt;IDataMemberJsonConverter, [DataMemberJsonConverter] removed&lt;/strong&gt;: now they either are not necessary anymore, or if you still want full control over the serialization of a property, you can use the &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonConverterAttribute.htm"&gt;[JsonConverterAttribute]&lt;/a&gt; applied to that property.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ICustomMobileTableSerialization removed&lt;/strong&gt;: if a type needs special serialization, decorate it with &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonConverterAttribute.htm"&gt;[JsonConverterAttribute]&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Only one member with name &amp;lsquo;id&amp;rsquo; &amp;ndash; regardless of casing &amp;ndash; can exist in a type being serialized&lt;/strong&gt;: before an object with members called &amp;ldquo;id&amp;rdquo;, &amp;ldquo;Id&amp;rdquo; and &amp;ldquo;ID&amp;rdquo; would be serialized to the server &amp;ndash; where it would fail, since only one id is allowed. Now it will throw during serialization.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;[DataMember] attributes in members now require a [DataContract] attribute in the class&lt;/strong&gt;: the contract of [DataMember] for serialization is tied with [DataContract], but we had a bug in which data members were being honored even if the containing class itself didn&amp;rsquo;t opt in to the data contract model (by using the [DataContract] attribute). Now if the SDK finds such a scenario it will throw an exception to signal that this is not a valid scenario. The typical scenario for using [DataMember] would be to change the serialized name of the member; now it can be accomplished via the &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/T_Newtonsoft_Json_JsonPropertyAttribute.htm"&gt;[JsonPropertyAttribute]&lt;/a&gt; instead.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The [&lt;/strong&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.mobileservices.datatableattribute.aspx"&gt;&lt;strong&gt;DataTableAttribute&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;] now takes the table name in the constructor&lt;/strong&gt;: before: [DataTable(Name = &amp;ldquo;MyTable&amp;rdquo;)]; after:: [DataTable(&amp;ldquo;MyTable&amp;rdquo;)]&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;If I remember more or if you find one which is not listed here, please add a comment and I&amp;rsquo;ll update this post.&lt;/p&gt;
&lt;h3&gt;Operations with untyped (i.e., JSON) data&lt;/h3&gt;
&lt;p&gt;When performing &lt;a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete"&gt;CRUD&lt;/a&gt; operations in a managed client, usually we&amp;rsquo;d create a data type to store our information (e.g., Person, Order, etc.) and pass them to the Insert/Read/Update/Delete operations. We could also work directly with JSON data, and the table would support those as well. In the Windows Store client the SDK used the classes in the &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/br229889.aspx"&gt;Windows.Data.Json&lt;/a&gt; namespace, native to the WinRT platform. However, those classes were not present in the Windows Phone 8, so that SDK was already using the JSON.NET classes from the &lt;a href="http://james.newtonking.com/projects/json/help/?topic=html/N_Newtonsoft_Json_Linq.htm"&gt;Newtonsoft.Json.Linq namespace&lt;/a&gt; (&lt;a href="http://james.newtonking.com/projects/json/help/html/T_Newtonsoft_Json_Linq_JToken.htm"&gt;JToken&lt;/a&gt; / &lt;a href="http://james.newtonking.com/projects/json/help/html/T_Newtonsoft_Json_Linq_JArray.htm"&gt;JArray&lt;/a&gt; / &lt;a href="http://james.newtonking.com/projects/json/help/html/T_Newtonsoft_Json_Linq_JValue.htm"&gt;JValue&lt;/a&gt; / &lt;a href="http://james.newtonking.com/projects/json/help/html/T_Newtonsoft_Json_Linq_JObject.htm"&gt;JObject&lt;/a&gt;). To move to a common set of classes, now all managed libraries use the JSON.NET classes, including the Windows Store apps.&lt;/p&gt;
&lt;p&gt;And the list of changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;[Windows Store only] Windows.Data.Json &amp;ndash;&amp;gt; Newtonsoft.Json.Linq&lt;/strong&gt;: there&amp;rsquo;s an added advantage that the JSON.NET classes have an API which is way more user-friendly than the &amp;ldquo;dry&amp;rdquo; WinRT one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Insert / update operations do not change the input object (untyped data only)&lt;/strong&gt;: This is a behavioral change which was the outcome of a lengthy discussion within the team. Before, the insert / operations would mutate the JsonObject (or JObject) value which was passed to it, by &amp;ldquo;patching&amp;rdquo; it with whatever the server returned. The most common case was the &amp;ldquo;id&amp;rdquo; in insert operations, but the server scripts are were free to mutate the object, even changing the shape of the value returned by the client (i.e., in an insert operation, the service could receive an object and return an array, or a primitive value). Before that would mean that the client had no way to retrieve that value. Now, the object passed to InsertAsync (and UpdateAsync) is not mutated, and the return of the server operation is returned as a new object instead. Notice that for &lt;em&gt;typed&lt;/em&gt; operations (e.g., inserting / updating an Order object), the original object is still patched &lt;em&gt;in place&lt;/em&gt;.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;This may require some code changes. For example, the code below:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;var table = MobileService.GetTable(&amp;ldquo;Clients&amp;rdquo;);&lt;/li&gt;
&lt;li&gt;var obj = JsonObject.Parse("{\"name\":\"John Doe\",\"age\":33}");&lt;/li&gt;
&lt;li&gt;await table.InsertAsync(obj);&lt;/li&gt;
&lt;li&gt;var id = (int)obj["id"].GetNumber();&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Would need to be rewritten as (notice changes in &lt;em&gt;&lt;span style="color: #0000ff;"&gt;italics&lt;/span&gt;&lt;/em&gt;)&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;var table = MobileService.GetTable(&amp;ldquo;Clients&amp;rdquo;);&lt;/li&gt;
&lt;li&gt;var obj = &lt;em&gt;&lt;span style="color: #0000ff;"&gt;JObject&lt;/span&gt;&lt;/em&gt;.Parse("{\"name\":\"John Doe\",\"age\":33}");&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;span style="color: #0000ff;"&gt;var inserted&lt;/span&gt; = &lt;/em&gt;await table.InsertAsync(obj);&lt;/li&gt;
&lt;li&gt;var id = &lt;em&gt;&lt;span style="color: #0000ff;"&gt;inserted["id"].Value&amp;lt;int&amp;gt;()&lt;/span&gt;;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;Again, I&amp;rsquo;ll update the post if I can remember (or if you can add a comment) of any additional changes.&lt;/p&gt;
&lt;h3&gt;Service filters &amp;ndash;&amp;gt; HttpClient primitives&lt;/h3&gt;
&lt;p&gt;Service filters are an advanced concept which implement a pipeline over the request / response. There is already such a pipeline in the HttpClient libraries &amp;ndash; and since it has recently been made available for downlevel platforms (it originally only worked for .NET 4.5 and .NET 4.0) the Mobile Services SDK can now use this existing code instead of creating yet another pipeline.&lt;/p&gt;
&lt;p&gt;And the changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Goodbye IServiceFilter, hello DelegatingHandler&lt;/strong&gt;: this is a sample implementation of a service filter, and the equivalent implementation with a delegating handler. Notice that there&amp;rsquo;s no IAsyncOperation&amp;lt;T&amp;gt; anymore, so the code is cleaner. Below you can see an example of the before / after the change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Message handlers are passed to the MobileServiceClient constructor, not to a method (WithFilter)&lt;/strong&gt;: that method created a clone of the client, and applied the filters to it. That name caused some confusion among users, with many people thinking that it would modify the client. By moving it to a constructor the API now makes it clear.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here&amp;rsquo;s an example of a service filter converted to a message handler. The filter will add a custom header to the request, and change the response status code (useful for testing the behavior on unexpected responses from the server). First the service filter.&lt;/p&gt;
&lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0549c1bc-e266-4ada-8ad5-d9bac3caadb0" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #fff; max-height: 400px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;async&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Task&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; CallFilteredClient()&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;var&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; client = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;MobileServiceClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(appUrl, appKey).WithFilter(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;MyFilter&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;());&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;var&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; table = client.GetTable&amp;lt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Person&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;gt;();&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;var&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; p = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Person&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; { Name = &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"John Doe"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; };&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;await&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; table.InsertAsync(p);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;class&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;MyFilter&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; : &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IServiceFilter&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IAsyncOperation&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IServiceFilterResponse&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;gt; Handle(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IServiceFilterRequest&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; request, &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IServiceFilterContinuation&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; continuation)&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;request.Headers.Add(&lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"x-my-header"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"my value"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;);&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; continuation.Handle(request).AsTask().ContinueWith&amp;lt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IServiceFilterResponse&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;gt;(t =&amp;gt; {&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpStatusCode&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; newStatusCode = &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpStatusCode&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.ServiceUnavailable;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;var&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; response = t.Result;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;var&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; newResponse = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;MyResponse&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(response.Content, response.ContentType, response.Headers,&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;response.ResponseStatus, (&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;)newStatusCode, newStatusCode.ToString());&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; newResponse;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}).AsAsyncOperation();&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;class&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;MyResponse&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; : &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IServiceFilterResponse&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; content;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; contentType;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IDictionary&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;gt; headers;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceFilterResponseStatus&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; responseStatus;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; statusCode;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; statusDescription;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; MyResponse(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; content, &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; contentType, &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IDictionary&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;gt; headers,&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceFilterResponseStatus&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; responseStatus, &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; statusCode, &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; statusDescription)&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.content = content;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.contentType = contentType;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.headers = headers;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.responseStatus = responseStatus;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.statusCode = statusCode;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.statusDescription = statusDescription;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; Content&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;get&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; { &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.content; }&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; ContentType&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;get&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; { &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.contentType; }&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IDictionary&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;gt; Headers&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;get&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; { &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.headers; }&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceFilterResponseStatus&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; ResponseStatus&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;get&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; { &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.responseStatus; }&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; StatusCode&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;get&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; { &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.statusCode; }&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; StatusDescription&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;get&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; { &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;this&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.statusDescription; }&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;And the same code implemented with a delegating handler:&lt;/p&gt;
&lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4383ce7c-6fff-4ad5-9a8f-fff912cb6613" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #fff; max-height: 400px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;async&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Task&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; CallClientWithHandler()&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;var&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; client = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;MobileServiceClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(appUrl, appKey, &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;MyHandler&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;());&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;var&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; table = client.GetTable&amp;lt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Person&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;gt;();&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;var&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; p = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Person&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; { Name = &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"John Doe"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; };&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;await&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; table.InsertAsync(p);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;class&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;MyHandler&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; : &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;DelegatingHandler&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;protected&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;override&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;async&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Task&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpResponseMessage&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;gt; SendAsync(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpRequestMessage&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; request, &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;CancellationToken&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; cancellationToken)&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;request.Headers.Add(&lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"x-my-header"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"my value"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;);&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;var&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; response = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;await&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;base&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.SendAsync(request, cancellationToken);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;response.StatusCode = &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpStatusCode&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.ServiceUnavailable;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; response;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For more information on the HttpClient primitives, check the &lt;a href="http://blogs.msdn.com/b/bclteam/archive/2013/02/18/portable-httpclient-for-net-framework-and-windows-phone.aspx"&gt;blog post from the BCL team&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Miscellaneous changes&lt;/h3&gt;
&lt;p&gt;Those are the other minor changes in the library:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;MobileServiceClient.LoginInProgress has been removed&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MobileServiceClient.LoginAsync(string) has been removed&lt;/strong&gt;. This is now called LoginWithMicrosoftAccountAsync, which is added as an extension method to the class.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MobileServiceTable, MobileServiceTable&amp;lt;T&amp;gt; and MobileServiceTableQuery&amp;lt;T&amp;gt; are now internal classes&lt;/strong&gt;: all methods which used to return a table object now return the interface type IMobileServiceTable (untyped) or IMobileServiceTable&amp;lt;T&amp;gt; (typed). Typed queries are now exposed as the IMobileServiceTableQuery&amp;lt;T&amp;gt; interface.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MobileServiceTable.&amp;lt;T&amp;gt;ToCollectionView() is now ToCollection()&lt;/strong&gt;: the collection view implementation had some bugs, and it has been rewritten.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple Take operations now considers the minimum value&lt;/strong&gt;: before it would use the last value. The call table.Take(5).Take(3).Take(7).ToListAsync() would issue a request with $top=7; now it sends a request with $top=3.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple Skip operations now add the values&lt;/strong&gt;: before it would use the last value. The call table.Skip(3).Skip(5).Skip(4) would issue a request with $skip=4; now it sends a request with $skip=12.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That should be it. Please start using the new libraries and let us know what you think! We still have some (although not much) time to react to user feedback before we have to lock the API down as we move to the general release.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10402163" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Service/">Mobile Service</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category></item><item><title>Azure Mobile Services managed client – now also from NuGet</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2013/03/09/azure-mobile-services-managed-client-now-also-from-nuget.aspx</link><pubDate>Sat, 09 Mar 2013 00:10:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10400804</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10400804</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10400804</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2013/03/09/azure-mobile-services-managed-client-now-also-from-nuget.aspx#comments</comments><description>&lt;p&gt;Currently if you want to create a Windows Store application which uses Azure Mobile Services, the process would be to go to either the quickstart page of your application in the &lt;a href="https://manage.windowsazure.com"&gt;Azure Portal&lt;/a&gt; (or the &lt;a href="http://www.windowsazure.com/en-us/downloads/"&gt;Windows Azure downloads page&lt;/a&gt;) and install the Mobile Services SDK:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3858.InstallMobileServiceSDK_5F00_1D6A95BE.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="InstallMobileServiceSDK" border="0" alt="InstallMobileServiceSDK" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/4530.InstallMobileServiceSDK_5F00_thumb_5F00_2B3CDBB9.png" width="463" height="314" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After installing the SDK, you can then go to the Visual Studio project, and add a reference to the library, in the Windows Extensions tab:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/2476.AddReference_5F00_390F21B4.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="AddReference" border="0" alt="AddReference" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6518.AddReference_5F00_thumb_5F00_6B06C23E.png" width="476" height="228" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s simple, but we can make it simpler – and with the added bonus of avoiding the installation of code in your machine. &lt;a href="http://nuget.org/"&gt;NuGet&lt;/a&gt; is a Visual Studio extension (installed by default in VS 2012) that makes it easy to install and update libraries to Visual Studio project. To install the required references using NuGet:&lt;/p&gt;  &lt;p&gt;1. Select “Manage NuGet Packages” in the project&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3060.ManageNugetPackages_5F00_4AEBB581.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ManageNugetPackages" border="0" alt="ManageNugetPackages" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3377.ManageNugetPackages_5F00_thumb_5F00_0AB59C07.png" width="515" height="377" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;2. Search for “Windows Azure Mobile”, select the “Windows Azure Mobile Services” package, and click install&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/4848.SelectNuGetPackage_5F00_1C922FD4.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="SelectNuGetPackage" border="0" alt="SelectNuGetPackage" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/2705.SelectNuGetPackage_5F00_thumb_5F00_7C772316.png" width="527" height="353" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s it! NuGet downloads the necessary assemblies, and adds reference to it in the project. The package supports both Windows Store (managed) applications and Windows Phone 8 applications.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Quick caveat&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Just one quick note: to use the Windows Azure Mobile Services NuGet package, you need to have the latest (2.2). If you have an older version, you may see this error:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/1200.NuGetFailedNeedsUpdate_5F00_0A496912.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="NuGetFailedNeedsUpdate" border="0" alt="NuGetFailedNeedsUpdate" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6507.NuGetFailedNeedsUpdate_5F00_thumb_5F00_3C41099C.png" width="288" height="280" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you get this error, go to the “Extensions and Updates” option of the Tools menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6012.ExtensionsAndUpdates_5F00_1C25FCDF.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ExtensionsAndUpdates" border="0" alt="ExtensionsAndUpdates" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3858.ExtensionsAndUpdates_5F00_thumb_5F00_10FC7295.png" width="398" height="262" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And select the update for the NuGet Package Manager&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/1715.ExtensionsAndUpdates_2D00_2_5F00_70E165D7.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ExtensionsAndUpdates-2" border="0" alt="ExtensionsAndUpdates-2" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/8662.ExtensionsAndUpdates_2D00_2_5F00_thumb_5F00_3BD4D6A7.png" width="450" height="231" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After the update the package installation should work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10400804" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Service/">Mobile Service</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/NuGet/">NuGet</category></item><item><title>Enabling Single Sign-On for Windows 8 Azure Mobile Apps</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2013/02/05/enabling-single-sign-on-for-windows-8-azure-mobile-apps.aspx</link><pubDate>Tue, 05 Feb 2013 01:04:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10391050</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10391050</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10391050</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2013/02/05/enabling-single-sign-on-for-windows-8-azure-mobile-apps.aspx#comments</comments><description>&lt;p&gt;One of the common complaints about the authentication support in the Windows 8 SDK for Azure Mobile Services is that regardless of whether the user selects the “save password” / “remember me” checkbox when entering their credentials, every time the application starts and the user needs to authenticate, they have to enter their credentials all over again. Currently the only way to enable the single sign-on (SSO) for Win8 apps would be to use the Live SDK (or some native SDK from the other providers, such as Facebook or Google) and then only authenticate with Azure Mobile Services with the token received from that SDK.&lt;/p&gt;  &lt;p&gt;We recently released an update of the Azure Mobile Services client SDK for Windows 8 (along with an update to the service runtime), and this feature is now available. To enable single sign-on, we need to use a new overload to the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj872755.aspx"&gt;LoginAsync&lt;/a&gt; (or &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj554236.aspx"&gt;login&lt;/a&gt; from the JavaScript client), and we also need to set the package SID of the Windows 8 application from the store. Let’s see how I can change my application to use this new feature. This is my current app. It currently uses Facebook authentication (a simple app which gets data from the graph API about the logged in user), but if I were using the other three authentication providers the steps to enable SSO would be the same.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/5123.App_5F00_18F5EC9D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="App" border="0" alt="App" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3060.App_5F00_thumb_5F00_2AD2806A.png" width="512" height="286" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The code for the application (in one method) is the following:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c0d31dbe-d600-418c-b12a-518561217291" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;async&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; btnGetData_Click_1(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; sender, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; e)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;try&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; user = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; MobileService.LoginAsync(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MobileServiceAuthenticationProvider&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Facebook);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Logged in as {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, user.UserId);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table = MobileService.GetTable(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;UserIdentity&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; item = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonObject&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table.InsertAsync(item);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Item: {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, item.Stringify());&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; fbAccessCode = item[&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;identities&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;].GetObject()[&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;facebook&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;].GetObject()[&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;accessToken&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;].GetString();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; httpClient = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpClient&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; resp = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; httpClient.GetAsync(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;https://graph.facebook.com/me?access_token=&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + fbAccessCode);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; body = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; resp.Content.ReadAsStringAsync();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonObject&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; bodyJson = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonObject&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Parse(body);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;foreach&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; key &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;in&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; bodyJson.Keys)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;{0}: {1}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, key, bodyJson[key].Stringify());&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;catch&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Exception&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ex)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Error: {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, ex);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;First, the change in the client, which is the simple one: just use the new overload of the LoginAsync method – see the change below. Everything else remains exactly the same.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bd1e8a21-462a-4a46-a1d1-5e655b76eb55" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; user = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; MobileService.LoginAsync(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MobileServiceAuthenticationProvider&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Facebook, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Logged in as {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, user.UserId);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table = MobileService.GetTable(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;UserIdentity&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Now, for the required server change. To enable this feature, we actually need to have a package id for the application in the Windows 8 store. If you still haven’t created an application on the Windows Store, you can follow the instructions in the &lt;a href="http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-push-dotnet/"&gt;tutorial for enabling push notifications&lt;/a&gt;. So far I hadn’t needed to do that, although once my app was ready for publishing to the store I’d had to do that anyway. So let me create one now:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/0825.CreateNewAppWindowsStore_5F00_38A4C665.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="CreateNewAppWindowsStore" border="0" alt="CreateNewAppWindowsStore" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3377.CreateNewAppWindowsStore_5F00_thumb_5F00_6A9C66EF.png" width="417" height="269" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After the application is created (I’ll call mine “blogpost20130204”) we can associate the VS project with the application in the store:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/4848.AssociateAppStore_5F00_4A815A32.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="AssociateAppStore" border="0" alt="AssociateAppStore" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/2705.AssociateAppStore_5F00_thumb_5F00_2A664D75.png" width="413" height="282" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Next, we need to find the package SID for the store application. I actually find the dashboard for the &lt;a href="https://manage.dev.live.com"&gt;Live Connect Developer Center&lt;/a&gt; easier to navigate than the Windows Store dashboard, so I’ll go from there:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/7585.LiveConnectDashboard_5F00_38389370.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="LiveConnectDashboard" border="0" alt="LiveConnectDashboard" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/5432.LiveConnectDashboard_5F00_thumb_5F00_6A3033FA.png" width="366" height="157" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After selecting the application, select “Edit Settings” and “API Settings” and it should show the package SID for my app:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/4846.PackageSid_5F00_5F06A9B0.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="PackageSid" border="0" alt="PackageSid" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/7178.PackageSid_5F00_thumb_5F00_10FE4A3B.png" width="337" height="259" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now that we have that value, we need to set it on the Azure Mobile Service portal for our application. Currently the only place where we can set it is on the “PUSH” tab, so that’s where we go, even through we’ll use it for authentication, and not push (in the future I’m sure there will be an update to the portal and that will be in its proper place).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3858.PushTab_5F00_57E76D38.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="PushTab" border="0" alt="PushTab" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3463.PushTab_5F00_thumb_5F00_09DF0DC3.png" width="365" height="276" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Ok, now we have both the client and the server changes made. And that should be it. The username / password information should be now remembered by the client application!&lt;/p&gt;  &lt;h3&gt;More info / known issues&lt;/h3&gt;  &lt;p&gt;The old behavior and the new behavior are a byproduct of our usage of the Web Authentication Browser control in our Windows 8 SDK. Over the next couple of days I’ll publish a post with the internal details of our authentication, and how it relates to that control.&lt;/p&gt;  &lt;p&gt;There’s currently one issue that we’re aware of: if you try to use &lt;strong&gt;both&lt;/strong&gt; the Live SDK to authenticate the user to the app (a.k.a. client-side auth flow) &lt;strong&gt;and&lt;/strong&gt; the single sign-on for Microsoft accounts (a.k.a. server-side auth flow), then the server-side flow won’t work. Notice that this isn’t something that one would normally do, as both do the same thing. Just something to be aware.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10391050" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Service/">Mobile Service</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category></item><item><title>Inserting multiple items at once in Azure Mobile Services</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2013/01/02/inserting-multiple-items-at-once-in-azure-mobile-services.aspx</link><pubDate>Wed, 02 Jan 2013 22:29:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10381933</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10381933</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10381933</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2013/01/02/inserting-multiple-items-at-once-in-azure-mobile-services.aspx#comments</comments><description>&lt;p&gt;With the Azure Mobile Services client SDK, it’s fairly simple to insert an item into a table in Azure. Inserting multiple items can be also done fairly easily, simply inserting one at a time. But there are some scenarios where we want to actually do multiple insertions at once, to minimize the number of networking requests made from the client to the service. In the &lt;a href="https://github.com/WindowsAzure/azure-mobile-services/tree/dev/test/iOS"&gt;E2E Test Application&lt;/a&gt; that we have for our iOS client, the first thing we do in our query tests is to pre-populate a table with some data (if the table was empty), and since we don’t that to affect the test performance (we use about 250 items), we decided to insert them all at once. This has also been asked in our forums, so I decided to post how I went out to implement it.&lt;/p&gt;  &lt;p&gt;The idea is fairly simple: instead of sending one item, we send a list of items which we want to be inserted. At the server side, instead of letting the default behavior for the insert operation kick in, we instead loop through the items and insert them one-by-one. Since the database and the instance running the mobile services are often located in the same datacenter, the latency between the two components is a lot smaller than from the client making the insert call and the mobile service, so we have some significant performance gains. And by having the logic to do multiple insertions at the server side, we don’t need to implement that at the client (doing it in managed code is trivial with the async / await keywords; doing that in iOS or in JavaScript not so much).&lt;/p&gt;  &lt;p&gt;The way that I chose to implement the logic was that the service would receive not an array of items directly, but an object with one of its members being the array to be inserted. That’s easier to implement in the managed client (using an &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.mobileservices.idatamemberjsonconverter.aspx"&gt;IDataMemberJsonConverter&lt;/a&gt; instead of an &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.mobileservices.icustommobileservicetableserialization.aspx"&gt;ICustomMobileServiceTableSerialization&lt;/a&gt;). For JavaScript it really doesn’t matter, since we’re dealing with JS objects in either case. And for the iOS client, we currently can only do that, since the insert operation only takes a dictionary (not an array) as an argument.&lt;/p&gt;  &lt;p&gt;Let’s look at the server script. In this example, we’re adding populating our table called ‘iosMovies’, and the data to be inserted is an array in the “movies” property of the received item. The first thing we do is to check whether we actually need to do the insertion (that’s something specific to the scenario of my app; maybe in your case you always want to do the insertion, so that step won’t be necessary). By reading only the first element of the table, we can check whether the table is populated or not (since this script runs in the “insert’ operation, we assume that the table is either fully populated or it needs the items to be inserted). If the data is already there, we respond with an appropriate status. Otherwise, we proceed with the multiple insert operations.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd2c9b25-ce6b-4254-989f-fca8321d4a7b" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; insert(item, user, request) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table = tables.getTable(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;iosMovies&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;table.take(1).read({&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;success: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (items) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (items.length &amp;gt; 0) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// table already populated&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(200, { id: 1, status: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Already populated&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; });&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// Need to populate the table&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;populateTable(table, request, item.movies);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Populating the table with multiple items is done by looping through the items to be inserted, and inserting them one by one (*). Since the insert operation in the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj554210.aspx"&gt;table object&lt;/a&gt; is asynchronous, we can’t use a simple sequential loop; instead, we’ll insert each element when the callback for the previous one is called. After the last one is inserted, we can then respond to the client with an appropriate status.&lt;/p&gt;  &lt;p&gt;There’s one extra step that we had to do in this example, which caught me by surprise at first – updating a field of type Date (or DateTime in the managed client, or NSDate in the iOS client). When I first ran that code, the table was created, and the data was seemingly correct. But when I checked the type of the columns in the database, my field ‘ReleaseDate’ had been translated into a column of type ‘string’. ‘datetime‘ is a supported primitive type in Azure Mobile Services, so I was expecting the column to have the appropriate value. The problem is that dates and strings are transmitted using the same type in JSON, string (there’s no such a thing as a “JSON date”). If a string value arrives with a specific format (the ISO 8601 date format, with millisecond precision), then the Mobile Service runtime converts that value into a JavaScript Date object. However, that conversion is only done in top-level objects – it doesn’t traverse the whole incoming object graph (for performance reasons), so in my case my “date” value ended up as a normal string. To fix that, prior to inserting the data we fixed that by converting the ‘ReleaseDate’ field in in the input array.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7d46699c-2da3-4ca8-b1c6-6816e8030595" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; populateTable(table, request, films) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; index = 0;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;films.forEach(changeReleaseDate);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; insertNext = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; () {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (index &amp;gt;= films.length) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(201, { id: 1, status: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Table populated successfully&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; });&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; toInsert = films[index];&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;table.insert(toInsert, {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;success: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; () {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;index++;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ((index % 20) === 0) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                        &lt;span style="background:#ffffff;color:#000000"&gt;console.log(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Inserted %d items&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, index);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;insertNext();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;};&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;insertNext();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; changeReleaseDate(obj) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; releaseDate = obj.ReleaseDate;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;typeof&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; releaseDate === &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;string&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;releaseDate = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Date(releaseDate);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;obj.ReleaseDate = releaseDate;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;So that’s the script for the server. Now for the client code. Let’s look at the flavors we have. First, managed code, where we have the classes for that data:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4e886089-3f30-4f04-941d-51944701c6f0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 400px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DataTable&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(Name = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;w8Movies&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)]&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;AllMovies&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DataMember&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(Name = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)]&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Id { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DataMember&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(Name = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;status&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)]&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Status { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DataMember&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(Name = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;movies&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)]&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DataMemberJsonConverter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(ConverterType = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;typeof&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MovieArrayConverter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;))]&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Movie&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;[] Movies { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MovieArrayConverter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; : &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;IDataMemberJsonConverter&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ConvertFromJson(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;IJsonValue&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; value)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// unused&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;null&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;IJsonValue&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ConvertToJson(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; instance)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Movie&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;[] movies = (&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Movie&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;[])instance;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonArray&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; result = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonArray&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;foreach&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; movie &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;in&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; movies)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;result.Add(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MobileServiceTableSerializer&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Serialize(movie));&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; result;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DataTable&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(Name = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;w8Movies&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;)]&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Movie&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Id { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Title { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Duration { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ReleaseDate { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Year { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;bool&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; BestPictureWinner { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Rating { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;And to insert multiple movies at once, we create an instance of our type which holds the array, and call insert on that object:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6826f5d2-bf56-4168-91a7-59dea2cb5c90" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 400px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Func&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt; createDate = &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;(y, m, d) =&amp;gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTime&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(y, m, d, 0, 0, 0, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DateTimeKind&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Utc);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;AllMovies&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; allMovies = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;AllMovies&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;Movies = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Movie&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;[]&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Movie&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;BestPictureWinner = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;false&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Duration = 142, Rating = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;R&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;ReleaseDate = createDate(1994, 10, 14), &lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Title = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;The Shawshank Redemption&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Year = 1994 },&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Movie&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;BestPictureWinner = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Duration = 175, Rating = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;R&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;ReleaseDate = createDate(1972, 3, 24),&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Title = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;The Godfather&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Year = 1972 },&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Movie&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;BestPictureWinner = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Duration = 200, Rating = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;R&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;ReleaseDate = createDate(1974, 12, 20), &lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Title = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;The Godfather: Part II&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Year = 1974 },&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Movie&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;BestPictureWinner = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;false&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Duration = 168, Rating = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;R&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;ReleaseDate = createDate(1994, 10, 14), &lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Title = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Pulp Fiction&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Year = 1994 },&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;};&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;try&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table = MobileService.GetTable&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;AllMovies&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt;();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table.InsertAsync(allMovies);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Status: {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, allMovies.Status);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;catch&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Exception&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ex)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;AddToDebug(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Error: {0}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, ex);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;For Objective-C, we don’t need to create the types, so we can use the NSDictionary and NSArray classes directly. The implementation of the ‘getMovies’ method can be found &lt;a href="https://github.com/WindowsAzure/azure-mobile-services/blob/dev/test/iOS/ZumoE2ETestApp/ZumoE2ETestApp/ZumoQueryTestData.m"&gt;in our GitHub repository&lt;/a&gt;.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9b6c6f16-59ee-4f64-8520-8b027bb45d89" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;NSArray *movies = [ZumoQueryTestData getMovies];&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;NSDictionary *item = @{@&amp;quot;movies&amp;quot; : movies};&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;MSTable *table = [client getTable:queryTestsTableName];&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;[table insert:item completion:^(NSDictionary *item, NSError *error) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;if (error) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;NSLog(@&amp;quot;Error populating table: %@&amp;quot;, error);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;} else {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;NSLog(@&amp;quot;Table is populated and ready for query tests&amp;quot;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}];&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Similarly for JavaScript, we can just use “regular” objects and arrays to insert the data:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:dc6f5f5d-9949-4740-ba4e-74e381e52b5a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 400px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table = client.getTable(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;w8Movies&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; allMovies = {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;movies: [&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;BestPictureWinner: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;false&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Duration: 142,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Rating: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;R&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;ReleaseDate: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Date(Date.UTC(1994, 10, 14)),&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Title: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;The Shawshank Redemption&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Year: 1994&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;},&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;BestPictureWinner: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Duration: 175,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Rating: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;R&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;ReleaseDate: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Date(Date.UTC(1972, 3, 24)),&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Title: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;The Godfather&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Year: 1972&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;},&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;BestPictureWinner: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Duration: 200,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Rating: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;R&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;ReleaseDate: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Date(Date.UTC(1974, 12, 20)),&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Title: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;The Godfather: Part II&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Year: 1974&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;},&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;BestPictureWinner: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;false&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Duration: 168,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Rating: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;R&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;ReleaseDate: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Date(Date.UTC(1994, 10, 14)),&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Title: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Pulp Fiction&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;Year: 1994&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;]&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;};&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;table.insert(allMovies).done(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (inserted) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;document.getElementById(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;result&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).innerText = inserted.status || allMovies.status;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;That’s about it. This is one of the ways we have to prevent multiple networking requests between the client and the mobile service to perform multiple insertions at once.&lt;/p&gt;  &lt;p&gt;(*) &lt;strong&gt;Bonus info&lt;/strong&gt;: As I mentioned before, this still does multiple calls, between the mobile service and the database, but since they’re co-located, the latency is small. You also can make really only one call, from the service to the database, by using the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj554212.aspx"&gt;mssql object&lt;/a&gt;, and creating one insert request for multiple rows at once. You’d need to do the translation between the data types and the SQL expression yourself, and use the “union all” trick to create a temporary table and insert from that table – see an example below. Notice that you’d also need to create the table columns (if they don’t exist yet), since the dynamic schema feature doesn’t work with the mssql object – once you go down to that level, you’re in full control of the database communication.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0bbf3da6-70cb-44ae-ad85-53cb04f83e81" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;INSERT&lt;/span&gt; &lt;span style="color:#0000ff"&gt;INTO&lt;/span&gt; &lt;span style="color:#008080"&gt;w8Movies&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#808080"&gt;(&lt;/span&gt;&lt;span style="color:#008080"&gt;Title&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;[Year]&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;Duration&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;BestPictureWinner&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;Rating&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;ReleaseDate&lt;/span&gt;&lt;span style="color:#808080"&gt;)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;The Shawshank Redemption&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; 1994&lt;span style="color:#808080"&gt;,&lt;/span&gt; 142&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;FALSE&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;R&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;1994-10-14&amp;#39;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;UNION&lt;/span&gt; &lt;span style="color:#808080"&gt;ALL&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;The Godfather&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; 1972&lt;span style="color:#808080"&gt;,&lt;/span&gt; 175&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;TRUE&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;R&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;1972-03-24&amp;#39;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;UNION&lt;/span&gt; &lt;span style="color:#808080"&gt;ALL&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;The Godfather: Part II&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; 1974&lt;span style="color:#808080"&gt;,&lt;/span&gt; 200&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;TRUE&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;R&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;1974-12-20&amp;#39;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;UNION&lt;/span&gt; &lt;span style="color:#808080"&gt;ALL&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;Pulp Fiction&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; 1994&lt;span style="color:#808080"&gt;,&lt;/span&gt; 168&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;TRUE&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;R&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;1994-10-14&amp;#39;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;So which one to use? I really didn’t see much advantage in going full SQL for my scenario. Once a communication between the mobile service and the database is successful, chances are that over the next second or so the subsequent ones will be as well, so doing ~250 insert operations, although not really an atomic transaction, has a very good chance of being one. As usual, it may vary according to the scenario of your application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10381933" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Service/">Mobile Service</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category></item><item><title>Getting user information on Azure Mobile Services</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/25/getting-user-information-on-azure-mobile-services.aspx</link><pubDate>Thu, 25 Oct 2012 05:39:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10362604</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10362604</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10362604</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/25/getting-user-information-on-azure-mobile-services.aspx#comments</comments><description>&lt;p&gt;With the introduction of the server-side authentication flow (which I mentioned in my &lt;a href="http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/23/troubleshooting-authentication-issues-in-azure-mobile-services.aspx"&gt;last post&lt;/a&gt;), it’s now a lot simpler to authenticate users with Windows Azure Mobile Services. Once the LoginAsync / login / loginViewControllerWithProvider:completion: method / selector completes, the user is authenticated, the MobileServiceClient / MSClient object will hold a token that is used for authenticating requests, and it can now be used to access authentication-protected tables. But there’s more to authentication than just getting a unique identifier for a user – we can also get more information about the user from the providers we used to authenticate, or even act on their behalf if they allowed the application to do so.&lt;/p&gt;  &lt;p&gt;With Azure Mobile Services you can still do this. However, the property is not available at the user object stored at the client – the only property it exposes is the user id, which doesn’t give the information that the user authorized the providers to give. This post will show, for the supported providers, how to get access to some of their properties, using their specific APIs.&lt;/p&gt;  &lt;h3&gt;User identities&lt;/h3&gt;  &lt;p&gt;The client objects doesn’t expose any of that information to the application, but at the server side, we can get what we need. The &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj554220.aspx"&gt;User object&lt;/a&gt; which is passed to all scripts has now a new function, getIdentities(), which returns an object with provider-specific data which can be used to query their user information. For example, for a user authenticated with a Facebook credential in my app, this is the object returned by calling user.getIdentities():&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Consolas"&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;facebook&amp;quot;:{        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;userId&amp;quot;:&amp;quot;Facebook:&lt;em&gt;my-actual-user-id&lt;/em&gt;&amp;quot;,        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&amp;quot;accessToken&amp;quot;:&amp;quot;&lt;em&gt;the-actual-access-token&lt;/em&gt;&amp;quot;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }        &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;And for Twitter:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Consolas"&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;twitter&amp;quot;:{        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;userId&amp;quot;:&amp;quot;Twitter:&lt;em&gt;my-actual-user-id&lt;/em&gt;&amp;quot;,        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;accessToken&amp;quot;:&amp;quot;&lt;em&gt;the-actual-access-token&lt;/em&gt;&amp;quot;,        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;accessTokenSecret&amp;quot;:&amp;quot;&lt;em&gt;the-actual-access-token-secret&lt;/em&gt;&amp;quot;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }        &lt;br /&gt;}        &lt;br /&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Microsoft:&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Consolas"&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;microsoft&amp;quot;:{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;userId&amp;quot;:&amp;quot;MicrosoftAccount:&lt;em&gt;my-actual-user-id&lt;/em&gt;&amp;quot;,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;accessToken&amp;quot;:&amp;quot;&lt;em&gt;the-actual-access-token&lt;/em&gt;&amp;quot;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;}      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Google:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Consolas"&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;google&amp;quot;:{        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;userId&amp;quot;:&amp;quot;Google:&lt;em&gt;my-actual-user-id&lt;/em&gt;&amp;quot;,        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;accessToken&amp;quot;:&amp;quot;&lt;em&gt;the-actual-access-token&lt;/em&gt;&amp;quot;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }        &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Each of those objects has the information that we need to talk to the providers API. So let’s see how we can talk to their APIs to get more information about the user which has logged in to our application. For the examples in this post, I’ll simply store the user name alongside the item which is being inserted&lt;/p&gt;  &lt;h3&gt;Talking to the Facebook Graph API&lt;/h3&gt;  &lt;p&gt;To interact with the Facebook world, you can either use one of their native SDKs, or you can talk to their REST-based &lt;a href="https://developers.facebook.com/docs/reference/api/"&gt;Graph API&lt;/a&gt;. To talk to it, all we need is a HTTP client, and we do have the nice &lt;a href="https://github.com/mikeal/request"&gt;request module&lt;/a&gt; which we can import (require) on our server scripts. To get the user information, we can send a request to &lt;a href="https://graph.facebook.com/me"&gt;https://graph.facebook.com/me&lt;/a&gt;, passing the access token as a query string parameter. The code below does that. It checks whether the user is logged in via Facebook; if so, it will send a request to the Graph API, passing the token stored in the user identities object. If everything goes right, it will parse the result (which is a JSON object), and retrieve the user name (from its “name” property) and store in the item being added to the table.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b763e11-7d2f-47f5-b27a-b1d362a0eb5e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; insert(item, user, request) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;item.UserName = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;&amp;lt;unknown&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// default&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; identities = user.getIdentities();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; req = require(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;request&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.facebook) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; fbAccessToken = identities.facebook.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://graph.facebook.com/me?access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + fbAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;req(url, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (err, resp, body) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (err || resp.statusCode !== 200) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;console.error(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Error sending data to FB Graph API: &amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, err);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(statusCodes.INTERNAL_SERVER_ERROR, body);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;try&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; userData = JSON.parse(body);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;item.UserName = userData.name;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;request.execute();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;catch&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (ex) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                ��   &lt;span style="background:#ffffff;color:#000000"&gt;console.error(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Error parsing response from FB Graph API: &amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, ex);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(statusCodes.INTERNAL_SERVER_ERROR, ex);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// Insert with default user name&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;request.execute();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;With the access token you can also call other functions on the Graph API, depending on what the user allowed the application to access. But if all you want is the user name, there’s another way to get this information: the &lt;em&gt;userId&lt;/em&gt; property of the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj554220.aspx"&gt;User object&lt;/a&gt;, for users logged in via Facebook is in the format “Facebook:&amp;lt;graph unique id&amp;gt;”. You can use that as well, without needing the access token, to get the public information exposed by the user:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:30956d3a-5cfc-4603-abe8-4c7f58080022" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; insert(item, user, request) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;item.UserName = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;&amp;lt;unknown&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// default&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; providerId = user.userId.substring(user.userId.indexOf(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;:&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;) + 1);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; identities = user.getIdentities();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; req = require(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;request&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.facebook) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://graph.facebook.com/&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + providerId;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;req(url, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (err, resp, body) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (err || resp.statusCode !== 200) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;console.error(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Error sending data to FB Graph API: &amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, err);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(statusCodes.INTERNAL_SERVER_ERROR, body);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;try&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; userData = JSON.parse(body);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;item.UserName = userData.name;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;request.execute();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;catch&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (ex) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;console.error(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Error parsing response from FB Graph API: &amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, ex);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(statusCodes.INTERNAL_SERVER_ERROR, ex);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// Insert with default user name&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;request.execute();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The main advantage of this last method is that it can not only be used in the client-side as well.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b4f12688-f45f-4c82-bebc-ab69d6a27937" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;async&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; btnFacebookLogin_Click_1(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; sender, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; e)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; MobileService.LoginAsync(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MobileServiceAuthenticationProvider&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Facebook);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; userId = MobileService.CurrentUser.UserId;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; facebookId = userId.Substring(userId.IndexOf(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;:&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;) + 1);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; client = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpClient&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; fbUser = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; client.GetAsync(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;https://graph.facebook.com/&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + facebookId);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; response = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; fbUser.Content.ReadAsStringAsync();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; jo = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonObject&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Parse(response);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; userName = jo[&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;].GetString();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.lblTitle.Text = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Multi-auth Blog: &amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + userName;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;That’s it for Facebook; let’s move on to another provider.&lt;/p&gt;  &lt;h3&gt;Talking to the Google API&lt;/h3&gt;  &lt;p&gt;The code for the Google API is fairly similar to the one for Facebook. To get user information, we send a request to https://www.googleapis.com/oauth2/v1/userinfo, again passing the access token as a query string parameter. &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:270d2888-4e94-44c7-8325-25a5b4256354" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; insert(item, user, request) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;item.UserName = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;&amp;lt;unknown&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// default&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; identities = user.getIdentities();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; req = require(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;request&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.google) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; googleAccessToken = identities.google.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://www.googleapis.com/oauth2/v1/userinfo?access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + googleAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;req(url, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (err, resp, body) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (err || resp.statusCode !== 200) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;console.error(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Error sending data to Google API: &amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, err);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(statusCodes.INTERNAL_SERVER_ERROR, body);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;try&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; userData = JSON.parse(body);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;item.UserName = userData.name;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;request.execute();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;catch&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (ex) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;console.error(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Error parsing response from Google API: &amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, ex);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(statusCodes.INTERNAL_SERVER_ERROR, ex);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// Insert with default user name&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;request.execute();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Notice that the code is so similar that we can just merge them into one:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:589c7505-d7c7-437f-a132-4f78e877cf0f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; insert(item, user, request) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;item.UserName = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;&amp;lt;unknown&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// default&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; identities = user.getIdentities();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; url;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.google) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; googleAccessToken = identities.google.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://www.googleapis.com/oauth2/v1/userinfo?access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + googleAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.facebook) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; fbAccessToken = identities.facebook.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://graph.facebook.com/me?access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + fbAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (url) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; requestCallback = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (err, resp, body) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (err || resp.statusCode !== 200) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;console.error(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Error sending data to the provider: &amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, err);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(statusCodes.INTERNAL_SERVER_ERROR, body);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;try&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; userData = JSON.parse(body);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;item.UserName = userData.name;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;request.execute();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;catch&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (ex) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;console.error(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Error parsing response from the provider API: &amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, ex);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(statusCodes.INTERNAL_SERVER_ERROR, ex);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; req = require(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;request&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; reqOptions = {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;uri: url,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;headers: { Accept: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; }&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;};&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;req(reqOptions, requestCallback);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;// Insert with default user name&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;request.execute();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;And with this generic framework we can add one more:&lt;/p&gt;  &lt;h3&gt;Talking to the Windows Live API&lt;/h3&gt;  &lt;p&gt;Very similar to the previous ones, just a different URL. Most of the code is the same, we just need to add a new else if branch:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b2a66284-3da3-4589-9ffa-e18fb64a3643" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.google) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; googleAccessToken = identities.google.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://www.googleapis.com/oauth2/v1/userinfo?access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + googleAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.facebook) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; fbAccessToken = identities.facebook.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://graph.facebook.com/me?access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + fbAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.microsoft) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; liveAccessToken = identities.microsoft.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://apis.live.net/v5.0/me/?method=GET&amp;amp;access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + liveAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;And the user name can be retrieved in the same way as the others – notice that this is true because all three providers seen so far return the user name in the “name” property, so we didn’t need to change the callback code.&lt;/p&gt;  &lt;h3&gt;Getting Twitter user data&lt;/h3&gt;  &lt;p&gt;Twitter is a little harder than the other providers, since it needs two things from the identity (access token and access token secret), and one of the request headers needs to be signed. For simplicity here I’ll just use the user id trick as we did for Facebook:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c8c72ef8-5554-437d-bfdb-85f19b7c1029" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.google) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; googleAccessToken = identities.google.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://www.googleapis.com/oauth2/v1/userinfo?access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + googleAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.facebook) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; fbAccessToken = identities.facebook.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://graph.facebook.com/me?access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + fbAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.microsoft) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; liveAccessToken = identities.microsoft.accessToken;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://apis.live.net/v5.0/me/?method=GET&amp;amp;access_token=&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + liveAccessToken;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (identities.twitter) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; userId = user.userId;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; twitterId = userId.substring(userId.indexOf(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;:&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;) + 1);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;https://api.twitter.com/users/&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + twitterId;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;And since the user name is also stored in the “name” property of the Twitter response, the callback doesn’t need to be modified.&lt;/p&gt;  &lt;h3&gt;Accessing provider APIs from the client&lt;/h3&gt;  &lt;p&gt;So far I’ve shown how you can get user information from the script, and some simplified version of it for the client side (for Facebook and Twitter). But what if we want the logic to access the provider APIs to live in the client, and just want to retrieve the access token which is stored in the server? Right now, there’s no clean way of doing that (no “non-CRUD operation” support on Azure Mobile Services), so what you can do is to create a “dummy” table that is just used for that purpose.&lt;/p&gt;  &lt;p&gt;In the portal, create a new table for your application – for this example I’ll call it Identities, set the permissions for Insert / Delete and Update to “Only Scripts and Admins” (so that nobody will insert any data in this table), and for Read set to “Only Authenticated Users”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/8206.IdentitiesTable_5F00_109AE419.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="IdentitiesTable" border="0" alt="IdentitiesTable" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6153.IdentitiesTable_5F00_thumb_5F00_707FD75B.png" width="436" height="377" /&gt;&lt;/a&gt;&lt;/p&gt;              &lt;p&gt;Now in the Read script, return the response as requested by the caller, with the user identities stored in a field of the response. For the response: if a specific item was requested, return only one element; otherwise return a collection with only that element:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ce929ba2-bbce-4a6f-9d83-27b7073806ff" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; max-height: 200px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; read(query, user, request) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; result = {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;id: query.id,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;identities: user.getIdentities()&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;};&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (query.id) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(200, result);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;request.respond(200, [result]);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;And we can then get the identities on the client as a JsonObject by retrieving data from that “table”.&lt;/p&gt;  &lt;p&gt;   &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:88f9fa2d-0dfa-4b76-8c36-6f7cce7432a2" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table = MobileService.GetTable(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Identities&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; response = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; table.ReadAsync(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; identities = response.GetArray()[0].GetObject();&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;  &lt;p&gt;Notice that there’s no LookupAsync method on the “untyped” table, so the result is returned as an array; it’s possible that this will be added to the client SDK in the future, so we won’t need to get the object from the (single-element) array, receiving the object itself directly.&lt;/p&gt;  &lt;h3&gt;Wrapping up&lt;/h3&gt;  &lt;p&gt;The new multi-provider authentication support added in Azure Mobile Services made it quite easy to authenticate users to your mobile application, and it also gives you the power to access the provider APIs. If you have any comments or feedback, don’t hesitate to send either here on in the &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/azuremobile/threads"&gt;Azure Mobile Services forum&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10362604" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Authentication/">Authentication</category></item><item><title>Troubleshooting authentication issues in Azure Mobile Services</title><link>http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/23/troubleshooting-authentication-issues-in-azure-mobile-services.aspx</link><pubDate>Tue, 23 Oct 2012 02:28:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10361904</guid><dc:creator>CarlosFigueira</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/rsscomments.aspx?WeblogPostID=10361904</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/carlosfigueira/commentapi.aspx?WeblogPostID=10361904</wfw:comment><comments>http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/23/troubleshooting-authentication-issues-in-azure-mobile-services.aspx#comments</comments><description>&lt;p&gt;With the announcement last week in &lt;a href="http://weblogs.asp.net/scottgu/archive/2012/10/16/windows-azure-mobile-services-new-support-for-ios-apps-facebook-twitter-google-identity-emails-sms-blobs-service-bus-and-more.aspx"&gt;ScottGu’s blog&lt;/a&gt;, Azure Mobile Service now supports different kinds of authentication in addition to authentication using the Windows Live SDK which was supported at first. You can now authenticate the users of your applications using Facebook, Google, Twitter and even Microsoft Accounts (formerly known as Live IDs) without any native SDK for those providers, just like on web applications. In fact, the authentication is done exactly by the application showing an embedded web browser control which talks to the authentication provider’s websites. In the example below, we see an app using Twitter to authenticate its user.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6431.TwitterAuthWindow_5F00_72E3467E.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="TwitterAuthWindow" border="0" alt="TwitterAuthWindow" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6443.TwitterAuthWindow_5F00_thumb_5F00_12922047.png" width="507" height="381" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The tutorial &lt;a href="http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-users-dotnet/"&gt;Getting Started with Users&lt;/a&gt; shows how to set up the authentication, including creating applications in each of the supported providers. It’s a great tutorial, and when everything works fine, then great, we’ll add the authentication code to the client (quite small, especially for managed Windows Store apps), users can login and we’re all good. However, there are cases where we just don’t get the behavior we want, and we end up with a client which just can’t correctly authenticate.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/7024.FailedAuthWindow_5F00_4E51B8FA.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="FailedAuthWindow" border="0" alt="FailedAuthWindow" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6036.FailedAuthWindow_5F00_thumb_5F00_47327C82.png" width="504" height="379" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;There are a number of issues which may be causing this problem, and the nature of authentication of connected mobile applications, with three distinct components (the mobile app itself, the Azure Mobile Service, and the identity provider) makes debugging it harder than simple applications.&lt;/p&gt;  &lt;p&gt;There is, however, one nice trick which &lt;a href="https://twitter.com/tjanczuk"&gt;@tjanczuk&lt;/a&gt; (who actually implemented this feature) taught me and can make troubleshooting such problems a little easier. What we do essentially is to remove one component of the equation (the mobile application), to make debugging the issue simpler. The trick is simple: since the application is actually hosting a browser control to perform the authentication, we’ll simply use a real browser to do that. By talking to the authentication endpoints of the mobile service runtime directly, we can see what’s going on behind the scenes of the authentication protocol, and hopefully fix our application.&lt;/p&gt;  &lt;h3&gt;The authentication endpoint&lt;/h3&gt;  &lt;p&gt;Before we go into broken scenarios, let’s talk a about the authentication endpoint which we have in the Azure Mobile Services runtime. As of the writing of this post the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj710108.aspx"&gt;REST API Reference&lt;/a&gt; for Windows Azure Mobile Services has yet to be updated for the server-side (web-based) authentication support, so I’ll cover it briefly here.&lt;/p&gt;  &lt;p&gt;The authentication endpoint for an Azure Mobile Service responds to GET requests to https://&amp;lt;service-name&amp;gt;.azure-mobile.net/login/&amp;lt;providerName&amp;gt;, where &amp;lt;providerName&amp;gt; is one of the supported authentication providers (currently “facebook”, “google”, “microsoftaccount” or “twitter”). When a browser (or the embedded browser control) sends a request to that address, the Azure Mobile Service runtime will respond with a redirect (HTTP 302) response to the appropriate page on the authentication provider (for example, the twitter page shown in the first image of this post). Once the user enters valid credentials, the provider will redirect it back to the Azure Mobile Service runtime with its specific authentication token. At that time, the runtime will validate those credentials with the provider, and then issue its own token, which will be used by the client as the authentication token to communicate with the service.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3113.ServerSideAuthFlow_5F00_1225ED52.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ServerSideAuthFlow" border="0" alt="ServerSideAuthFlow" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6740.ServerSideAuthFlow_5F00_thumb_5F00_720AE094.png" width="424" height="362" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The diagram above shows a rough picture of the authentication flow. Notice that the client may send more than one request to the authentication provider, as it’s often first asks the user to enter its credentials, then (at least once per application) asks the user to allow the application to use its credentials. What the browser control in the client does is to monitor the URL to where it’s navigating, and when it sees that it’s navigating to the /login/done endpoint, it will know that the whole authentication “dance” has finished. At that point, the client can dispose the browser control and store the token to authenticate future requests it sends.&lt;/p&gt;  &lt;p&gt;This whole protocol is just a bunch of GET requests and redirect responses. That’s something that a “regular” browser can handle pretty well, so we can use that to make sure that the server is properly set up. So we’ll now see some scenarios where we can use a browser to troubleshoot the server-side authentication. For this scenario I prefer to use either Google Chrome or Mozilla Firefox, since they can display JSON payloads in the browser itself, without needing to go to the developer tools. With Internet Explorer you can also do that, but by default it asks you to save the JSON response in a file, which I personally find annoying. Let’s move on to some problems and how to identify them.&lt;/p&gt;  &lt;h3&gt;&lt;/h3&gt;    &lt;h3&gt;Missing configuration&lt;/h3&gt;  &lt;p&gt;Once the mobile service application is created, no identity provider credentials are set in the portal. If the authentication with a specific provider is not working, you can try browsing to it. In my application I haven’t set the authentication credentials for Google login, so I’ll get a response saying so in the browser.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/1134.AuthProviderNotEnabled_5F00_46C6498D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="AuthProviderNotEnabled" border="0" alt="AuthProviderNotEnabled" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/1157.AuthProviderNotEnabled_5F00_thumb_5F00_3FA70D15.png" width="486" height="201" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To fix this, go to the portal, and enter the correct credentials. Notice that there was a bug in the portal until last week where the credentials were not being properly propagated to the mobile service runtime (it has since been fixed). If you added the credentials once this was released, you can try removing them, then adding them again, and it should go through.&lt;/p&gt;  &lt;h3&gt;Missing redirect URL&lt;/h3&gt;  &lt;p&gt;In all of the providers you need to set the redirect URL so that the provider knows to, after authenticating the user, redirect it back to the Azure Mobile Service login page. By using the browser we can check see that error clearer than when using an actual mobile application. For example, this is what we get when we forget to set the “Site URL” property on Facebook, after we browse to &lt;a href="https://my-application-name.azure-mobile.net/login/facebook"&gt;https://my-application-name.azure-mobile.net/login/facebook&lt;/a&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/4784.NoRedirectUrlFacebook_5F00_3887D09D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="NoRedirectUrlFacebook" border="0" alt="NoRedirectUrlFacebook" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/2211.NoRedirectUrlFacebook_5F00_thumb_5F00_5F55E6DD.png" width="481" height="239" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And for Windows Live (a.k.a. Microsoft Accounts), after browsing to &lt;a href="https://my-application-name.azure-mobile/login/microsoftaccount"&gt;https://my-application-name.azure-mobile/login/microsoftaccount&lt;/a&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3704.NoRedirectUrlMicrosoft_5F00_4D0D201B.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="NoRedirectUrlMicrosoft" border="0" alt="NoRedirectUrlMicrosoft" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3113.NoRedirectUrlMicrosoft_5F00_thumb_5F00_10E15473.png" width="481" height="191" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Not as clear an error as the one from Facebook, but if you look at the URL in the browser (may need to copy/paste to a text editor to see better):&lt;/p&gt;  &lt;p&gt;&lt;a href="https://login.live.com/err.srf?lc=1033"&gt;https://login.live.com/err.srf?lc=1033&lt;/a&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; #error=invalid_request&amp;amp;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; error_description=The%20provided%20value%20for%20the%20input%20parameter%20'redirect_uri'%20is%20not%20valid.%20The%20expected%20value%20is%20'https://login.live.com/oauth20_desktop.srf'%20or%20a%20URL%20which%20matches%20the%20redirect%20URI%20registered%20for%20this%20client%20application.&amp;amp;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; state=13cdf4b00313a8b4302f6&lt;/p&gt;  &lt;p&gt;It will have an error description saying that “The provided value for the input parameter 'redirect_uri' is not valid”.&lt;/p&gt;  &lt;p&gt;For other providers the experience is similar.&lt;/p&gt;  &lt;h3&gt;Invalid credentials&lt;/h3&gt;        &lt;p&gt;Maybe when copying the credentials from the provider site to the Windows Azure Mobile Services portal, the authentication will also fail, but only after going through . In this case, most providers will just say that there is a problem in the request, so one spot to look for issues is on the credentials to see if the ones in the portal match the ones in the provider page. Here are some examples of what you’ll see in the browser when that problem happens. Twitter will mention a problem with the OAuth request (OAuth being the protocol used in the authentication):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/8816.image_5F00_50AB3AF8.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/1157.image_5F00_thumb_5F00_1075217E.png" width="486" height="137" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Facebook, Microsoft and Google accounts have different errors depending on whether the error is at the client / app id or the client secret. If the error is at the client id, then the provider will display an error right away. For example, Microsoft accounts will show its common error page&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/5850.WrongClientIdMicrosoft_5F00_17282B01.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="WrongClientIdMicrosoft" border="0" alt="WrongClientIdMicrosoft" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/7002.WrongClientIdMicrosoft_5F00_thumb_5F00_6BE393F9.png" width="485" height="144" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;But the error description parameter in the URL shows the actual problem: “The client does not exist. If you are the application developer, configure a new application through the application management site at https://manage.dev.live.com/.” Facebook isn’t as clear, with a generic error. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/1638.WrongClientIdFacebook_5F00_16BBF80C.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="WrongClientIdFacebook" border="0" alt="WrongClientIdFacebook" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/2727.WrongClientIdFacebook_5F00_thumb_5F00_5685DE91.png" width="486" height="173" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Google is clearer, showing the error right on the first page:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/8816.WrongClientIdGoogle_5F00_2B41478A.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="WrongClientIdGoogle" border="0" alt="WrongClientIdGoogle" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/8081.WrongClientIdGoogle_5F00_thumb_5F00_0406FE55.png" width="487" height="239" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, when the client / app id is correct, but the problem is on the app &lt;em&gt;secret&lt;/em&gt;, then all three providers (Microsoft, Facebook, Google) will show the correct authentication page, asking for the user credentials. Only when the authentication with the provider is complete, and it redirects it back to the Azure Mobile Service (step 5 in the authentication flow diagram above), and the runtime tries to validate the token with the provider is that it will show the error. Here are the errors which the browser will show in this case. First, Facebook:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/0160.WrongCredentialsFacebook_5F00_2EDF6267.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="WrongCredentialsFacebook" border="0" alt="WrongCredentialsFacebook" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6431.WrongCredentialsFacebook_5F00_thumb_5F00_039ACB60.png" width="490" height="134" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Google:&lt;/p&gt;        &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3782.WrongCredentialsGoogle_5F00_2A68E1A0.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="WrongCredentialsGoogle" border="0" alt="WrongCredentialsGoogle" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/6428.WrongCredentialsGoogle_5F00_thumb_5F00_6A32C825.png" width="489" height="129" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Microsoft:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/5751.WrongCredentialsMicrosoft_5F00_63138BAD.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="WrongCredentialsMicrosoft" border="0" alt="WrongCredentialsMicrosoft" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/0564.WrongCredentialsMicrosoft_5F00_thumb_5F00_09E1A1EE.png" width="492" height="124" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Other issues&lt;/h3&gt;  &lt;p&gt;I’ve shown the most common problems which we’ve seen here which we can control. But as usual, there may be times where things just don’t work – network connectivity issues, blackouts on the providers. As with all distributed systems, those issues can arise from time to time which are beyond the control of the Azure Mobile Services. For those cases, you should confirm that those components are working correctly as well.&lt;/p&gt;  &lt;h3&gt;When everything is fine&lt;/h3&gt;  &lt;p&gt;Hopefully some of the troubleshoots steps I’ve shown here you’ve been able to fix your server-side authentication with the Azure Mobile Services. If that’s the case, you should see this window.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/0576.SuccessfulAuthentication_5F00_49AB8873.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="SuccessfulAuthentication" border="0" alt="SuccessfulAuthentication" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-95-96-metablogapi/3223.SuccessfulAuthentication_5F00_thumb_5F00_428C4BFB.png" width="482" height="112" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And with that window (code: 200), you’ll know that, at least the server / provider portion of the authentication dance is ready. With the simple client API, hopefully that will be enough to get your application authentication support.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10361904" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Windows+Azure/">Windows Azure</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Mobile+Service/">Mobile Service</category><category domain="http://blogs.msdn.com/b/carlosfigueira/archive/tags/Azure+Mobile+Services/">Azure Mobile Services</category></item></channel></rss>