Skip to main content

Creating a Microsoft Band Tile to push build status notifications

Last year Microsoft had launched Microsoft Band 2. From the hardware configuration, it’s very powerful with a lot of sensors and a battery autonomy that offers me two days of power.

But, the thing that impress me is the software part and how easily you can develop a tile (a custom app) for it. You don’t need to learn C#, you can create a tile easily directly from browser.
Yes, you heard me, from a browser -

This will allow you get content from the the fat web and push it to your tile. In this way you can easily integrate your application with the band - fast and easy

Another great thing is how you deploy and share tiles. You don’t need to push to the store, validate it and so on. No, you are free to share the tile with anybody. Just upload it to a specific location and share the URL with your friends via email or web. The phone can detect automatically the tile and open it using Microsoft Band application.

Information is the power
For consumers, the most important thing is the content that you display in the tile. Try to focus on the content that you want to display. You need to identify the content that 
can improve the life of the band owner.
Because the number of tiles that you can install on the band is limited, you should keep in mind that the consumer will keep only the most important tiles, that brings on his device information that he really needs. Otherwise, your tile will be just another tile, that nobody use or keep more than 5 minutes.
Any developer can create a tile and push content to Microsoft Band, in only 2 or 3 minutes. But only great ideas and useful content will end up on consumers devices.

Our team
Each developer from the team that I’m part of received last year a Microsoft Band 2. We started to make jokes, that we increased the number of Microsoft Bands in Cluj-Napoca with 800-1000%. The team is not so big, but in that moment in time in Cluj-Napoca I knew only a person with a band.

I started to think about what we can do with the band, how we can improve our life. I end up with a simple solution, that I will describe end to end in the next part of the article.

Push build status change notification to our band

The idea is simple. We are keeping our source code on TFS Online (Visual Studio Online) and TFS 2015 on-premises. We have different builds agents on Azure and in our company private network (on-premises) that build our solution, run unit tests, extract different metrics and deploys automatically the application on different environments. The main scope is to notify as soon as possible the development team that the build is down.  

Blockers and architecture overview
The main scope is to push a notification to the band in the moment when build fails. The idea is simple, but we need to find a solution to be able to send the notification to the band without having to store TFS User Credentials.

There is no way to store credentials on the band and query the source control server.

A possible solution is to develop a phone app that would push this notifications. But, wait… we are not mobile developers and each of us has different types of phones – iPhones, Windows Phone and Android. It might work, but the development effort is to expensive. It is possible to write a cross platform mobile app., but until you push it to the store you will lose the interest and the current opportunity.

RSS Feed
A more simple solution is to expose a RSS feed with build status change notifications. Each time when the build status change, new content will be available on the RSS Server. The tiles that is running on the band will detect the new content and will notify the user.

In this moment we resolved only a part of the problem. We have a web endpoint that can be used by the tile to access the RSS feed. The RSS feed channel can be used by the band to get build status change notifications.

Push Notifications
Now, we need to find a way how we can push the build status change from CI server to our web application. This is a little more tricky and please ignore any kind of security issues that will be only mentioned but not covered.
For Visual Studio Team Services, the problem can be solved easily. Because the CI is public available we need to store in our web app a valid username and password that can be used to query the build status for changes. 
But for our on-premises CI server we might have a problem. The on-premises CI server is not public available. This means that we cannot query our server to check the build status from the internet.

Let's use our imagination. 
What is the default action that is done by a CI server when a build fails, except the color change (big smile)?
The most common action is to send an email to one or more users. This is our key to be able to access a build status change notification.

The CI machine will send a notification to our mail server. Normally, a Mail Server is public accessible from internet. Our RSS web up will need to store the email credentials.
Even if the solution will work and can be used with success we need to keep in mind that:

  • Emails credentials will be stored by Web App
  • Confidential information (Build Status) will be public available on a web endpoint that can be used by anybody
  • Any person that has your tile will be able to see status change notification of your build(s)
All this points needs to be mitigated with the security group of your company. You should never implement such a solution without their approval. 


TFS Email notification
The solution is applicable for older version of TFS also. The below steps and samples are for Visual Studio Online and TFS 2015. 
You will need to define an alert that sends an email notification in the moment when the build quality changes. Based on your needs you can use the same account to send notification for different builds. 

