<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Writing...Data Services</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/writingdata_services/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/writingdata_services/feed.xml</link>
    <description>Coding and writing about OData and now Windows Azure Mobile Services...</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:37:02 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>New UWP quickstart project, Mobile Services transition begins, and other Azure Mobile news</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/new-uwp-quickstart-project-mobile-services-transition-begins-and-other-azure-mobile-news</link>
      <pubDate>Wed, 18 May 2016 09:00:53 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/?p=1036</guid>
      <description><![CDATA[It’s been a while since I have been able to post about the goings on with Azure Mobile Apps and...]]></description>
      <content:encoded><![CDATA[It’s been a while since I have been able to post about the goings on with Azure Mobile Apps and other related Azure mobile goodies. (I’ve also been working on docs for the new <a href="https://azure.microsoft.com/en-us/documentation/articles/functions-overview/">Azure Functions</a> offering, which is now in preview, so there’s that.) Anyway, here’s some of what’s exciting on Azure, at least to mobile developers:
<h3><a href="https://azure.microsoft.com/en-us/blog/transition-of-azure-mobile-services/">Mobile Services will get migrated to App Service</a></h3>
Mobile Apps in App Service is a better/more powerful offering than Mobile Service in <a href="https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-value-prop-migration-from-mobile-services/">quite a few ways</a>, and it doesn’t make sense for the team to support both forever. As such, existing mobile services are going to be moved to run on App Service starting on September 1, 2015, and as of August no new mobile services can be created. After the <a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-migrating-from-mobile-services/">migration</a>, existing mobile service instances will be running on App Service and will use the Azure portal (instead of the old “classic” one). There is still a separate step to <a href="https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-net-upgrading-from-mobile-services/">upgrade to Mobile Apps</a>.  If you have an existing mobile service, you will want to read <a href="https://azure.microsoft.com/en-us/blog/transition-of-azure-mobile-services/">the entire announcement</a>.
<h3><a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-windows-store-dotnet-get-started/">Universal Windows Platform support in Mobile Apps</a></h3>
Although the .NET client has been working for Universal Windows Platform (UWP) app on Windows 10 for a while now, it hasn’t been officially supported and there wasn’t a UWP quickstart project in the portal. This deficiency has been remedied as the Windows (C#) button in the quickstart now downloads a UWP app project, which is responsive for both desktop and phone devices. The <a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-windows-store-dotnet-get-started/">Windows getting started tutorial</a> is now updated to use this new UWP quickstart project. I have also added a UWP version to the <a href="https://github.com/Azure-Samples/app-service-mobile-windows-quickstart">quickstart completed project for Windows</a>. For those unfamiliar, this repo is essentially the quickstart project that you get after completing the four main Mobile Apps tutorials (<a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-windows-store-dotnet-get-started/">create</a>, <a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-windows-store-dotnet-get-started-users/">auth</a>, <a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-windows-store-dotnet-get-started-push/">push</a>, and <a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-windows-store-dotnet-get-started-offline-data/">offline</a>). The cool thing is that this project also includes some real-world extras (<a href="https://github.com/Azure-Samples/app-service-mobile-windows-quickstart#check-for-expired-tokens">token expiration checks</a>, <a href="https://github.com/Azure-Samples/app-service-mobile-windows-quickstart#template-push-notification-registration">template-based push</a>, and <a href="https://github.com/Azure-Samples/app-service-mobile-windows-quickstart#client-added-push-notification-tags">client-added push tags</a>), which you can read about in the <a href="https://github.com/Azure-Samples/app-service-mobile-windows-quickstart">project readme</a> or in the <a href="https://azure.microsoft.com/en-us/documentation/samples/app-service-mobile-windows-quickstart/">Azure Samples Gallery</a>.
<h3><a href="https://azure.microsoft.com/blog/announcing-the-publication-of-parse-server-with-azure-managed-services/">Parse Server template in the Azure Marketplace</a></h3>
<a href="https://azure.microsoft.com/marketplace/partners/microsoft/parseserver/"><img style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/2016/05/image618.png" alt="image" width="484" height="308" border="0" /></a>

In a new offering that fully supports Parse customer needs when migrating to Azure, there is now a Parse Server implementation that uses only Azure services via a <a href="https://azure.microsoft.com/marketplace/partners/microsoft/parseserver/">template in the Azure Marketplace</a>. The best parts to me are: 1) you no longer need to provide your own Mongo DB (you instead get to use Azure DocumentDB), 2) integrattion with Azure Notification Hubs for push notifications and with Azure Storage for blobs, and 3) you even get a Parse dashboard in the Azure portal. Bam! For details, see the post <a href="https://azure.microsoft.com/blog/announcing-the-publication-of-parse-server-with-azure-managed-services/">Announcing the publication of Parse Server with Azure Managed Services</a>. Don’t miss the <a href="https://azure.microsoft.com/marketplace/partners/microsoft/parseserver/">free DocumentDB limited introductory offer</a>.
<h3><a href="https://shellmonger.com/?s=30+days+of+zumo">30 Days of Zumo.v2 blog series</a></h3>
In an homage to Josh Twist’s classic blog series on Mobile Services, Mobile Apps expert Adrian Hall has embarked on a very interesting and informative series on Mobile Apps: <a href="https://shellmonger.com/?s=30+days+of+zumo">30 Days of Zumo.v2</a>. Rather than rehashing the <a href="https://azure.microsoft.com/documentation/services/app-service/mobile/">existing docs</a>, this series swerves off-road and delves into areas currently not too well documented. Very worth a read, and remember to check there for answers to your Mobile Apps questions.

&nbsp;

That’s it for this installment, cheers!
<h5>Glenn Gailey</h5>]]></content:encoded>
    </item>
    <item>
      <title>Adding push notification tags from the client--Node.js backend version</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/adding-push-notification-tags-from-a-node-js-backend</link>
      <pubDate>Thu, 14 Apr 2016 18:46:18 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/?p=1005</guid>
      <description><![CDATA[In my previous post, I showed how you can enable an Azure Mobile Apps client to add tags to a push...]]></description>
      <content:encoded><![CDATA[In my <a href="https://blogs.msdn.microsoft.com/writingdata_services/2016/01/22/adding-push-notification-tags-from-an-azure-mobile-apps-client/">previous post</a>, I showed how you can enable an Azure Mobile Apps client to add tags to a push notification registration using the installation ID available on the client. While fairly popular, my original post was only for a .NET backend mobile app, and I got lots of requests to show an equivalent was to do the same in a Node.js backend.
<blockquote><strong>NOTE:</strong> I’m also keeping an eye on <a href="https://github.com/Azure/azure-mobile-apps-node/issues/241">an issue that the team is working on</a> to whitelist tags so that clients can supply a set of pre-defined safe tags during registration. When that finally gets done, I will blog about it as it should be a bit easier than this, and not require an additional round-trip to the backend to add tags.</blockquote>
I finally had a chance to create a similar custom API in a Node.js backend Mobile App, with the goal of being able to have an identical API call to the .NET backend, where the POST request looks like this:
<pre class="brush: text; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">POST https://todolist.azurewebsites.net/api/updatetags/f211a45f-6f6d-4189-b106-e534af999fff HTTP/1.1
Host: todolist.azurewebsites.net
Content-Type: application/json
ZUMO-API-VERSION: 2.0.0
Content-Length: 20

["test","broadcast"]</pre>
In the express.js app, the following POST method implementation defines a custom router that handles this request and adds tags to the given installation (remember that an installation is a push registration tagged with the client’s installation ID):
<pre class="prettyprint">// Define a POST operation that updates installation tags. 
router.post('/:id', function (request, response) {
	
	// Get the notification hub used by the mobile app.
	var push = request.azureMobile.push;
	var installationId = request.params.id;

	// Get the tags array from the request message.
	var tags = request.body;

	// Validate for and block any SID tags.
	for (i = 0; i &lt; tags.length; i++) {
		if (tags[i].search("sid:") !== -1) {
				response.status(403)
				.send("You cannot set '" + tags[i] + "' as a tag.");
				return;
		}
	}
	
	// Define an update tags operation.
	var updateOperation = [{
		"op": "add",
		"path": "/tags",
		"value": tags.toString()
	}];		
	
	// Update the installation to add the new tags.
	push.patchInstallation(installationId, updateOperation, function(error, res){
		if(error){
			logger.error('An error occurred when adding tags', error);
			response.status(error.statusCode).send(error.detail);
		}
		else{
			response.status(200).send(tags);
		}
	});		
});</pre>
Note that this code validates the client-supplied tags to make sure a user ID isn’t being supplied, to prevent a user from getting push data for another user.

Just for completeness, here’s also the GET method that returns tags for a given registration:
<pre class="prettyprint">// Define GET operation that returns tags for an installation. 
router.get('/:id', function (request, response) {
	// Get the notification hub used by the mobile app.
	var push = request.azureMobile.push;
	var installationId = request.params.id;
	
	push.getInstallation(installationId, function(error, installation, res){
		if (error){					
			// Log the error and send an error response.
			logger.error('An error occurred when retrieving installation', error);
			response.status(error.statusCode).send(error.detail);					
		}
		else{
			// Return an array of current tags.
			response.json(installation.tags);	
		}				
	});
});</pre>
In particular, I wanted to keep the parameterized routes that I had in the .NET backend mobile app. Because of this, I wasn’t able to use the nice convenient JSON-based pattern for defining custom APIs in the /api subfolder. Instead, I ended-up having to use an express.js Router object to define my parameterized routes. Because I did this in a separate file in the <em>./api </em>subfolder, I needed to expose my router as a module, which I consumed in the main app. Here’s how my router module is defined, without all the function code from above:

var express = require('express'); // Create an express.js router for our custom API. var router = express.Router(); // Define a POST operation that updates installation tags. router.post('/:id', function (request, response) { … }); // Define GET operation that returns tags for an installation. router.get('/:id', function (request, response) { …

}); module.exports = router;

Then, in the app itself, I added this <code>app.use()</code> reference to hook-up to the <code>./api/udatetags</code> route:
<pre class="prettyprint">app.use(mobileApp);    
// Add the router module on the custom API endpoint. 
app.use('/api/updatetags', require('./api/UpdateTags.js'));
app.listen(process.env.PORT || 3000);   // Listen for requests.</pre>
That’s all there is. I am planning on including this custom API and routing in the Node.js version of the quickstart completed project, which I hope to publish this week. Note that I’m not a Node.js guru, so if you have suggested improvements to my code, please let me know in the comments.

