Bernie Cook's Blog

Azure, C#, .NET, Architecture & Related Tech News


Leave a comment

Distributed Design: Applying the Command Pattern to Azure’s Web/Worker Roles

WorkerRoleOne place I regularly come across the use of the Command pattern is when working on Azure projects that employ worker roles to execute long running tasks initiated by a scheduled process or user action. The Command pattern lends itself to the distributed nature of these solutions with very little plumbing required when working in Azure.

The following post provides a sample application; CommandQueue which contains 3 examples of a web and worker role utilising the Command pattern. The web role is designed to provide a rapid responses to the user, offloading any lengthy operations to the worker role. The source code for the CommandQueue solution is available on GitHub so feel free to clone, compile and execute it while working through this post.

Continue reading


Leave a comment

Put ReSharper In Your Toolbox

ReSharperReSharper, the productivity tool which extends the Visual Studio IDE, is one development tool that I would certainly not want to live without. It’s one thing to have a strong skill set and another to compliment it with a great set of tools.

I’d seen ReSharper in action a number of times back in early 2012 but was never sold on it – I mean Visual Studio is an amazingly rich IDE, how could you ever hope to make it better? Well JetBrains (the minds behind ReSharper) have done just that. ReSharper is designed as an extension to Visual Studio providing an array of productivity benefits for both teams and individual developers.

I’m conscious that by now I’m starting to sound like a salesman, but do bear with me. What I’ve done is bundle together a few ReSharper features in this post. Hopefully it’s enough of a introduction to convince you of it’s necessary place in your toolbox. Continue reading


5 Comments

Repository Caching with Aspect Oriented Programming

Repository Caching with Aspect Oriented ProgrammingThis post provides a walkthrough of how to implement basic cache handling at the repository layer using Aspect Oriented Programming (AOP). I’ve chosen PostSharp’s AOP framework and built a relatively simple Domain-Driven Design (DDD) solution in .NET to illustrate how it all ties together.

I want delve into too much AOP detail up front other than to reiterate the usual AOP pitch – that it’s an incredibly useful programming paradigm which addresses cross-cutting coding concerns within application development. What does that mean in English? Once you’ve mastered the basic AOP terminology and implementation requirements you can use it to remove a lot of duplicate code that appears throughout your solution. If you’re not familiar with AOP then take a quick moment to watch one of PostSharp’s many introductory screencasts or browse through their documentation. Keep in mind that AOP isn’t OOP as you work your way through the following code, it complements OOP extremely well but doesn’t follow object-oriented principles. Continue reading


4 Comments

Distributed Caching in Azure – Cache Worker Role

In June 2012 version 1.7 of the Windows Azure Platform release was introduced and with it came the new cache worker role. This provided another distributed cache management option for Azure developers alongside the likes of AppFabric Caching, or Memcached, to name a few. There are a number of ways to utilise and configure cache worker roles and this post covers one of them, providing a step by step guide to creating a new cloud solution where a web and worker role (cache clients) share the same cache worker role (cache cluster). Continue reading


Leave a comment

Async in Windows Azure

At the time of writing (November 2012) Windows Azure C# development is only available with the .NET 3.5 and 4.0 Frameworks. So what happens when you want to implement some asynchronous server-based programming using the .NET 5.0 Async language features?

Microsoft’s answer is to install the Async Targeting Pack for Visual Studio 2012. The only prerequisite is that you’re developing with Visual Studio 2012. Continue reading


1 Comment

Reviewing the T-SQL Generated by LINQ to SQL Within SQL Server Profiler

SQL Server ProfilerIf you’re interested in taking a look at the final T-SQL generated by your LINQ to SQL queries then you have a few options available:
 

  1. Utilise LINQPad which converts your C# LINQ database queries into T-SQL
  2. Execute an SQL Server Profiler trace against the database your application is querying while its running
  3. Understand how ADO.NET translates the LINQ to SQL expression tree into T-SQL so you know what it’s going to output

I thought I’d blog about the second option above given it’s the more common approach I adopt when I’m working with LINQ to SQL. Continue reading


Leave a comment

Programmatic SSL AppFabric Cache Integration

I recently integrated Windows Azure’s AppFabric Cache into a solution I’ve been working on and went down the programmatic route as opposed to modifying my solution’s application configuration files.  I initially modified the web.config and app.config files for my web and worker roles respectively, just to see how easy it was to implement caching via that method, and I can say with confidence that Microsoft have made it a complete breeze.  However, my requirements meant that I had to programmatically create the DataCacheFactory and connect to the SSL endpoint for an added layer of security. Continue reading