Posts

Microsoft Azure Application Insights

Introduction I recently set out to integrate Application Insights (AI) into my ASP.NET MVC 5 (not core, yet) web application hosted in Microsoft Azure.  I was sorely disappointed by the lack of in-depth documentation provided by Microsoft.  Whats more, most of the articles I found on the topic were outdated by several years.  I was able to piece together enough content online to get up-and-running, but had to dig into the source code to fully understand how to configure AI the way that I wanted it.  I'm going post a few little snippets here that I discovered along the way in the hopes that they help anyone else struggling to configure AI. Tracking Authenticated User ID in Application Insights

Tracking Authenticated User ID in Application Insights

After getting the basic out-of-the-box inplementation of Application Insights (AI) up and running, I decided to customize it to pass the ID of the current user along with the telemetry.  The first couple of articles I discovered recommended writing a custom Telemetry Initializer to populate the Telemetry.Context.AuthenticatedUserId property.  Since my website uses ASP.NET forms authentication, I was able to grab the ID of the current user from the HttpContext.Current.User property.  My initializer ended up looking something like this: public class MyTelemetryInitializer : ITelemetryInitializer { public void Initialize(ITelemetry telemetry) { var identity = HttpContext.Current?.User?.Identity; if (identity == null) return; telemetry.Context.User.AuthenticatedUserId = identity.Name; } } Then I register my initializer using the following line of code in the app_start function of my Global.asax.cs file. ...

Running Windows 8 in Parallels

I recently attended a great two day code camp on Windows 8 development hosted by Microsoft here in London.  A prerequisite for the camp of course was that attendees bring a laptop running Windows 8.  As some of my readers probably know, my current choice of laptop is a MacBook Air running Mac OS X and Windows 7 on Bootcamp.  I was hesitant to overwrite my Windows 7 installation with a pre-released version of Windows 8 because I was certain there would be drivers missing, etc.  Instead I decided to look into installing Win 8 into a virtual machine.  I already own a license for Parallels for Mac OS so I figured I would start there.  I booted into my Mac partition, started Parallels and clicked the "Create a virtual machine" button.  Much to my surprise, one of the options on the next screen was to download and install Windows 8 Consumer Preview.  I happily selected this options and left for dinner as I waited for Parallels to download the necessa...

Writing Your First Rx Statement

Image
Introduction In my first blog post on Reactive Extensions (Rx),  Introduction to Reactive Extensions , I mentioned that there are several ways in which you can create an IObservable<T>. The most fundamental way to create an IObservale<T> is be using the Observable.Create<TSource>() method.  At first glance this method is a bit confusing but once you know how to implement it, it becomes very powerful. You First Rx Statement  In this tutorial I will build a Windows console application that will make an asynchronous web call to the Twitter API using the WebClient.DownloadStringAsync() and Rx.  I begin by creating a new console application called SampleRxApp. Next, I add the appropriate Rx reference.  For this, I use Nuget to add a reference to Rx-Main. Once I have added necessary Rx library, I add the following using statement to the top of my Program.cs file.  using System; using System.Net; using...

Introduction to Reactive Extensions

Working in the field of technology means constantly learning new technologies and using them to build cool new software.  I think my desire to learn is what drove me to this industry.   My most recent endeavor was learning the Reactive Extensions (Rx) for the .NET framework.  I had no reason to believe that picking up Rx would be any different from any other technology.  Boy was I wrong!  In my 10 years of learning new technologies, the difficultly of learning Rx rated right up there with making the switch from procedural to object oriented programming.  It is a paradigm shift that requires you to completely rethink the way you develop.  Developing with Rx will probably come more naturally for those of you well versed in asynchronous programming, but I did not have much exposure to async programming prior to this undertaking (which is probably why I found it so difficult to pick up).   Another reason why I found it difficult to learn Rx...

Reacquainting myself with Windows Workflow Foundation

Introduction I have always found the Windows Workflow Foundation an intriguing technology because of the potential it has to truly separate business logic out of our code and into an easily maintainable, visually pleasing format.  Though it is used quite heavily in SharePoint to manage things like approval processes, unfortunately I haven’t seen it leveraged in very many custom built applications.  I think this is probably due to the lack of knowledge around the technology as well as the difficultly in building out the scaffolding to fully integrate it into a custom application.  There are dozens of articles on the Internet that show you how to build a simple “Hello World” workflow.  But it is a rather big jump to get it up and running in your application.  I’m speaking from personal experience. It has been a while since I’ve worked with Workflow Foundation so I haven’t had the opportunity to explore the changes that came in version 4.0 of the .NET Framework....

WP7 People Hub Facebook Integration

One of the features of the new Windows Phone 7 that I really like is the full integration of Facebook into the People Hub.  The People Hub is like your traditional mobile phone contact list on steroids.  Not only does it store the contact information for all of your friends, family and colleagues, but if you have a Facebook account, you can configure the People Hub to pull in updates for all of your friends as well. The reason why this feature is so great is that Facebook updates are not limited to just status messages and picture posts, but includes your friends’ actual contact information as well.  This means that if one of your friends update their phone number or address on Facebook, that information is synchronized to your phone immediately.  I no longer have to chase people down for their contact information when it changes. This feature was somewhat available in the past on iPhone using the Facebook application.  You could browse your friends in the F...