Cheers!
<h4>Glenn Gailey</h4>]]></content:encoded>
    </item>
    <item>
      <title>Microsoft acquires Xamarin, plus Node.js backend GA, Cordova client beta, file upload, and more Mobile Apps goodness…</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/microsoft-acquires-xamarin-plus-node-js-backend-ga-cordova-client-beta-file-upload-and-more-mobile-apps-goodness</link>
      <pubDate>Wed, 24 Feb 2016 16:17:00 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/2016/02/24/microsoft-acquires-xamarin-plus-node-js-backend-ga-cordova-client-beta-file-upload-and-more-mobile-apps-goodness/</guid>
      <description><![CDATA[Lots of great stuff has been happening with Azure Mobile Apps and around Microsoft in the past month...]]></description>
      <content:encoded><![CDATA[<p>Lots of great stuff has been happening with Azure Mobile Apps and around Microsoft in the past month or so, particularly around new content and samples. Note that Mobile Apps samples are now beginning to show-up in the <a href="https://azure.microsoft.com/en-us/documentation/samples/?service=app-service\mobile">Azure Samples gallery</a>. <br />Remember to keep an eye on both the <a href="https://azure.microsoft.com/en-us/blog/topics/mobile/">Azure blog</a> and <a href="https://azure.microsoft.com/en-us/updates/?service=app-service">App Service updates</a>&hellip;.</p>
<h2><a href="http://weblogs.asp.net/scottgu/welcoming-the-xamarin-team-to-microsoft">Microsoft acquiring Xamarin</a></h2>
<p>Hot off the presses&hellip;.As ScottGu writes <a href="http://weblogs.asp.net/scottgu/welcoming-the-xamarin-team-to-microsoft">in his blog today</a>, an excellent marriage is finally going to happen with Microsoft agreeing to purchase Xamarin. This is great news for .NET app developers, and something that many have long expected, wished for.</p>
<h2><a href="https://azure.microsoft.com/en-us/updates/general-availability-node-js-sdk-for-azure-mobile-apps-2-0-0/">Mobile Apps Node.js backend declared GA</a></h2>
<p>A great milestone for the Node.js backend version of Mobile Apps as the JavaScript-based backend reaches the &ldquo;general availability&rdquo; milestone. You can <a href="https://www.npmjs.com/package/azure-mobile-apps">get it now on npm</a>.</p>
<p>All of the Mobile Apps tutorials now have both .NET backend and Node.js backend examples. There is also guidance for working with the <a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-node-backend-how-to-use-server-sdk/">Node.js backend SDK</a>. If you are still using Mobile Services because you loved the Node.js backend, the time to <a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-node-backend-upgrading-from-mobile-services/">upgrade to Mobile Apps</a> is now.</p>
<h2><a href="https://azure.microsoft.com/en-us/blog/announcing-the-beta-apache-cordova-plugin-for-azure-app-service-mobile-apps/">New Cordova client support for Mobile Apps</a></h2>
<p>For those of you who have been waiting patiently for Cordova support in Mobile Apps, great news. A <a href="https://azure.microsoft.com/en-us/blog/announcing-the-beta-apache-cordova-plugin-for-azure-app-service-mobile-apps/">beta Cordova client plugin is now available</a>. Even better, this is the first official Azure Cordova client that has support for WNS, so you can send push notifications to your Cordova app running on a Windows app using WNS. At this point, we have the <a href="https://azure.microsoft.com/documentation/articles/app-service-mobile-cordova-get-started/">core tutorials</a> (focused on Android for now) and a <a href="https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-cordova-how-to-use-client-library/">client SDK topic</a>.</p>
<h2><a href="https://azure.microsoft.com/en-us/blog/file-management-with-azure-mobile-apps/">Upload files to Mobile Apps</a></h2>
<p>You obviously can&rsquo;t store blob data (image/audio/video files) in the same database as regular mobile data. Mobile Apps now makes storing blobs a much more integrated and turnkey process than in the past, including support for offline sync. Check out the <a href="https://aka.ms/mobq5u">new tutorial for file upload</a>, as well as the <a href="https://azure.microsoft.com/en-us/documentation/samples/app-service-mobile-dotnet-todo-list-files/">sample project</a>.</p>
<h2><a href="https://azure.microsoft.com/documentation/samples/?term=quickstart-completed">Quickstart completed samples</a></h2>
<p>Folks have been asking for years for us to publish the finished versions of the TodoList sample project featured in all of the Mobile Apps and Mobile Services tutorials. We have now published what I call &ldquo;quickstart completed&rdquo; Mobile Apps samples for a <a href="https://azure.microsoft.com/documentation/samples/app-service-mobile-dotnet-backend-quickstart/">.NET backend</a> with <a href="https://azure.microsoft.com/documentation/samples/app-service-mobile-windows-quickstart/">Windows</a> and <a href="https://azure.microsoft.com/documentation/samples/app-service-mobile-xamarin-android-quickstart/">Xamarin.Android</a> clients. Of particular interest are the implementation decisions that were made when implementing offline, auth, and push at the same time. There are also some real-world extensions made in these project, like enabling the clients to add tags to their push registrations.</p>
<h2><a href="https://azure.microsoft.com/blog/azure-welcomes-parse-developers/">Parse server on Azure App Service</a></h2>
<p>OK, this one&rsquo;s not technically new, since I blogged about it <a href="http://blogs.msdn.com/b/writingdata_services/archive/2016/02/01/use-the-deploy-to-azure-button-for-parse-server.aspx">last time</a>&mdash;just wanted to include it for completeness sake. I should also mention that while the officially supported guidance for migrating Parse notifications to Azure Notification Hubs is still in the works, <a href="http://www.amiturgman.com/blog-1/2016/2/13/migrating-parse-push-notifications-to-azure-notification-hubs">this post</a> can help you get started now with Hubs (for those who can&rsquo;t wait).</p>
<p>That&rsquo;s all for now&hellip;</p>
<p>Cheers!</p>
<h5>Glenn Gailey</h5>]]></content:encoded>
    </item>
    <item>
      <title>Use the Deploy to Azure Button for your Parse Migration</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/use-the-deploy-to-azure-button-for-your-parse-migration</link>
      <pubDate>Mon, 01 Feb 2016 22:09:00 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/2016/02/01/use-the-deploy-to-azure-button-for-your-parse-migration/</guid>
      <description><![CDATA[I was thrilled to have participated in assembling the recent guidance to help Parse-hosted app...]]></description>
      <content:encoded><![CDATA[<p>I was thrilled to have participated in assembling the recent guidance to help Parse-hosted app developers move their cloud code and data to Azure, including authoring the very popular post <a href="https://azure.microsoft.com/en-us/blog/azure-welcomes-parse-developers/">Azure welcomes Parse developers</a>. This guidance was the culmination, starting with the <a href="http://blog.parse.com/announcements/moving-on/" target="_blank">shocking announcement</a> about Facebook&rsquo;s shutting-down Parse, of a wild weekend working with some very smart developers on the Azure App Service team to get the Parse server running seamlessly on Azure App Service.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/0218.image_3CB4C4E7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/0218.image_5F00_3CB4C4E7.png"><img style="background-image: none; float: right; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/8787.image_thumb_3C4891F2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/8787.image_5F00_thumb_5F00_3C4891F2.png" alt="image" width="167" height="40" align="right" border="0" /></a>While I was happy with the post overall, there was one nifty bit of work that didn&rsquo;t get featured. As part of the effort, the team created a App Service deployment template, which is basically a hosted site for creating a new app service and deploying the Parse server from the GitHub repo to the new site all in a single step. (If you recall, creating a new app service took quite a few steps.) This deployment is triggered by the <strong>Deploy to Azure</strong> button, which you may have seen in other samples in the Azure repos. If you were wondering, the deployment is powered by <a href="https://azure.microsoft.com/en-us/documentation/articles/resource-group-overview/">Azure Resource Manager</a>.</p>
<p>One of the best parts about the deploy button is that you can even pick the pricing tier for the newly created App Service plan as part of the template. Basically, the deploy button replaces these three manual sections in the <a href="https://azure.microsoft.com/en-us/blog/azure-welcomes-parse-developers/" target="_blank">original blog post</a>:</p>
<ul>
<li><strong>Create a new backend in App Service</strong></li>
<li><strong>Clone the Parse server repo and deploy to Azure</strong></li>
<li><strong>Configure the backend</strong></li>
</ul>
<p>Here&rsquo;s the streamlined procedure using the Deploy to Azure button:</p>
<ol>
<li>Fork the <a href="https://github.com/Azure/parse-server-example">Azure Parse server example</a> project in GitHub into your GitHub account, then click <strong>Deploy to Azure</strong>. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/8360.image_20A3C98E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/8360.image_5F00_20A3C98E.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/3173.image_thumb_20379699.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/3173.image_5F00_thumb_5F00_20379699.png" alt="image" width="364" height="121" border="0" /></a> <br />This displays the Deploy to Azure wizard.</li>
<li>Complete the deployment template to create a new resource group. Choose a meaningful <strong>Site Name</strong> and <strong>Resource Group Name</strong> for your new web app, then click <strong>Next</strong>. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/5224.image_74F2FF91.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/5224.image_5F00_74F2FF91.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/8688.image_thumb_4DB8B65C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/8688.image_5F00_thumb_5F00_4DB8B65C.png" alt="image" width="484" height="419" border="0" /></a>&nbsp; <br />In this template, SKU determines the pricing tier for the App Service plan for your resource group. Also, when you supply <strong>Mongo Connection String</strong>, <strong>Parse App ID</strong> and <strong>Parse Master Key</strong> values in this template, they become environment variables stored securely in App Service (not on your local machine or in a repo).</li>
<li>The deployment template confirms that you you are about to create and deploy a new web app based on the Parse server example repo. When you are ready, click <strong>Deploy</strong>. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/0777.image_695D4252.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/0777.image_5F00_695D4252.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/8204.image_thumb_7B39D61F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/8204.image_5F00_thumb_5F00_7B39D61F.png" alt="image" width="484" height="272" border="0" /></a> <br />That&rsquo;s it!</li>
<li>After deployment completes successfully, you will see the URL for your new service. Click <strong>Manage</strong> to navigate to your new backend in the <a href="https://portal.azure.com/">Azure portal</a>. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/2248.image_0D55D8EF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/2248.image_5F00_0D55D8EF.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/1667.image_thumb_08DF5828.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/1667.image_5F00_thumb_5F00_08DF5828.png" alt="image" width="484" height="263" border="0" /></a></li>
<li>Click <strong>All settings </strong>&gt; <strong>Application settings</strong> and scroll down the in the Application settings blade to <strong>App settings</strong>. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/3731.image_53D2C8F7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/3731.image_5F00_53D2C8F7.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/8623.image_thumb_0F9261AB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/8623.image_5F00_thumb_5F00_0F9261AB.png" alt="image" width="484" height="238" border="0" /></a> <br />Notice that the MongoDB and Parse keys you provided earlier are now are stored as app settings.</li>
</ol>
<p>At this point, you can go back to the main procedure starting with <strong>Try out the Hello World</strong>. If you find any issues using the deployment button, please let the Azure team in in the <a href="https://social.msdn.microsoft.com/forums/azure/en-US/home?forum=azuremobile">Mobile forums</a>.</p>
<p>Even cooler is that the Deploy to Azure button got accepted into the main <a href="https://github.com/ParsePlatform/parse-server-example">ParsePlatform/parse-server-example</a> repo:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/5808.image_6B00D426.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/5808.image_5F00_6B00D426.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/1373.image_thumb_7CDD67F3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/1373.image_5F00_thumb_5F00_7CDD67F3.png" alt="image" width="484" height="354" border="0" /></a></p>
<p>This is pretty great stuff, and it&rsquo;s awesome that it came together so fast. I&rsquo;ve traditionally been mostly a .NET developer, but I have to say that there is something about an open and collaborative platform like Node.js where it seems like things can just get done faster.</p>
<p>Cheers!</p>
<h5>Glenn Gailey&nbsp; <!--EndFragment--></h5>]]></content:encoded>
    </item>
    <item>
      <title>Adding push notification tags from an Azure Mobile Apps client</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/adding-push-notification-tags-from-an-azure-mobile-apps-client</link>
      <pubDate>Fri, 22 Jan 2016 09:26:13 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/2016/01/22/adding-push-notification-tags-from-an-azure-mobile-apps-client/</guid>
      <description><![CDATA[When a mobile app registers for push notifications using an Azure App Service Mobile Apps backend,...]]></description>
      <content:encoded><![CDATA[<p>When a mobile app registers for push notifications using an Azure App Service Mobile Apps backend, there are two default <a href="https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-routing-tag-expressions/">tags</a> that can get added to the registration in Azure Notification Hubs: the installation ID, which is unique to the app on a given device, and the user ID, which is only added when the user has been previously authenticated. Any other tags that get supplied by the client are ignored, which is by design. (Note that this differs from Mobile Services, where the client could supply any tag and there were hooks into the registration process on the backend to validate tags on incoming registrations.) </p>  <p>Because the client can’t add tags and at the same time there is not service-side hooks into the push notification registration process, the client needs to do the work of adding new tags to a given registration. To let the client supply tags, we need to add an API to our mobile app backend that the client to call to add tags.</p>  <p>Before we dive into creating a new custom API, let’s briefly discuss the new <em>installation ID</em> concept, which is key to the whole thing. Also note that this post uses a .NET backend, but the same principles apply for a node.js backend.</p>  <h3>Introducing InstallationId</h3>  <p>The Mobile Apps client library now defines an installation ID, which didn’t exist in Mobile Services. The installation ID is a GUID that is specific to an installed app on a given mobile device, to the point that when you uninstall and reinstall the app on the same device you get a new GUID. The installation ID can be obtained from the Mobile client API, as follows:</p>  <pre class="brush: csharp; auto-links: true; collapse: false; first-line: 1; gutter: true; highlight: [2]; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">MobileServiceClient.InstallationId;</pre>

<p>This same API exists in the Mobile Apps library on all client device platforms. How this works is that when the client registers for push notifications with Notification Hubs (through the Mobile Apps client), this installation ID is added automatically as a tag. This tag is then used as an index into a specific registration, and the Notification Hubs client has new APIs that let you work with registrations based on this value.&#160; Here is what an installation ID tag value looks like: </p>

<pre class="brush: js; auto-links: true; collapse: false; first-line: 1; gutter: true; highlight: [2]; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">$InstallationId:{9c105281-c188-44b8-b1b5-8d08725c4785}</pre>

<p>When working with the Notification Hubs client, all you will need is the GUID value, which you get from the <strong>MobileServiceClient</strong>.</p>

<h3>The UpdateTags controller</h3>

<p>To enable the client to add tags to its registration, the first thing I did was create a new <strong>ApiController</strong> named <strong>UpdateTagsController</strong> in my Mobile App backend, and in the initializer I added the standard code that creates the <strong>NotificationHubClient</strong> instance based on the hub used by my Mobile App backend:</p>

<pre class="brush: csharp; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">private NotificationHubClient hubClient;

protected override void Initialize(HttpControllerContext controllerContext)
{
    base.Initialize(controllerContext);

    // Get the Mobile App settings.
    MobileAppSettingsDictionary settings =
        this.Configuration.GetMobileAppSettingsProvider().GetMobileAppSettings();

    // Get the Notification Hubs credentials for the Mobile App.
    string notificationHubName = settings.NotificationHubName;
    string notificationHubConnection = settings
        .Connections[MobileAppSettingsKeys.NotificationHubConnectionString]<br />        .ConnectionString;

    // Create the notification hub client.
    hubClient = NotificationHubClient
        .CreateClientFromConnectionString(notificationHubConnection, <br />            notificationHubName);
}</pre>

<p>Then I implemented a GET by ID method so that I could retrieve tags for a given installation ID:</p>

<pre class="brush: csharp; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">// GET api/UpdateTags/Id
[HttpGet]
public async Task&lt;List&lt;string&gt;&gt; GetTagsByInstallationId(string Id)
{
    try
    {
        // Return the installation for the specific ID.
        var installation =  await hubClient.GetInstallationAsync(Id);
        return  installation.Tags as List&lt;string&gt;;
    }
    catch(MessagingException ex)
    {
        throw ex;
    }
}</pre>

<p>In my scenario, the client didn’t really need to use this, but it would be useful to inspect existing tags, and I did use it when checking tags using a REST client, like fiddler. Here’s the HTTP GET request to the new API:</p>

<pre class="brush: csharp; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">GET https://todolist.azurewebsites.net/api/updatetags/9c105281-c188-44b8-b1b5-8d08725c4785 HTTP/1.1
User-Agent: Fiddler
Host: todolist.azurewebsites.net
ZUMO-API-VERSION: 2.0.0</pre>

<p>Then you get back the existing tags:</p>

<pre class="brush: csharp; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 82
Content-Type: application/json; charset=utf-8
Expires: 0
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET
Date: Wed, 20 Jan 2016 21:13:15 GMT

[&quot;_UserId:sid:4fce9655d0610c53a1f236ae7befc14x&quot;]</pre>

<p>Note that the only tag returned is the user ID, because this registration we done with a logged-in user. The installation ID isn’t returned by the API, but you can see it there by using the Server Explorer in Visual Studio: </p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/3022.image_258E4172.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/3022.image_5F00_258E4172.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/5516.image_thumb_40C69A73.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/5516.image_5F00_thumb_5F00_40C69A73.png" width="604" height="276" /></a></p>

<p>If your app needs to send notifications to a specific device, you probably want to store the installation ID from your user along with the user ID or some other tracking data in your backend.</p>

<h3>Adding new tags: the POST method</h3>

<p>The method mapped to the POST request expects a JSON array of tags from the client, which get added to the registration for a given installation ID. (If the input is not a valid JSON array, an exception returns an HTTP 500.) A single <a href="https://msdn.microsoft.com/en-us/library/azure/microsoft.azure.notificationhubs.partialupdateoperation.aspx">PartialUpdateOperation</a> in a list contains the <strong>JArray</strong> of tags to be added (you can only have one tags operation in a given request to <a href="https://msdn.microsoft.com/en-us/library/azure/microsoft.azure.notificationhubs.notificationhubclient.patchinstallationasync.aspx">PatchInstallationAsync()</a>. </p>

<pre class="brush: csharp; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">// POST api/UpdateTags/Id
[HttpPost]
public async Task&lt;HttpResponseMessage&gt; AddTagsToInstallation(string Id)
{
    // Get the tags to update from the body of the request.
    var message = await this.Request.Content.ReadAsStringAsync();

    // Validate the submitted tags.
    if (string.IsNullOrEmpty(message) || message.Contains(&quot;sid:&quot;))
    {
        // We can't trust users to submit their own user IDs.
        return new HttpResponseMessage(HttpStatusCode.BadRequest);
    }

    // Verify that the tags are a valid JSON array.
    var tags = JArray.Parse(message);

    // Define a collection of PartialUpdateOperations. Note that 
    // only one '/tags' path is permitted in a given collection.
    var updates = new List&lt;PartialUpdateOperation&gt;();

    // Add a update operation for the tag.
    updates.Add(new PartialUpdateOperation
    {
        Operation = UpdateOperationType.Add,
        Path = &quot;/tags&quot;,
        Value = tags.ToString()
    });

    try
    {
        // Add the requested tag to the installation.
        await hubClient.PatchInstallationAsync(Id, updates);

        // Return success status.
        return new HttpResponseMessage(HttpStatusCode.OK);
    }
    catch(MessagingException)
    {
        // When an error occurs, return a failure status.
        return new HttpResponseMessage(HttpStatusCode.InternalServerError);
    }
}</pre>

<table cellspacing="0" cellpadding="2" width="516" border="1"><tbody>
    <tr>
      <td valign="top" width="514"><font color="#c0504d"><strong>Important:</strong> there is currently a bug where attempting to add a tag that starts with whitespace causes all tags to be removed from the registration, including the installation ID. This is pretty bad, so until we get it fixed you may want to trim tags that are supplied by end users.</font></td>
    </tr>
  </tbody></table>

<p>Here is an example of calling the POST method directly using a REST client, like Fiddler:</p>

<pre class="brush: csharp; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">POST http://todolist.azurewebsites.net/api/updatetags/9c105281-c188-44b8-b1b5-8d08725c4785 HTTP/1.1
User-Agent: Fiddler
Host: localhost:51795
ZUMO-API-VERSION: 2.0.0
Content-Length: 20

['broadcast','test']</pre>

<p>Next we will see how to call this new API from a .NET client app.</p>

<h3>Calling the new API from the client</h3>

<p>With the new API tested and published, it’s very easy to call it from the client app after registration is complete. The following code example calls <strong>InvokeApiAsync()</strong> on the <strong>MobileServiceClient</strong> after registration succeeds to send a two tag update request to the <font face="Courier New">/api/updatetags/&lt;installation_id&gt;</font> endpoint:</p>

<pre class="brush: csharp; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">// Register for template push notifications.
await App.MobileService.GetPush()
.RegisterAsync(channel.Uri, templates);

// Define two new tags as a JSON array.
var body = new JArray();
body.Add(&quot;broadcast&quot;);
body.Add(&quot;test&quot;);

// Call the custom API '/api/updatetags/&lt;installationid&gt;' 
// with the JArray of tags.
var response = await App.MobileService
    .InvokeApiAsync(&quot;updatetags/&quot; 
    + App.MobileService.InstallationId, body);</pre>

<p>Now, you can send notifications only to specific devices depending on the registered tags. </p>

<h3>Final thoughts </h3>

<p>Well, that’s all there is to adding tags from to a registration using the installation ID from the client. Pretty easy stuff. Although you do need a valid installation ID to successfully call these APIs, you might want to also <a href="https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-dotnet-backend-how-to-use-server-sdk/#add-auth">require authentication</a>, just to keep any malicious users from trying to add tags using some randomly guessed installation ID. </p>

<p>Cheers!</p>

<h5>Glenn Gailey</h5>]]></content:encoded>
    </item>
    <item>
      <title>How to clone a JavaScript backend Mobile Service</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/how-to-clone-a-javascript-backend-mobile-service</link>
      <pubDate>Tue, 15 Dec 2015 11:24:55 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/2015/12/15/how-to-clone-a-javascript-backend-mobile-service/</guid>
      <description><![CDATA[The Azure Mobile folks state very clearly that you shouldn’t use a production instance of Azure...]]></description>
      <content:encoded><![CDATA[<p>The Azure Mobile folks state very clearly that you shouldn’t use a production instance of Azure Mobile Services to test out new functionality, which makes sense. However, this brings up an interesting question from a customer: “How do I create a clone of my existing mobile service to do testing and development?” </p>  <p>A JavaScript backend mobile service has essentially two parts: the node.js site and code that hooks that site to the Mobile Services runtime and Azure SQL Database. The node.js site files (script files, permissions, custom API endpoints) are easy to clone because they are defined in the site itself. Other actions, like creating the mobile service itself and tables within the mobile service, must either be done in the <a href="https://manage.windowsazure.com/">Azure classic portal</a> or by using the command line interface (CLI). So, if you really want to automate the process of cloning and syncing a production and staging site, you will use the CLI and Git. </p>  <h2>Configure the Git repo</h2>  <p>Since we need to pull down the production site and copy those files to our new staging site, we need to make sure that Git publishing is configured on the mobile service. Complete the following steps with your production site:</p>  <ol>   <li><a href="https://azure.microsoft.com/en-us/documentation/articles/mobile-services-store-scripts-source-control/#enable-source-control">Enable source control in your mobile service</a>.&#160; </li>    <li><a href="https://azure.microsoft.com/en-us/documentation/articles/mobile-services-store-scripts-source-control/#clone-repo">Install Git and create the local repository</a>. </li> </ol>  <p>Note that you only need to configure Git publishing once for your subscription. At this point, you should have pulled the production site down to the Git repo on your local machine.</p>  <h2>Create the cloned mobile service</h2>  <p>You need to create a new mobile service (such as <em>todolist-clone</em>) and recreate the same tables that you have in the production site. You can do this either in the <a href="https://manage.windowsazure.com/">portal</a> or by using the CLI, like this:</p>  <ol>   <li>Create the mobile service clone:      <pre class="brush: shell; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">azure mobile create todolist-clone &lt;server-admin&gt; &lt;server-password&gt;</pre>
  </li>

  <li>Re-create the same tables (once for each existing table): 
    <pre class="brush: shell; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">azure mobile table create todolist-clone TodoItem</pre>
  </li>
</ol>

<h2>Overwrite the cloned mobile service and publish</h2>

<p>Once the new cloned service is configured, you can copy over from the production site and republish:</p>

<ol>
  <li><a href="https://azure.microsoft.com/en-us/documentation/articles/mobile-services-store-scripts-source-control/#clone-repo">Use Git to also create a local repository for the cloned site.</a> 

    <br />Note that your credentials are the same as the first time—since they are shared across the subscription. </li>

  <li>On your local machine, copy files from the <em>\service</em> subdirectory of the original production repo (todolist) to the same local directory in the new repo (todolist-clone). </li>

  <li>Open the package.json file in the root of the cloned repo and update the <strong>name</strong> field to the name of the clone, as below: 

    <pre class="brush: js; auto-links: true; collapse: false; first-line: 1; gutter: true; highlight: [2]; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">{
  <strong>&quot;name&quot;: &quot;todolist-clone&quot;</strong>,
  &quot;version&quot;: &quot;1.0.0&quot;,
  &quot;description&quot;: &quot;todolist-cordova - hosted on Windows Azure Mobile Services&quot;,
  &quot;main&quot;: &quot;server.js&quot;,
  &quot;engines&quot;: {
    &quot;node&quot;: &quot;&gt;= 0.8.19&quot;
  },
  &quot;dependencies&quot;: {
	&quot;node-uuid&quot;: &quot;~1.4.3&quot;
  },
  &quot;devDependencies&quot;: {},
  &quot;scripts&quot;: {},
  &quot;author&quot;: &quot;unknown&quot;,
  &quot;licenses&quot;: [],
  &quot;keywords&quot;:[]
}</pre>
  </li>

  <li>Save the changes and execute the following commands in the new repo to add/commit/publish changes: 
    <pre class="brush: js; auto-links: true; collapse: false; first-line: 1; gutter: true; highlight: [2]; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">git add .</pre>

    <pre class="brush: js; auto-links: true; collapse: false; first-line: 1; gutter: true; highlight: [2]; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">git commit -a -m &quot;cloned the site&quot;</pre>

    <pre class="brush: js; auto-links: true; collapse: false; first-line: 1; gutter: true; highlight: [2]; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">git push origin master</pre>
  </li>
</ol>

<p>At this point, the mobile service will be restarted and you should see your production APIs, script files, and permissions in the new cloned mobile service. Note that you won’t see your existing data, since the cloned service uses tables in a new DB schema that matches the service name (in this case <em>todolist_clone</em>). </p>

<p> Hope that this is helpful….</p>

<p>Cheers!</p>

<h5>Glenn Gailey</h5>]]></content:encoded>
    </item>
    <item>
      <title>Updates to My Cordova Push Sample and new Cordova Push Plugin</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/updates-to-my-cordova-push-sample-and-new-cordova-push-plugin</link>
      <pubDate>Wed, 28 Oct 2015 10:19:00 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/2015/10/28/updates-to-my-cordova-push-sample-and-new-cordova-push-plugin/</guid>
      <description><![CDATA[UPDATE (11/3/2015): The updates to my Cordova push notification sample has been merged into the...]]></description>
      <content:encoded><![CDATA[<p><strong>UPDATE</strong> (11/3/2015): The updates to my Cordova push notification sample has been merged into the <a href="https://github.com/Azure/mobile-services-samples/tree/master/CordovaNotificationsArticle">source fork of the Mobile Services samples GitHub repo</a>.</p>
<p>As folks may remember, I published a Cordova push notifications sample for Azure to support my MSDN Magazine article: <a href="https://msdn.microsoft.com/en-us/magazine/dn879353.aspx">Microsoft Azure - Push Notifications to Cordova Apps with Microsoft Azure</a>. It has been almost a year since I wrote that article (which was published in Jan 2015), and since then the article has gone out of date. Being used to writing for MSDN or azure.com, I was saddened to realize that I am not able to update this MSDN Magazine article as I can most other content on a microsoft.com web property. Fortunately, I am still able to update the sample project itself, which I have now done.</p>
<h4>Updating the Project to Visual Studio 2015</h4>
<p>The original sample (and article) was created using Apache Cordova Tools for Visual Studio 2013, which is no longer the happy path for Cordova apps using Visual Studio. There have been some significant (and breaking) changes to Cordova tools between 2013 and 2015, including re-rationalizing the Cordova project to become much more of a standard Cordova project, which you can now build using conventional Cordova command line tools. In fact, there are lots of CI options for VS Cordova projects now, as you can read about <a href="http://taco.visualstudio.com/en-us/docs/get-started-vs-tools-apache-cordova/">in the docs</a>.</p>
<p>Anyway, I updated my project to Visual Studio 2015 and it&rsquo;s now merged into <a href="https://github.com/azure/mobile-services-samples/tree/master/CordovaNotificationsArticle">the Mobile Services&nbsp;sample repository.</a></p>
<h4>There&rsquo;s a Cool New Push Plugin for Cordova/PhoneGap</h4>
<p>While updating the sample, I discovered that the classic PushPlugin we&rsquo;ve all been using to support push notifications on Cordova has been deprecated. There&rsquo;s now a new push plugin, which you can find here: <a title="https://github.com/phonegap/phonegap-plugin-push" href="https://github.com/phonegap/phonegap-plugin-push">https://github.com/phonegap/phonegap-plugin-push</a></p>
<p>Needless to say, when I discovered this I also updated the sample to use this most recent (and supported) push plugin. I was happy to discover that the new plugin is much more platform agnostic than the old one way. By switching to the new plugin, I was also able to reduce the amount of code required for push by about 40% (103 lines to 61 lines of code). For example, here&rsquo;s the code that initializes the plugin and requests the handle from either APNS or GCM:</p>
<pre class="brush: js; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">pushNotification = PushNotification.init({
    "android": { "senderID": GCM_SENDER_ID },
    "ios": { "alert": "true", "badge": "false", "sound": "false" }
});</pre>
<p>(Note that WNS is also supported by the plugin (just also pass <span style="font-family: Courier New;">"windows": {}</span> to the <strong>init</strong> function), it&rsquo;s just not supported by the Mobile Services plugin.)</p>
<p>The new plugin is event based, so you simply register for the <strong>registration</strong> and <strong>notification</strong> events. The registration handler is where you register with Notification Hubs using the handle. My client code here is still platform-specific because of the Mobile Services plugin:</p>
<pre class="brush: js; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">pushNotification.on('registration', function (data) {
    // Get the native platform of the device.
    var platform = device.platform;
    // Get the handle returned during registration.
    var handle = data.registrationId;
    // Set the device-specific message template.
    if (platform == 'android' || platform == 'Android') {
        // Template registration.
        var template = '{ "data" : {"message":"$(message)"}}';
        // Register for notifications.
        mobileServiceClient.push.gcm.registerTemplate(handle,
            'myTemplate', template, null)
            .done(registrationSuccess, registrationFailure);
    } else if (device.platform === 'iOS') {
        // Template registration.
        var template = '{"aps": {"alert": "$(message)"}}';
        // Register for notifications.            
        mobileServiceClient.push.apns.registerTemplate(handle,
            'myTemplate', template, null)
            .done(registrationSuccess, registrationFailure);
    }
});</pre>
<p>(There&rsquo;s also a platform agnostic <a href="https://github.com/sgrebnov/cordova-plugin-azure-notificationhub">Cordova plugin for Notification Hubs</a>, but it doesn&rsquo;t support templates, which is a really nice to have for Cordova apps. <img class="wlEmoticon wlEmoticon-sadsmile" style="border-style: none;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/1134.wlEmoticon-sadsmile_37BADAD4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/1134.wlEmoticon_2D00_sadsmile_5F00_37BADAD4.png" alt="Sad smile" />)</p>
<p>In my sample, the notification event is handled the same way on all platforms:</p>
<pre class="brush: js; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">pushNotification.on('notification', function (data) {
    // Display the alert message in an alert.
    alert(data.message);
    // Reload the items list.
    app.Storage.getData();
});</pre>
<p>There are other fields on data, depending on the platform itself&mdash;you can check out the <a href="https://github.com/phonegap/phonegap-plugin-push#api">push plugin documentation</a> for more info.</p>
<p><strong>Overall impression</strong>: I&rsquo;m not a JavaScript guru, but using this new plugin seems to yield much cleaner and more manageable code.</p>
<h4>Whitelist Plugin is Now Required</h4>
<p>One final thing that I discovered (and what hung me up the longest) is that the latest version of Cordova won&rsquo;t connect to Azure using XHR requests. By working through the error messages, I figured out that I needed to use the <a href="https://github.com/apache/cordova-plugin-whitelist">Whitelist plugin</a> and define, via policies, what code can run and what remote requests are allowed. Basically, I has to add this code to my index.html page to enable the app to connect to my mobile service:</p>
<pre class="brush: js; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">&lt;meta http-equiv="Content-Security-Policy" 
        content="connect-src 'self' https://*.azure-mobile.net;"&gt;</pre>
<p>Hopefully, the updated sample will help get folks moving in the right direction again with Azure push notifications and Cordova apps.</p>
<p>Cheers!</p>
<h5>Glenn Gailey</h5>]]></content:encoded>
    </item>
    <item>
      <title>Making Sense of Cordova Push Notification Options and APIs</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/making-sense-of-cordova-push-notification-options-and-apis</link>
      <pubDate>Fri, 16 Oct 2015 01:17:00 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/2015/10/16/making-sense-of-cordova-push-notification-options-and-apis/</guid>
      <description><![CDATA[Update: (2/6/2016) Updated Mobile Apps support now that a Cordova client is available.
Updated:...]]></description>
      <content:encoded><![CDATA[<p><strong>Update:</strong> (2/6/2016) Updated Mobile Apps support now that a <a href="https://azure.microsoft.com/en-us/blog/announcing-the-beta-apache-cordova-plugin-for-azure-app-service-mobile-apps/">Cordova client is available</a>.</p>
<p><strong>Updated:</strong> (10/27/15) Corrected my assessment of the <a title="new push plugin" href="https://github.com/phonegap/phonegap-plugin-push">new push plugin</a>. You can read more about this&nbsp;plugin in my post <a href="http://blogs.msdn.com/b/writingdata_services/archive/2015/10/28/updates-to-my-cordova-push-sample-and-new-cordova-push-plugin.aspx">Updates to My Cordova Push Sample and new Cordova Push Plugin.</a></p>
<p><strong>Updated:</strong> (10/20/15) Added more information on sending push notifications from various backends.</p>
<p>The ways in which you can implement push notifications for Cordova apps can be confusing and a bit murky. This is because a) push notification architectures are somewhat complex, having both client and backend parts, and b) there&rsquo;s more platform native stuff to worry about than for most Cordova client apps. The <a href="https://msdn.microsoft.com/en-us/magazine/dn879353.aspx">article that I published in MSDN Magazine</a> only covered a small, simpler scenario with just Android. As such, I wanted to detail everything I know about the available options for implementing push notifications in a Cordova app in this blog post, including the following:</p>
<ul>
<li>Importance of the backend service (and why Azure is so worth trying).</li>
<li>Client libraries and plugins for push notification in Cordova apps.</li>
<li>Service-side APIs you can use for sending notifications.</li>
<li>Configuring a push notification topology (mostly using Azure).</li>
<li>Sending notification from the backend.</li>
</ul>
<p>Note that this post is point-in-time picture, and hopefully push notification support for Cordova apps (particularly the client plugins) will improve in the future.</p>
<h2>The Basic Push Notification Architecture</h2>
<p>While discussing push notifications options, libraries, etc., it&rsquo;s important to keep in mind the basic architecture and process flow of a push notification topology. For this, we&rsquo;ll turn to my favorite image courtesy of the <a href="https://acom-sandbox.azurewebsites.net/en-us/documentation/articles/notification-hubs-overview/">Azure Notification Hubs docs</a>:</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-width: 0px;" title="Notification Hubs" src="https://i-msdn.sec.s-msft.com/dynimg/IC702623.png" alt="Notification Hubs" width="576" height="275" border="0" /></p>
<p>When deciding what plugins and libraries to use, the important considerations are what backend service are you going to use and which client platforms you want to support in your Cordova app. Just as a reminder, these are the four primary platform-specific push notification services (PNS):</p>
<ul>
<li><strong>Apple Push Notification Service</strong> (APNS) &ndash; supports iOS devices.</li>
<li><strong>Google Cloud Messaging</strong> (GCM) &ndash; supports Android (but not Amazon Kindle) devices.</li>
<li><strong>Windows Notification Service</strong> (WNS) &ndash; supports Windows Store, universal Windows, and Windows Phone Store (&gt;8.1) devices.</li>
<li><strong>Microsoft Push Notification Service</strong> (MPNS) &ndash; supports Windows Phone 7 &amp; 8 (&ldquo;Silverlight&rdquo;) devices, and will not be supported going forward.</li>
</ul>
<h2 id="backend">Choosing a Backend Service</h2>
<p>The specific Cordova plugin and libraries that you will end up using will likely depend on the backend service that you choose, especially when the backend has built-in support for push notifications. This backend service must do the work of tracking the handles (tokens/channels) distributed by the PNS to a given device and sending notifications to a given device by using that handle. You can prop your own service to do this work, but then you do have to know how to talk to the major push services for Apple, Google, Microsoft, Amazon, etc.</p>
<p>While you could use any backend service to send push notifications to your Cordova app, there&rsquo;s a huge benefit to creating an Azure backend service or publishing your service to Azure&mdash;namely Azure Notification Hubs ( I discuss this in <a href="https://msdn.microsoft.com/en-us/magazine/dn879353.aspx">my MSDN Magazine article</a>). This Azure service, which you can not only use with Azure Mobile Services but with any Azure published service or on-premises service, is designed to work with all major PNS services. Notification Hubs does the &ldquo;heavy lifting&rdquo; of managing device handle registrations and makes it easy to send notification from various backend platforms, such as: ASP.NET (C#), Azure Mobile Services, PHP, and Node.js. You simply have to <a href="https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-android-get-started/#configure-a-new-notification-hub">configure each PNS with the notification hub</a>.</p>
<p>Because Mobile Services prides itself on being a more turnkey service for mobile apps, it also exposes registration APIs for push notifications, which are passed to the associated notification hub. You can access these registration APIs by using any Mobile Services client SDK, including the Cordova plugin.</p>
<h2 id="client-libraries">Client-side Libraries for Cordova Push Notifications</h2>
<p>There are four main Cordova client options that I have come across for registering a device with the PNS<sup>1</sup>, registering the handle with the backend service,<sup>2</sup> and handling incoming notifications<sup>4</sup> (note that these superscripts refer to specific steps from the above graphic). Most of these libraries are designed to work with a push topology that includes Azure Notification Hubs.</p>
<h4><a href="https://github.com/phonegap/phonegap-plugin-push">PushPlugin</a></h4>
<p>The original push notification plugin for Cordova, which does the basic work of requesting handles<sup>1</sup> and handling incoming notifications<sup>4</sup>, has been deprecated.&nbsp;&nbsp;(The new version of&nbsp;the plugin is much more platform agnostic; I was also able to reduce the amount of code required for push by about 40%.)<br />Use this plugin if you have created your own custom backend solution or when registering with Notification Hubs through Mobile Services.</p>
<ul>
<li><strong>Supports:</strong> APNS, GCM, WNS</li>
<li><strong>Pros:</strong> Supports all major platforms and is fairly platform-agnostic (at least from a client perspective).</li>
<li><strong>Cons: </strong>Doesn&rsquo;t talk to any backend services. You need to perform your own local storage of the handle. <!--EndFragment--></li>
</ul>
<h4><a href="https://github.com/sgrebnov/cordova-plugin-azure-notificationhub">Notification Hubs plugin</a></h4>
<p>This plugin was developed by MS Open Tech folks and it does the work of PushPlugin<sup>1,4</sup> in a much more platform agnostic way, and it stores the registration info locally. Plus, it also registers the device and handle with Azure Notification Hubs<sup>2</sup>. This is a good option for using Notification Hubs without a Mobile services backend.</p>
<ul>
<li><strong>Supports:</strong> APNS, GCM, WNS, MPNS</li>
<li><strong>Pros:</strong> Supports all major platforms. Single plugin integrates getting handles/tokens and registering (native) with Notification Hubs. Client code is platform agnostic (which is what you want from Cordova, right?).</li>
<li><strong>Cons:</strong> Doesn&rsquo;t support template registrations (which is a huge bummer for Cordova). Not yet in an official Azure project repo. Not integrated with the Mobile Services plugin.</li>
</ul>
<h4><a href="https://azure.microsoft.com/blog/announcing-the-beta-apache-cordova-plugin-for-azure-app-service-mobile-apps/">Mobile Apps Cordova client</a></h4>
<p>Azure App Service Mobile Apps&nbsp;now has (beta) Cordova support available, and&nbsp;is maintained by the Azure Mobile team. &nbsp;This plugin supports registering with Notification Hubs<sup>2</sup> and is the way that Microsoft Azure wants you to add push notifications to your Cordova app. Note that offline sync support will be added to the plugin before GA.</p>
<ul>
<li><strong>Supports:</strong> APNS, GCM, and WNS.&nbsp;</li>
<li><strong>Pros:</strong> Integrates with Mobile Apps to enable Notification Hubs registration<sup>2</sup>.</li>
<li><strong>Cons:</strong> You must use a Mobile Apps backend.</li>
</ul>
<h4><a href="https://github.com/Azure/azure-mobile-services-cordova">Mobile Services plugin</a></h4>
<p>The official Cordova plugin for Mobile Services supports registering with Notification Hubs<sup>2</sup>, but only for ANPS and GCM. It also stores the handles locally, but you still need to use PushPlugin.<sup>1, 4</sup> This is the scenario that I highlighted in <a href="https://msdn.microsoft.com/en-us/magazine/dn879353.aspx">my MSDN Magazine article</a>.</p>
<ul>
<li><strong>Supports:</strong> Only APNS and GCM</li>
<li><strong>Pros:</strong> Integrates with Mobile Services client to enable Notification Hubs registration<sup>2</sup>.</li>
<li><strong>Cons:</strong> Only supports APNS and GCM. Still requires PushPlugin.<sup>1, 4</sup></li>
</ul>
<h4><a href="https://github.com/Azure/mobile-services-samples/tree/master/TodoListNotifications">Mobiles Services Push Sample</a></h4>
<p>This was my first attempt at using push notifications with Mobile Services in a Cordova app, which I wrote back before the Mobile Services plugin existed. This sample includes my own push registration library that accesses the Mobile Services registration REST APIs for Notification Hubs (which IMHO are better than the Notification Hubs REST APIs)<sup>2</sup> and stores the returned handle locally . Like the Mobile Services plugin, this sample also uses PushPlugin,<sup>1, 4</sup> however it does also support MPNS. It&rsquo;s pretty easy to extend to other platforms supported by PushPlugin&mdash;I know folks have also added WNS support (sadly, I don&rsquo;t get much time to support this sample).</p>
<ul>
<li><strong>Supports:</strong> APNS, GCM, MPNS</li>
<li><strong>Pros:</strong> Leverages the Mobile Services client to enable Notification Hubs registration (3). Easy to extend to WNS.</li>
<li><strong>Cons:</strong> Doesn&rsquo;t (yet) support WNS. Still requires PushPlugin.<sup>1, 4</sup> Sample project is maintained only by me, and it&rsquo;s not really a plugin. <!--EndFragment--></li>
</ul>
<h2 id="server-apis">Server APIs for Sending Notifications</h2>
<p>Assuming that you are using Azure Notification Hubs to send push notifications to your Cordova app from your backend service,<sup>3</sup> these are the Azure Notification Hubs libraries that you need to use:</p>
<table style="width: 553px;" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="250">
<p><strong>Backend service</strong></p>
</td>
<td valign="top" width="301"><strong>Notification Hubs-enabled library</strong></td>
<td valign="top" width="301"><strong>&nbsp;Template Push API</strong></td>
</tr>
<tr>
<td valign="top" width="250"><a href="https://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-ios-get-started-push/#update-server">Mobiles Services (.NET backend)</a></td>
<td valign="top" width="301"><a title="Mobile Services .NET Backend" href="https://msdn.microsoft.com/en-us/library/azure/mt419613.aspx">Mobile Services .NET Backend</a></td>
<td valign="top" width="301"><a href="https://msdn.microsoft.com/en-us/library/azure/dn643116.aspx">PushClient<span>.</span>SendAsync()</a>&nbsp;with <a href="https://msdn.microsoft.com/en-us/library/azure/microsoft.windowsazure.mobile.service.templatepushmessage.aspx">TemplatePushMessage</a></td>
</tr>
<tr>
<td valign="top" width="250"><a href="https://azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-ios-get-started-push/#update-scripts">Mobiles Services (node.js)</a></td>
<td valign="top" width="301"><a title="Mobile Services JavaScript backend" href="https://msdn.microsoft.com/en-us/library/azure/jj554226.aspx">Mobile Services JavaScript backend</a></td>
<td valign="top" width="301"><a href="https://msdn.microsoft.com/en-us/library/azure/jj554217.aspx">push.send()</a></td>
</tr>
<tr>
<td valign="top" width="250"><a href="https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-aspnet-backend-ios-notify-users/#sending-notifications-from-the-webapi-backend">ASP.NET</a></td>
<td valign="top" width="301"><a title="Notification Hubs .NET" href="https://msdn.microsoft.com/en-us/library/azure/mt414893.aspx">Notification Hubs .NET</a></td>
<td valign="top" width="301"><a title="SendTemplateNotificationAsync Method" href="https://msdn.microsoft.com/en-us/library/azure/microsoft.azure.notificationhubs.notificationhubclient.sendtemplatenotificationasync.aspx">NotificationHubClient.SendTemplateNotificationAsync()</a></td>
</tr>
<tr>
<td valign="top" width="250"><a href="https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-nodejs-how-to-use-notification-hubs/">Node.js</a></td>
<td valign="top" width="301"><a href="http://dl.windowsazure.com/nodedocs/">Azure SDK for Node.js</a></td>
<td valign="top" width="301"><a href="http://dl.windowsazure.com/nodedocs/NotificationHubService.html#send">NotificationHubService.Send()</a></td>
</tr>
<tr>
<td valign="top" width="250"><a href="https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-java-backend-how-to/">Java</a></td>
<td valign="top" width="301"><a href="https://github.com/Azure/azure-notificationhubs-java-backend">Java Notification Hubs SDK</a></td>
<td valign="top" width="301"><a href="https://github.com/Azure/azure-notificationhubs-java-backend/blob/master/NotificationHubs/src/com/windowsazure/messaging/NotificationHub.java#L521">NotificationHub.sendNotification()</a>&nbsp;with <a href="https://github.com/Azure/azure-notificationhubs-java-backend/blob/master/NotificationHubs/src/com/windowsazure/messaging/Notification.java#L165">Notification.createTemplateNotification()</a></td>
</tr>
</tbody>
</table>
<p>For backend servers not supported by these APIs (like for <a href="https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-php-backend-how-to/">PHP</a>/<a href="https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-python-backend-how-to/">Python</a>/Ruby), you can always just use the <a href="http://msdn.microsoft.com/en-us/library/windowsazure/dn223264.aspx/">Notification Hubs REST APIs</a>.</p>
<h2 id="configuration">Configuring the Push Topology</h2>
<p>For each supported client platform, you must have your app configured to access the PNS.<sup>1</sup> You also need your backend service configured with the PNS to be able to request push notifications on behalf of your app using the PNS-generated handle.<sup>3</sup></p>
<h4>Client configuration</h4>
<p>These client configuration steps are usually done in the client project must vary in complexity, depending on the PNS (and Apple is by far the hardest):</p>
<ul>
<li><strong>APNS: </strong><ol>
<li>Build the iOS native app project from the Cordova app.</li>
<li>Open the Xcode project in Xcode on your Mac.</li>
<li><a href="https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingProfiles/MaintainingProfiles.html#//apple_ref/doc/uid/TP40012582-CH30-SW991">Register an App ID for your app</a>.</li>
<li><a href="https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringPushNotifications/ConfiguringPushNotifications.html#//apple_ref/doc/uid/TP40012582-CH32-SW6">Enable push notifications for the app</a>.</li>
<li><a href="https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringPushNotifications/ConfiguringPushNotifications.html#//apple_ref/doc/uid/TP40012582-CH32-SW8">Verify that the app ID enables push notifications</a>.</li>
<li><a href="https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringPushNotifications/ConfiguringPushNotifications.html#//apple_ref/doc/uid/TP40012582-CH32-SW10">Refresh the provisioning profiles in the Xcode quickstart project</a>.</li>
<li><a href="https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringPushNotifications/ConfiguringPushNotifications.html#//apple_ref/doc/uid/TP40012582-CH32-SW12">Verify that the provisioning profile was either created or regenerated to enable push notifications</a></li>
</ol>
<p><strong>NOTE:</strong> Most of these client configuration steps for APNS must be done in the Xcode project generated by the Cordova build for iOS. You also need an Apple Developer account to register for push notifications and a physical device to test them.</p>
</li>
</ul>
<ul>
<li><strong>GCM:</strong><ol>
<li><a href="https://github.com/Azure/azure-content/blob/master/includes/mobile-services-enable-google-cloud-messaging.md">Enable Google Cloud Messaging</a>.</li>
<li>Set the Google Project ID in the client (PushPlugin only).</li>
<li><a href="https://github.com/Azure/azure-content/blob/master/includes/mobile-services-enable-google-cloud-messaging.md">Create a new server key</a> (make note of the API key value, which is the GCM credentials).</li>
<li>(Optional) <a href="https://azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-android-get-started-push/#test-push-notifications-in-your-appSet">Setup the Android emulator for testing</a>.</li>
</ol>
<p>Android is the only app that doesn&rsquo;t require you to build the native app and register using the platform IDE.</p>
</li>
<li><strong>WNS:</strong><ol>
<li>Build the Windows native app project from the VS Cordova project.</li>
<li>Open the generated Windows project in Visual Studio.</li>
<li><a href="https://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj856246.aspx">Register your app with the Windows Store.</a></li>
<li>Go to the <a href="https://account.live.com/developers/applications/index">Microsoft Account developer center</a>, select your new app, and make a note of your package SID and client secret, which are the WNS credentials.</li>
</ol>
<p><strong>NOTE:</strong> You need a <a href="https://dev.windows.com/en-us/programs/join">Windows Developer account</a> to register for push notifications.</p>
</li>
<li><strong>MPNS:</strong>
<p>For folks still trying to support Windows Phone 8 and Windows Phone 8.1 "Silverlight" apps, the good news MPNS doesn't require authentication, as long as you send less than 500 notification a day (per channel).</p>
</li>
</ul>
<h4>Backend Configuration</h4>
<p>When using Azure Notification Hubs, the final step for each platform is to <a href="https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-android-get-started/#configure-a-new-notification-hub">set the authentication credentials from each PNS in the Azure portal</a>. Note that when you set the push credentials in Mobile Services, they are simply passed-back to the associated notification hub.</p>
<h2>Conclusion</h2>
<p>Push notifications is a key requirement for many mobile app scenarios, and the PushPlugin does provide push notification support for Cordova apps. While Azure is a great platform for sending push notifications, either through Azure Mobile Services or directly from Azure Notification Hubs, the Cordova client support in Azure libraries for push notification is not quite as robust as it could be, especially if you are trying to support Windows apps when using template notifications. In the meantime, you can fall back on PushPlugin and the Notification Hubs REST APIs to support these scenarios.</p>
<p>Anyway, I hope that helps to clarify things, at least a little bit.</p>
<p>Cheers!</p>
<h5>Glenn Gailey</h5>]]></content:encoded>
    </item>
    <item>
      <title>New Azure Mobile samples and tutorials</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/new-azure-mobile-samples-and-tutorials</link>
      <pubDate>Wed, 15 Jul 2015 08:54:08 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/2015/07/15/new-azure-mobile-samples-and-tutorials/</guid>
      <description><![CDATA[I’m excited to announce that we have some interesting new content and samples published to support...]]></description>
      <content:encoded><![CDATA[<p>I’m excited to announce that we have some interesting new content and samples published to support Azure Mobile Services and Azure App Service Mobile Apps. Most of this new content was asked for by customers, which makes it even more fun to share this.</p>  <h3><a href="https://github.com/Azure/mobile-services-samples/tree/master/CustomAuthentication">Custom authentication sample</a></h3>  <p>I was challenged by a <a href="https://twitter.com/jcombalicer/status/606487996246794241">customer via Twitter</a> to publish a custom authentication project that includes both backend and universal Windows client (as I described in my <a href="http://blogs.msdn.com/b/writingdata_services/archive/2015/05/06/sign-in-to-mobile-services-using-custom-authentication-from-a-windows-client.aspx">previous post</a>) but that also used Azure Table storage. </p>  <p><a href="https://github.com/Azure/mobile-services-samples/tree/master/CustomAuthentication"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/0702.image_421D7DA0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/0702.image_5F00_421D7DA0.png" width="539" height="484" /></a></p>  <p>This sample demonstrates adding custom authentication to the TodoList quickstart mobile service .NET backend project. By default, this project uses Azure SQL Database for data storage, but the readme shows you how to convert storage to use Azure Table storage. This solution includes a universal Windows 8.1 project that is used to test the custom authentication in the mobile service.</p>  <h3><a href="https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-dotnet-backend-hybrid-connections-get-started-preview/">Hybrid Connections tutorial for Mobile Apps</a></h3>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/6082.image_5AAD1AF0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/6082.image_5F00_5AAD1AF0.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/1727.image_thumb_71DB261F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/1727.image_5F00_thumb_5F00_71DB261F.png" width="604" height="343" /></a></p>  <p>Like the ones for <a href="https://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-hybrid-connections-get-started/">Mobile Services</a> and <a href="http://azure.microsoft.com/en-us/documentation/articles/web-sites-hybrid-connection-connect-on-premises-sql-server/">Web Apps</a>, this new tutorial shows you how to connect your Azure App Service mobile app to an on-premises SQL Server database by using Hybrid Connections. </p>  <h3><a href="https://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-universal-dotnet-upload-data-blob-storage/">Universal Windows version of Upload images to Azure Storage by using Mobile Services</a></h3>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/3480.image_2A85D02D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/3480.image_5F00_2A85D02D.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/5531.image_thumb_6CF87263.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/5531.image_5F00_thumb_5F00_6CF87263.png" width="604" height="342" /></a></p>  <p>It took a while to get this done, but the upload images tutorials are very popular. Now, there is a universal Windows 8.1 app version that uses the new MediaCapture APIs that support both Windows and Windows Phone devices. We are also working on the Android version now that the <a href="https://github.com/Azure/azure-storage-android">Azure Storage SDK for Android</a> is available (stay tuned).</p>  <h3><a href="https://github.com/Azure/mobile-services-samples/tree/master/TodoListXamarinForms">Xamarin.Forms version of the TodoList quickstart project</a></h3>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/8508.image_73AB7BE6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/8508.image_5F00_73AB7BE6.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/8105.image_thumb_53243C34.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/8105.image_5F00_thumb_5F00_53243C34.png" width="604" height="429" /></a></p>  <p>Xamarin.Forms is becoming more and more popular, but sadly we may never get an official Xamarin.Forms&#160; version of the TodoList app quickstart that you can download from the portal for your mobile service. Luckily, our resident Xamarin expert, Norm Estabrook, wrote for us a Xamarin.Forms version of TodoList.</p>  <p>The good news is that there is already full quickstart support for Xamarin.Forms in Mobile Apps:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/0216.image_1596DE6B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/0216.image_5F00_1596DE6B.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/5327.image_thumb_11205DA4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/5327.image_5F00_thumb_5F00_11205DA4.png" width="604" height="308" /></a></p>  <h3><a href="https://azure.microsoft.com/en-us/documentation/articles/partner-xamarin-mobile-services-xamarin-forms-get-started-push/">Add push notifications to your Xamarin.Forms app</a></h3>  <p><a href="https://azure.microsoft.com/en-us/documentation/articles/partner-xamarin-mobile-services-xamarin-forms-get-started-push/"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/7077.image_62C6D7F6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/7077.image_5F00_62C6D7F6.png" width="604" height="343" /></a></p>  <p>Norm also added a nice Xamarin.Forms version of the <em>Add push notifications to your app</em> series of Mobile Services tutorials. The cool thing about this is that it’s a cross-platform tutorial that leverages template registrations in Notification Hubs to send simultaneous registrations to iOS (APNS), Android (GCM), and Windows (WNS) platforms.&#160; </p>  <p>Next, I need to spend some time cleaning up the preview <a href="https://azure.microsoft.com/en-us/documentation/services/app-service/mobile/">Mobile Apps topics</a>.</p>  <p>Cheers!</p>  <h5>Glenn Gailey</h5>]]></content:encoded>
    </item>
    <item>
      <title>Sign-in to Mobile Services using custom authentication from a Windows client</title>
      <link>https://docs.microsoft.com/archive/blogs/writingdata_services/sign-in-to-mobile-services-using-custom-authentication-from-a-windows-client</link>
      <pubDate>Wed, 06 May 2015 10:44:01 GMT</pubDate>
      <dc:creator><![CDATA[Glenn Gailey [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/writingdata_services/2015/05/06/sign-in-to-mobile-services-using-custom-authentication-from-a-windows-client/</guid>
      <description><![CDATA[UPDATE: I have published a Visual Studio solution that is a .NET backend mobile&nbsp;service...]]></description>
      <content:encoded><![CDATA[<table style="width: 600px;" border="1">
<tbody>
<tr>
<td><strong>UPDATE</strong>: I have <a href="https://github.com/Azure/mobile-services-samples/tree/master/CustomAuthentication">published a Visual Studio solution</a> that is a .NET backend mobile&nbsp;service with custom authentication plus a universal Windows 8.1 app project. (I cheated a bit with the registration because I didn't want to create a whole new UI, but it should be enough to point you in the right direction for Windows C#.) Just for fun, the service can be converted easily from SQL Database to Azure Table storage.</td>
</tr>
</tbody>
</table>
<p>I spent some time the past few days improving the topic <a href="http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-get-started-custom-authentication">Add custom authentication to your app</a>, which had a few issues&mdash;the main one being that we didn&rsquo;t tell you how to consume the custom authentication endpoints in a client app to sign-in a user. The new section we added describes the steps needed to access the custom authentication endpoints from the client, which are:</p>
<ol>
<li>Create a sign-in UI to get the username and password.</li>
<li>Create a new registration using the <strong>CustomRegistration</strong> endpoint.</li>
<li>Sign-in using the <strong>CustomLogin</strong> endpoint.</li>
<li>Use the returned user ID and authentication token to set the current user for the client.</li>
</ol>
<p>This guidance we added to the topic is platform agnostic, so it lacks specific code examples. Fortunately, there are other examples of how to call a custom API from the various clients (<a href="http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/19/custom-api-in-azure-mobile-services-client-sdks.aspx" target="_blank">Carlos&rsquo; blog post</a> is still one of the best resources on calling custom APIs). In this post, I show how I did it for a Windows C# app.</p>
<h2>Create the custom sign-in UI</h2>
<p>The first step is to create a custom UI to supply the username and password, which should be done at runtime (you can cache these credentials, but you need to store them securely using <strong>PasswordVault</strong>, as shown <a href="http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-universal-dotnet-get-started-users/#tokens" target="_blank">in this topic</a>).</p>
<p>Because I remember having to create these kinds of sign-in UIs all of the time in the Windows Forms days, I was surprised at how not straightforward it was to create a custom sign-in dialog in a modern Windows app. To me, this demonstrates the benefits of Mobile Services authentication, either client-directed authentication (using Live SDK) or service-directed authentication (which uses the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.security.authentication.web.webauthenticationbroker.aspx" target="_blank">WebAuthentiationBroker</a> class under the covers), both are browser-based authentication so no extra UI is needed.</p>
<p>For my new Windows Store app sign-in UI, I decided to just add a new <strong>Grid</strong> that overlays the existing UI grid, which contains username and password fields. Here&rsquo;s the XAML:</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">Grid</span> <span class="attr">Name</span><span class="kwrd">="GridLoginDialog"</span> <span class="attr">Background</span><span class="kwrd">="Black"</span> <span class="attr">Visibility</span><span class="kwrd">="Collapsed"</span> 
      <span class="attr">Opacity</span><span class="kwrd">="0.5"</span> <span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Grid</span> <span class="attr">Width</span><span class="kwrd">="350"</span> <span class="attr">Height</span><span class="kwrd">="200"</span> <span class="attr">Background</span><span class="kwrd">="White"</span> <span class="attr">Opacity</span><span class="kwrd">="100"</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">Grid.ColumnDefinitions</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">ColumnDefinition</span> <span class="attr">Width</span><span class="kwrd">="*"</span><span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">ColumnDefinition</span> <span class="attr">Width</span><span class="kwrd">="200"</span><span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">Grid.ColumnDefinitions</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">Grid.RowDefinitions</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">RowDefinition</span> <span class="attr">Height</span><span class="kwrd">="35"</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">RowDefinition</span> <span class="attr">Height</span><span class="kwrd">="*"</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">RowDefinition</span> <span class="attr">Height</span><span class="kwrd">="*"</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">RowDefinition</span> <span class="attr">Height</span><span class="kwrd">="60"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">Grid.RowDefinitions</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">TextBlock</span> <span class="attr">Name</span><span class="kwrd">="loginMessage"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">TextBlock</span> <span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="1"</span> <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="0"</span> <span class="attr">Text</span><span class="kwrd">="Username: "</span> 
                   <span class="attr">HorizontalAlignment</span><span class="kwrd">="Right"</span> <span class="attr">FontSize</span><span class="kwrd">="12"</span> 
                   <span class="attr">VerticalAlignment</span><span class="kwrd">="Center"</span>  <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">TextBox</span> <span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="1"</span> <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="1"</span> <span class="attr">Name</span><span class="kwrd">="txtUsername"</span> 
                 <span class="attr">HorizontalAlignment</span><span class="kwrd">="Right"</span> <span class="attr">FontSize</span><span class="kwrd">="12"</span> 
                 <span class="attr">VerticalAlignment</span><span class="kwrd">="Center"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">TextBlock</span> <span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="2"</span> <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="0"</span>  <span class="attr">Text</span><span class="kwrd">="Password: "</span>  <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">PasswordBox</span> <span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="2"</span> <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="1"</span> <span class="attr">Name</span><span class="kwrd">="txtPassword"</span> 
                     <span class="attr">Margin</span><span class="kwrd">="0,10,22,10"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">StackPanel</span> <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="1"</span> <span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="3"</span>  <span class="attr">Orientation</span><span class="kwrd">="Horizontal"</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Button</span> <span class="attr">Content</span><span class="kwrd">="Sign in"</span> <span class="attr">Width</span><span class="kwrd">="90"</span> <span class="attr">Name</span><span class="kwrd">="ButtonCustomLogin"</span> 
                    <span class="attr">Click</span><span class="kwrd">="ButtonCustomLogin_Click"</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Button</span> <span class="attr">Content</span><span class="kwrd">="Cancel"</span> <span class="attr">Width</span><span class="kwrd">="90"</span> <span class="attr">Name</span><span class="kwrd">="ButtonCancelLogin"</span> 
                    <span class="attr">Click</span><span class="kwrd">="ButtonCancelLogin_Click"</span> <span class="kwrd">/&gt;</span>                   
        <span class="kwrd">&lt;/</span><span class="html">StackPanel</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">ProgressRing</span> <span class="attr">Name</span><span class="kwrd">="LoginProgress"</span> <span class="attr">IsActive</span><span class="kwrd">="false"</span> <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="0"</span> 
                      <span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="3"</span> <span class="attr">HorizontalAlignment</span><span class="kwrd">="Stretch"</span> 
                      <span class="attr">VerticalAlignment</span><span class="kwrd">="Stretch"</span> <span class="attr">Margin</span><span class="kwrd">="2"</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Grid</span><span class="kwrd">&gt;</span>          
<span class="kwrd">&lt;/</span><span class="html">Grid</span><span class="kwrd">&gt;</span></pre>
<p>I added an explicit sign-in button, which when clicked displays my sign-in grid:</p>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">void</span> ButtonCustomLogin_Click(<span class="kwrd">object</span> sender, RoutedEventArgs e)
{
    <span class="rem">// Show the sign-in grid and hide the login button.</span>
    <span class="kwrd">this</span>.GridLoginDialog.Visibility = Visibility.Visible;
    <span class="kwrd">this</span>.ButtonCustomLogin.Visibility = Visibility.Collapsed;

}</pre>
<p>Here&rsquo;s how the UI looks:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/0451.image_427338AE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/0451.image_5F00_427338AE.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/8877.image_thumb_124BEDEB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/8877.image_5F00_thumb_5F00_124BEDEB.png" alt="image" width="604" height="347" border="0" /></a></p>
<p>Google/Bing turned up very little about custom sign-in UI for Windows Store apps, so this is what I came up with. If you know of a better pattern for how to do this, I would love to know about it (please leave me a comment).</p>
<h2>Create a new registration</h2>
<p>The custom authentication tutorial has you create a <strong>CustomRegistration</strong> endpoint, which is used to create a new user in the Accounts table. Frankly, this part of the topic makes me the most uneasy, especially since we tell you to set this endpoint to allow anonymous access. (This is the great thing about using identity providers like Facebook and Google with Mobile Services, at least these third-party services already have account provisioning figured out.) I added a note to this section strongly suggesting that you implement some kind of account validation scheme, such as sending a text or email with a confirmation code that the user can enter to complete registration. Or maybe, you make this an endpoint that requires a master key so that only someone with service level access can add accounts.</p>
<p>My client sample doesn&rsquo;t do registration; I just assume that new account provisioning is done out-of-band, I actually changed the access permissions on my endpoint to <span style="font-family: Cordia New; font-size: small;">[AuthorizeLevel(AuthorizationLevel.Admin)]</span> and add registrations from the API help pages, using the service master key. While I don&rsquo;t show how to access the <strong>CustomRegistration</strong> endpoint here, the code you need is nearly identical to the code used to access <strong>CustomLogin</strong>, which we will look at next.</p>
<h2>Sign-in to the CustomLogin endpoint</h2>
<p>Assuming that my user account is already provisioned, you just use the supplied username and password to call the <strong>CustomLogin</strong> API, with a POST request. This is done in the <strong>AuthenticateAsync</strong> method:</p>
<pre class="csharpcode"><span class="kwrd">private</span> async Task&lt;MobileServiceUser&gt; AuthenticateAsync(<span class="kwrd">string</span> username, 
    <span class="kwrd">string</span> password) {           

    <span class="rem">// Call the CustomLogin API and set the returned MobileServiceUser</span>
    <span class="rem">// as the current user.</span>
    var user = await App.MobileService
        .InvokeApiAsync&lt;LoginRequest, MobileServiceUser&gt;(
        <span class="str">"CustomLogin"</span>, <span class="kwrd">new</span> LoginRequest() { 
            UserName = username, 
            Password = password });

    <span class="kwrd">return</span> user;
}</pre>
<p>Note that the <a href="https://msdn.microsoft.com/en-us/library/dn268388.aspx" target="_blank">InvokeApi&lt;T,U&gt;</a> method, which by default calls the endpoint using a POST request, returns a <a href="https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.mobileservices.mobileserviceuser.aspx" target="_blank">MobileServiceUser</a> object. This works because the shape of the response object returned by the <strong>CustomLogin</strong> endpoint is the same as the <a href="https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.mobileservices.mobileserviceuser.aspx" target="_blank">MobileServiceUser</a> class, so the client library is able to deserialize it correctly from the response. Note that the original version of the custom authentication tutorial returned a system-defined <strong>LoginResult</strong>, which for some reason doesn&rsquo;t quite match the shape of the client&rsquo;s user object. When I updated the tutorial, I changed this to instead return a <strong>CustomLoginResult</strong> object, which does match <strong>MobileServiceUser</strong> and make it a bit easier to set the current user on the client.</p>
<h2>Set the current user on the client</h2>
<p>The final thing to do is to set the <a href="https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.mobileservices.mobileserviceclient.currentuser.aspx" target="_blank">CurrentUser</a> property on the <a href="https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.mobileservices.mobileserviceclient.aspx" target="_blank">MobileServiceClient</a> instance to the <a href="https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.mobileservices.mobileserviceuser.aspx" target="_blank">MobileServiceUser</a> returned by the successful <strong>CustomLogin</strong> request, as shown in the sign-in button code below:</p>
<pre class="csharpcode"><span class="kwrd">private</span> async <span class="kwrd">void</span> ButtonCustomLogin_Click(<span class="kwrd">object</span> sender, RoutedEventArgs e)
{
    <span class="kwrd">if</span> (<span class="kwrd">string</span>.IsNullOrEmpty(txtUsername.Text) 
        || <span class="kwrd">string</span>.IsNullOrEmpty(txtPassword.Password))
    {
        <span class="kwrd">return</span>;
    }

    <span class="kwrd">this</span>.LoginProgress.IsActive = <span class="kwrd">true</span>;

    <span class="kwrd">try</span>
    {
        <span class="rem">// Sign-in and set the returned user on the context,</span>
        <span class="rem">// then load data from the mobile service.</span>
</pre>
<p><span style="background-color: #ffff00;"> App.MobileService.CurrentUser = await AuthenticateAsync(<span class="kwrd">this</span>.txtUsername.Text, txtPassword.Password);</span></p>
<pre class="csharpcode">        await RefreshTodoItems();
        <span class="kwrd">this</span>.GridLoginDialog.Visibility = Visibility.Collapsed;
    }
    <span class="kwrd">catch</span> (MobileServiceInvalidOperationException ex)
    {
        loginMessage.Text = ex.Message;        
    }
    <span class="kwrd">finally</span>
    {
        ResetLoginUI();
    }
}</pre>
<p>Note that setting the current user on the client follows the same basic pattern for caching tokens shown in the <a href="http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-universal-dotnet-get-started-users/#tokens" target="_blank">client authentication tutorial</a>. Also, I could have set the current user in the <strong>AuthenticateAsync</strong> method, but I wanted to break out this step for clarity.</p>
<p>With the user set, the Mobile Services client uses the <em>authenticationToken</em> in the current <strong>MobileServiceUser</strong> to generate the X-ZUMO-AUTH header, which enables access to table controller endpoints that are restricted to only authenticated users.</p>
<p>Yay! It works <img class="wlEmoticon wlEmoticon-smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/43/17/metablogapi/3681.wlEmoticon-smile_6B11A4B5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-43-17-metablogapi/3681.wlEmoticon_2D00_smile_5F00_6B11A4B5.png" alt="Smile" />&nbsp;</p>
<h2>Final thoughts</h2>
<p>Having only used the Mobile Service built-in authentication patterns, this was an interesting change of pace. Here are a few things other random things that occurred to me while I worked on this side project&hellip;.</p>
<ul>
<li>Custom authentication is way harder than using the authentication support built into Azure Mobile Services. But, isn&rsquo;t that why you are willing to pay a little bit extra for Mobile Services (that and the native client libraries&hellip;and push notifications). With the built-in authentiation support, once you get everything configured (which requires almost no code at all) you simply call <strong>LoginAsync</strong> from the client and you are done.</li>
<li>With custom authentication you are on your own. The tutorial we provide for a .NET backend (as well as <a href="http://www.thejoyofcode.com/Generating_your_own_ZUMO_auth_token_Day_8_.aspx" target="_blank">Josh&rsquo;s blog post using node.js</a>) are really bare bones, you still need to harden your authentication endpoints, prevent spoofers and fraudulent registrations, etc. To be honest, I&rsquo;m not really an expert on security programming. If you are, have at it. Maybe you have done this before and feel confident with it. However, if (like me) you are new to this&mdash;get an expert to review what you are doing before you go into production with any custom authentication scheme.</li>
<li>One of the many benefits of using our Mobile Services client libraries, aside from the ease and convenience, is that they always make requests to your mobile service running in Azure by using HTTPS. This means that <strong>InvokeApi</strong> will always use an HTTPS request. Using a pure REST call, you need to make sure you are accessing the endpoint using HTTPS.</li>
</ul>
<p>Anyway, please let us know via Disqus if you have any questions or issues with the <a href="http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-get-started-custom-authentication/" target="_blank">Custom Authentication tutorial</a>.</p>
<p>Cheers!</p>
<h4>Glenn Gailey</h4>]]></content:encoded>
    </item>
  </channel>
</rss>