Check for new emails
There are different libraries that can help you to access your email server. You should decide what kind of library you want to use based on the email server type. If you are using Outlook or Exchange Server that you might want to use EWS library. For Gmail account you might need a POP3 client and a MIME purser like OpenPOP.NET.
In the below sample you can see how you can get a messages using OpenPOP.NET library. 
POPClient client = new POPClient();
client.Connect("", 995, true);
client.Authenticate("", "Hahaha");
var count = client.GetMessageCount();
Message message = client.GetMessage(count);
The subject can be access in the following way 'message.Headers.Subject'.

Expose notifications as RSS feed 
The next step is to expose as RSS feed the new notifications. This can be done using in 10 minutes if we are using ApiController. Wait, we don't need to implement a RSS feed and serialize the content.
This is supported by ASP.NET MVC. There is even a special ActionResult that is created for this purpose - RssActionResult. To the RssActionResult, we need to set the 'Feed' property that is of type 'SyndicationFeed'.
public ActionResult BuildStatusRSS()
    IEnumerable<BuildStatus> buildStatus = BuildStatusManager.GetAllByDate(8);
    SyndicationFeed buildFeed =
        new SyndicationFeed("Build Status",
            new Uri(""),
    List<SyndicationItem> buildStatusList = new List<SyndicationItem>();
    foreach (BuildStatus bs in posts)
        string postUrl = string.Format("build\\build-entry-{0}", bs.Id);
        SyndicationItem buildStatus =
            new SyndicationItem(bs.Title,
                new Uri(postUrl),
    buildFeed.Items = buildStatusList;
    return new RssActionResult {Feed = buildFeed};

In the above example we are generating a RSS with build status. The BuildStatus class is a custom class where information related to a specific build are stored. This class is populated based on the emails that are send by the TFS when a build status changes.

Hosting our Web App
We can host our web application as a Web App in Azure. The free tier will be enough to play around.

My web application url will be The build status is mapped to

Creating the Tile
This is the last step that we need to do. We need to create the Microsoft Band Tile. This will be done directly from browser (
The next steps are pretty simple, you need to specify colors, icon and things like that. Once we done this, we can download the tile on our local computer.

Publish the tile
The most simple solution to publish the tile is to upload on a file sharing system like OneDrive and create a share link.

... the end...
And we are done. Once we will access the tile link from your phone, the Microsoft Band application will open and you will be able to push the tile.

In this post we saw an end to end solution on how we can push builds notification to our Microsoft Band without developing a phone application. From the tile perspective, creating and publishing a tile is easily.
The most complex thing is to create the feed with the right information. Not because of technical problems, it is about what content to push (display). We should remember that 'Information is the power'


Popular posts from this blog

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

Entity Framework (EF) TransactionScope vs Database.BeginTransaction

In today blog post we will talk a little about a new feature that is available on EF6+ related to Transactions.
Until now, when we had to use transaction we used ‘TransactionScope’. It works great and I would say that is something that is now in our blood.
using (var scope = new TransactionScope(TransactionScopeOption.Required)) { using (SqlConnection conn = new SqlConnection("...")) { conn.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = conn; sqlCommand.CommandText = ... sqlCommand.ExecuteNonQuery(); ... } scope.Complete(); } Starting with EF6.0 we have a new way to work with transactions. The new approach is based on Database.BeginTransaction(), Database.Rollback(), Database.Commit(). Yes, no more TransactionScope.
In the followi…

GET call of REST API that contains '/'-slash character in the value of a parameter

Let’s assume that we have the following scenario: I have a public HTTP endpoint and I need to post some content using GET command. One of the parameters contains special characters like “\” and “/”. If the endpoint is an ApiController than you may have problems if you encode the parameter using the http encoder.
using (var httpClient = new HttpClient()) { httpClient.BaseAddress = baseUrl; Task<HttpResponseMessage> response = httpClient.GetAsync(string.Format("api/foo/{0}", "qwert/qwerqwer"))); response.Wait(); response.Result.EnsureSuccessStatusCode(); } One possible solution would be to encode the query parameter using UrlTokenEncode method of HttpServerUtility class and GetBytes method ofUTF8. In this way you would get the array of bytes of the parameter and encode them as a url token.
The following code show to you how you could write the encode and decode methods.