Category: Tools

Azure Greg – YouTube Channel

Today I am announcing my official Azure Greg YouTube channel – this is where I will be recording demo videos and showing tips and tricks I pick up as I go – feel free to subscribe and get notified of the content as I release it.

I have a few videos up already which include the following: –

  • Rehearse your talk with PowerPoint Coach – Here I show off how to use a feature in PowerPoint called Research with coach, this helps you when rehearsing your talks. The AI feature listens to you as you present and gives you feedback during and a report at the end with tips on how to improve.
  • PowerToys – how to install and start using it for Windows.
  • Learn about Hugo – How to get up to speed once Hugo is installed, you can use this to create your first ever blog using Hugo.
  • How to install and customize the Windows Terminal – In this video, I take you through how to install and then customize the Windows Terminal.
  • Azure Resource Graph – In this video, I demo Azure Resource Graph and talk about an example JSON file you can use for any subscription which will give you an excellent inventory of your Azure resources.

If there is something you would really like to have me cover in a short video please do let me know. I will conduct twitter polls from time to time to ask what people would like to see.

Thank you to the current subscribers – there is a lot more content on the way.

Continuous Deployments for SQL Server – Part 4

Ok so we have seen in parts 1, 2, and 3 how to go about adding your database to source control, as well as comparing the schema and the data held within our SQL Server databases.

Its time to go about releasing changes made from one database to another (again think of you deploying changes from UAT to Production). There are several ways to go about releasing the changes, here are two of them:-

  • Script the schema and data changes as 2 separate scripts, which you can easily combine yourself.
  • Use Redgate SQL Packager and even create an .exe to run which will allow us to update the database.

Ok so let me demo how to go about using option two using Redgate SQL Packager which comes with the Redgate SQL Toolbelt.

Start up SQL Packager and you’ll see this start-up screen:-


I want to package an upgrade to a database so I have selected that option already, the next screen shows this:-

Above I have chosen my Database server and the database I want to use as the source and the target database (one we want to update).

Below shows the database objects I wish to package and apply on the target database.


Below shows the tables whose data I want to package and apply to the new database.


Below shows me the script that has been generated for me, first tab is the schema script, second tab is the data script and the third tab is for any warnings.


And the last screen gives us a choice to either package the change as a .exe, package it as a c# project, launch the script in SQL Query Analyser or Save the script for further inspection.


Choose option 1, run the exe and your database updates are complete, that’s all there is to it, any issues found the changes will be rolled back as they are transactional, leaving your database in tact.

Once complete, just run SQL Compare and SQL Data Compare and you can verify all is good – and viola, you’ve just updated production with schema and database changes, and you’ve been given a few different ways to do using RedGate SQL Toolbelt.

Continuous Deployments for SQL Server – Part 3

In part 2, I covered how to compare the schemas of two databases, in part 3 I’ll to cover how to compare the data held within these two databases, for that I am going to use SQL Data Compare.

Again we will use the same two databases, imagine your comparing UAT to Production and wish to compare the data within these two databases:-



(If the links are too small click on the image and then when the new window appears click on Original size at 1896 × 316)

The above image shows us that the t_depot database table has 4 rows which are in the Stock_DB_Deisgn table which aren’t within the STOCK_DB_DESIGN_ORIGINAL database. Again same as with SQL Compare, if we now click on Synchronization wizard we will see the following screen:-


And again as with SQL Compare, we get 2 options:-

  • Create a deployment script – use this option if you want to script the changes and review before running in the changes.
  • Synchronize Using SQL Data Compare – use this option if you want the tool to make the changes for you, you also get the option after its ran to automatically compare the 2 database data after the changes, to verify.

And that is it, easy, simple and straightforward, no manual steps involving creating scripts, no real chance for it to go wrong, plus once again you can source control the script if you really wanted to or share it with colleagues.

In part 4 I’ll cover how to deploy changes to your database whether its schema changes, data changes or both.

Continuous Deployments for SQL Server – Part 2

If you’re using SQL server at work and manually deploying changes to your database using manually crafted scripts then its time to stop, there is a better way to do this by automating it, remove the chance of human error, this will also ensure that before you deploy to production that your changes will work, guaranteed.

In this blog post, I’ll discuss comparing two SQL Server databases which you can use SQL compare to funnily enough compare them and see the differences between the two, very quickly and reliably, imagine you wanted to compare your local Development database with say your Staging database for example, or compare UAT to Production.

In this blog post I’ll go over the steps I went through and how to use Sql Compare to work out what’s changed between the two databases, schema wise, then in the second part I will show you how to use SQL Data Compare. to compare the data within both databases and in part 3 I will either create a script to update the database or run an exe which the tools will create for us to make both databases the exact same, both in schema and in data, so let’s get started.

I’ve made dome schema changes to STOCK_DB_DESIGN and I wish to see whats changed, so lets see how to compare the 2 databases using SQL Compare (I’m using version 11).

In the screen shot above I’ve chosen my databases to compare and the tool will now run and show me what the schema differences between the two. the screen shot below shows the results after the tool has been ran against both databases.


On the left pane we see the changed database, on the right the database without these changes, I clicked on the first row to show the changes in the t_depot table and in the split at the bottom it shows the differences per object – very quick and easy to see what’s changed.

Update time
In order to update the older database with the new changes, we simply click on Deployment Wizard at the top and we get the following screen with options:-


Here we get 2 options:-

  • Create a deployment script – use this option if you want to script the changes and review before running in the changes.
  • Deploy Using SQL Compare – use this option if you want the tool to make the changes for you, you also get the option after its ran to automatically compare the 2 database after the changes to verify.

And that is it, easy, simple and straightforward, no manual steps involving creating scripts, no real chance for it to go wrong, plus you can source control the script if you really wanted to or share it with colleagues.

In part 3 I’ll cover comparing the 2 databases when it comes to data, for this we will use SQL Data Compare.

Continuous Deployments for SQL Server – Part 1

Okay so your using a SQL Server database at work but you haven’t yet put the database into Source Control, here are some reasons as to why you want to do this:-

Source control your database
Trust me your going to want to do this if you haven’t already, it’s a good practice, it may save your skin some day, yes you can take backups which again is a good practice, here is an excellent article on why you want to do this:- Why put your database into source control?.

Okay now that we wish to put our database into source control – we still use Subversion at work so I downloaded Subversion and installed it locally as well as TortoiseSVN.
I have 2 databases called STOCK_DB_DESIGN and STOCK_DB_DESIGN_ORIGINAL within SQL Sever, the former had a few schema changes, imagine this is Development(STOCK_DB_DESIGN) and Staging(STOCK_DB_DESIGN_ORIGINAL).

I created a local repository within Subversion and downloaded RedGate’s Database Lifecycle Management Products.

This tool comes with SQL Compare and SQL Data compare as well as a host of other awesome SQL Server tools which you can find out about at the above link.

For this post I’ll be using Redgate’s SQL Source Control which adds a tab to SQL Server Management Studio and looks something like this:-


So lets go ahead and add a database to our source control using this tool, Select the option above, and then Next


I selected Subversion because at work we still use it, but you can use Git also and others, click Next


I then give it a repository URL, I already created a repository within Subversion for my database and added the URL like above, click Next and that’s it, our database is now linked to source control. Now to get the database scripts into Subversion we need to right click on the Database in question within SQL Server Management studio like so and select Commit Changes to source control:-


This will then add all of the database objects to SQL Source Control, once that’ completed, go into windows explorer and I use TortoiseSVN I can right click within my local SVN repository folder and then select Checkout or get latest version and this will result in the following folders being populated:-


And when I go into say the tables folder I’ll see the following:-


And that’s all there is to source controlling your SQL Server database. If I make change to an object say a table I’ll see whats changed locally in SQL Management Studio and I’ll know I still need to commit the change as seen below:-


In Part 2 I’ll show you how to compare schemas on both databases to work out what changes are required, and how to script them using the tool.

Continous Deployment – Free Code Coverage tools Part 1


If you’re looking for some free code coverage tools then the good news is look no further than OpenCover.

OpenCover can be run from the command line, which also means you can run it as part of your continuous deployment all for free, I like free.

If you’d like to get code coverage built into Visual Studio then look no further than the extension called OpenCover UI, this will give you code coverage results and show you which lines of code are covered by your tests, giving you no excuse to not test as much of your code where possible.

I created a very simple Calculator class library project and then add a class library for testing my calculator class, I’ll spare you showing the simple code, but here is a screen shot of me having ran the tests using OpenCover within Visual Studio.


The Above screen shows the lines in the class which are covered by tests in green, red are lines uncovered by any tests, below that is a break down showing the percentages of code covered and on the right is the test explorer showing the list of tests available.

If you want to run OpenCover within Visual Studio then add it via Extensions and Updates in the Tools menu of Visual Studio.

If you want to run OpenCover from the console then you can run it via the command prompt, doing it this way has much more flexibility as you can filter out test projects and generated code etc using the arguments you pass into the OpenCover executable.


Now once we have the code coverage within Visual Studio we can also get code coverage on our build server which is really what were after, due to OpenCover being an executable this is very easy to set up, you can find all the info you need to do this at the OpenCover Usage link.

In the second part of this blog post I’ll show how to generate a web page to show off these results which can be easily incorporated into your build server after each build, this will also show history of code coverage over time in case you want that feature too.

Squirrel – replace ClickOnce the easy way

Last week I was taking a look at Squirrel which states

Squirrel: It’s like ClickOnce but Works™

The goal of me looking at Squirrel was to find a decent replacement to ClickOnce, I read a tweet from @paulcbetts mentioning his work and how he had created Squirrel as a replacement to using ClickOnce.

Having spent some time implementing this and coming across one or two issues which I overcame, the good news is ClickOnce is hopefully no longer needed.

Squirrel works and does exactly what we require, our windows forms application’s can have a ‘check for updates’ option, which updates to the latest release, close the old application down after its updated, re-open from the original desktop or start menu shortcut and your done.

Steps to get Squirrel working

  1. Sourcecode is on GitHub.
  2. Create a simple Windows Forms Application
  3. Add the nuget package called nugetinstalllike so:-
  4. Add the following to the program.cs like so (line 19 is the only one I added) :-

    [sourcecode language=”csharp”]
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    using Squirrel;

    namespace WindowsFormsApplication1
    static class Program
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    static void Main()
    SquirrelAwareApp.HandleEvents(onAppUpdate: Form1.OnAppUpdate,
    onAppUninstall: Form1.OnAppUninstall,
    onInitialInstall: Form1.OnInitialInstall);

    Application.Run(new Form1());

  5. Add some content like a simple button or a menu with the choice to check for updates
  6. in the code behind we implement squirrel like so:-

    [sourcecode language=”csharp”]
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    using System.Configuration;
    using Squirrel;
    using System.Reflection;
    using System.IO;

    namespace WindowsFormsApplication1
    public partial class Form1 : Form
    private const ShortcutLocation DefaultLocations = ShortcutLocation.StartMenu
    | ShortcutLocation.Desktop;

    public Form1()

    private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
    // Check for Squirrel Updates
    var t = UpdateApp();

    public async Task UpdateApp()
    var updatePath = ConfigurationManager.AppSettings["UpdatePathFolder"];
    var packageId = ConfigurationManager.AppSettings["PackageID"];

    using (var mgr = new UpdateManager(updatePath, packageId, FrameworkVersion.Net45))
    var updates = await mgr.CheckForUpdate();
    if (updates.ReleasesToApply.Any())
    var lastVersion = updates.ReleasesToApply.OrderBy(x => x.Version).Last();
    await mgr.DownloadReleases(new[] { lastVersion });
    await mgr.ApplyReleases(updates);
    await mgr.UpdateApp();

    MessageBox.Show("The application has been updated – please close and restart.");
    MessageBox.Show("No Updates are available at this time.");

    public static void OnAppUpdate(Version version)
    // Could use this to do stuff here too.

    public static void OnInitialInstall(Version version)
    var exePath = Assembly.GetEntryAssembly().Location;
    string appName = Path.GetFileName(exePath);

    var updatePath = ConfigurationManager.AppSettings["UpdatePathFolder"];
    var packageId = ConfigurationManager.AppSettings["PackageID"];

    using (var mgr = new UpdateManager(updatePath, packageId, FrameworkVersion.Net45))

    // Create Desktop and Start Menu shortcuts
    mgr.CreateShortcutsForExecutable(appName, DefaultLocations, false);

    public static void OnAppUninstall(Version version)
    var exePath = Assembly.GetEntryAssembly().Location;
    string appName = Path.GetFileName(exePath);

    var updatePath = ConfigurationManager.AppSettings["UpdatePathFolder"];
    var packageId = ConfigurationManager.AppSettings["PackageID"];

    using (var mgr = new UpdateManager(updatePath, packageId, FrameworkVersion.Net45))
    // Remove Desktop and Start Menu shortcuts
    mgr.RemoveShortcutsForExecutable(appName, DefaultLocations);

  7. We now need to create a .nuspec file which we will use to package up our application, Squirrel needs to have every file within the lib\net45 folder.

    To create a .nuspec file I simply copied nuget.exe into the solution and then went to a command prompt and typed:- nuget spec, this creates a .nuspec file which we can then hand edit inside Visual Studio and looks like this:-
    [sourcecode language=”csharp”]
    <?xml version="1.0"?>
    <package >
    <authors>Gregor Suttie</authors>
    <title>WindowsFormsAppliation1 Squirrel Tester</title>
    <description>Testing out Squirrel</description>
    <copyright>Copyright 2015</copyright>
    <file src="bin\Debug\*.*" target="lib\net45\"></file>

  8. Next we need to pack the .nuspec file to generate the nuget package, so run the following:-
    Nuget pack WindowsFormsApplication1.nuspec
  9. From the package manager console inside Visual Studio we now need to run the following command:-

    squirrel –releasify C:\Squirrel\WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.

  10. In the folder above we should now have a folder called Releases, containing a setup.exe which we use to install the application.
  11. Run setup.exe and your app will install with shortcuts on the desktop and the start menu if you use the code above which has defined these as shortcut options.
  12. If you then run check for updates, the code will go off and check the folder you specify in the app.config like so:-

    [sourcecode language=”csharp”]
    <add key="UpdatePathFolder" value="c:\updatesForMyApp\"/>

  13. In order to update our app we also need the following appsetting which is the id of the Nuget package we created earlier, be careful not to have the id with a space or a dot (.) within the Nuget package Id.:-
    [sourcecode language=”csharp”]
    <add key="PackageID" value="WindowsFormsApplication1"/>
  14. Also add this one line to the assmblyinfo.cs:-
    [sourcecode language=”csharp”]
    [assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]

  15. Once you install the application, go back and make a change to the code, save it, update the .nuspec file version number from 1.0.0 to 1.0.1 and then redo steps 7 and 8 (with the path to the new WindowsFormsApplication1. file)
  16. Almost done, copy the content of the releases folder to our location where we store the updates (our app.config setting for UpdatePathFolder which was set to c:\updatesForMyApp\)
  17. Run the app and choose the menu option ‘Check for Updates’ and you’ll get the latest version.
  18. Also note of you add a Debugger.Launch() statement in the code you can debug the code and step through line by line.

To find out more about further options available and much more about Squirrel click here.

Code coverage results for your JavaScript

I wanted to find out if there were any tools that can display code coverage results for JavaScript code (without the need for Java on the server or having to use Node), I experimented with a few different frameworks, test runners and what not and have spent a couple of hours looking in to this, in the end I opted for the following:-

jasmine_logo At work we currently use Jasmine which is a behaviour-driven development framework for testing JavaScript code along with PhantomJS which we use to run the tests using a specrunner (there are several ways to do it but this works for now)

I have installed the Visual Studio Extension called Chutzpah which is a JavaScript Test Runner which gives you a few nice things such as integration with TeamCity and the ability to right-click and then select Run Tests similarly to unit testing your C# code with your favourite unit testing framework.


Ok so back to code coverage for our JavaScript code – Matthew the guy who created Chutzpah is working on integrating code coverage into the next release so in the mean time here is how you get it to work – enter one further library called Blanket.js – Blanket.js is used to give us the code coverage results and currently supports Qunit, Mocha and Jasmine. An adapter API exists for supporting other test runners.

At this point you might be thinking its a fair amount of work to get this going but I will simplify the steps required to get your JavaScript code outputting code coverage results.

  • Download Blanket.js and look for the file called blanket-jasmine.js, add this to your Scripts folder inside your web application. This file is blanket version that works with Jasmine.
  • Add the Nuget package jasmine.js jasminenuget
  • Add some JavaScript code as below for example this is code.js
  • [sourcecode language=”csharp”]
    var stringLib = {
    vowels: function (a) {
    count = 0;
    for (var i = 0; i &lt; a.length; i++) {
    if (&quot;aeiou&quot;.indexOf(a[i]) &gt; -1) {
    return count;
    var mathLib = {
    add5: function (a) {
    return a + 5;
    mult5: function (a) {
    return a * 5;

  • Add a JavaScript file with your Jasmine tests for the code above like so :-
    [sourcecode language=”csharp”]
    describe("general", function () {
    it("A basic test", function () {
    var value = "hello";

    describe("stringLib", function () {
    it("will get vowel count", function () {
    var count = stringLib.vowels("hello");

    describe("mathLib", function () {
    it("will add 5 to number", function () {
    var res = mathLib.add5(10);

    it("will multiply 5 to number", function () {
    var res = mathLib.mult5(10);

  • Ok so we have some JavaScript code and Jasmine tests for the code, lets add some required links to our Jasmine specrunner page so we can see the code coverage
    results output to the screen, edit the spec runner like so:-


    The above screen shot shows that we have added a reference to both our JavaScript code file and the file containing the Jasmine tests.

  • Now if we browse to the specrunner page for Jasmine we will see the results of the test – green for passed and red for failed (no code coverage results yet).


  • Now lets show the JavaScript code coverage results – which is as simple as adding in the line to reference Blanket for Jasmine:-


  • Refresh the specrunner page and you will now see your JavaScript code coverage results like so:-


    The screen shot above shows us 100% code coverage, so no lines of JavaScript are coloured red (not covered)

  • If I comment out one of the tests we can see the difference below:-
  • And there we have it code coverage results of your JavaScript, brief post but enough to get you started I hope, next time I will add this to TeamCity and see what that gives us.

Book Review: C# Smorgasbord by Filip Ekberg


Book Review: C# Smorgasbord by Filip Ekberg

About the Author:
Filip is a Software Engineer working with various techniques such as C#, WPF, WCF, ASP.NET MVC, ASP.NET and much more. Currently working at Star Republic in Sweden as a Software Engineer working with both newer and older technologies in a Windows environment, mainly focusing on ASP.NET MVC development.

During his years of Programming, Filip has managed to accomplish some of the following:
• Software Engineering Degree @ Blekinge Institute of Technology
• Managing the Software Development Company SmartIT eSolutions Sweden which focused mainly on developing software and web solutions.
• Working as an Amanuensis ( Teacher ) @ Blekinge Institute of Technology teaching Java, C++, Sql and Network-programming.

You can read more on his blog here.

I saw a tweet from @daniellangnet who said this book was fantastic and if your looking for something to read over the holidays then give this a go, I actually ordered the book without even reading anything about it, unusual but glad i did!

Chapter 1: Introduction to Parallel Extensions :- Learn the basics of paralleization, use basic Linq, and how to optimize code by introducing parallelization.
Chapter 2: Productivity and Quality with Unit Testing :- Understand why tests are import, create a test project and improve code quality.
Chapter 3: Is upgrading your code a productive step? :- How to find bugs faster, How to use Resharper to get a more manageable project and to get things done faster.
Chapter 4: Creating a challenge out of the trivial tasks :- Challenge yourself to create understandable and higher quality software.
Chapter 5: Asynchronous programming with async and await :- Identify where yo might need asynchronous processing, refactor a synchronous app into becoming more responsive.
Chapter 6: Dynamic program :- Create and extend a dynamic object by using the ExpandObject, also understand why introducing dynamic objects might cause problems long-term.
Chapter 7: Increase readability with anonymous types and methods :identify where you might have single purpose methods that you can replace with anonymous methods for increased readability and lucidity.
Chapter 8: Exploring Reflection :- User reflection to get information about types at runtime and understand more about properties and methods.
Chapter 9: Creating things at runtime :- Create your own method at runtime using Reflection, be able to read IL and understand portions of it.
Chapter 10: Introducing Roslyn :- Create a basic code analysis that suggest issues in your code, run code snippets on entire code files.
Chapter 11: Adapting to Inversion of Control :- Understand the basics of Inversion of Control, introduce a Dependency Injector into your application.
Chapter 12: Are you Mocking me? :- Create a mock of any interface and write tests that introduce

This book as you can see has something for everyone, i have thoroughly enjoyed reading it from cover to cover and will be reading a good few of the chapters again, it’s a very handy reference book and covers a number of topics that as a developer can help you explore, improve and be inspired – just as it says on the front cover.

I picked this book up on Amazon for £19 and its well worth it – recommended reading for 2013.

Choosing what Technologies/Frameworks to use

TechnologyBasics I have seen a few of my good friends on twitter discussing what technologies/frameworks they use and why they chose them.

I have also seen people saying why they should use this technology/framework over that technology all with really good arguments, as well as people asking which technologies/frameworks/libraries they should look at.

Note:- This is from the perspective of a company and not an individual developers stand point.

It comes down to a number of things and twitter isn’t really the best place to discuss this as it’s too small to get your point across hence this blog post.

I have worked in a few different places over time and there really is no single answer, some financial place I was in you were told which technology you were going to be using and it wasnt even up for debate, software architects who you would never even see had made the decisions already whether that be a good idea or not.

I would say choose the technology/framework that fits your current criteria as well as the technology/framework that matches your teams skill sets.

There has been a few posts about MVC or Nancy, in the end who cares what you choose? – if it gets the job done right?

Perhaps if you’re in a small team then its easier to choose say Nancy over MVC perhaps? – but if you walked into a team of 50-100 developers in a company im betting more people know MVC than know Nancy, that’s not to say MVC is better than Nancy, I havent even looked at Nancy, why not? – for a couple of reasons, why do I want to look at Nancy when MVC is used through our solutions, do I want to spend time learning another tool that does the same job? – no I don’t have time, don’t get me wrong I love to look at new ways of doing things, but I want to spend time learning something else like KnockoutJS or RavenDB and expand on my skill set, id rather do that port perfectly fine code bases which use a number of tools that run on MVC to Nancy and then have to check everything still works as expected including tests, build scripts, all sorts of other tools we use like chirpy and T4MVC.

People wonder why companies choose Microsoft products over other similar products and from experience it’s usually for either the option of MSDN licence support if required, or that more developers out there know and understand the product therefore there is more chance of help/finding a solution to a nasty bug – sort of strength in numbers it’s also easier for a manager to say to their boss look we will use SQL Server instead of CouchDB because of the products past history and thy can sleep safe in the knowledge its proven – I am not saying that other products are brand new and not to be trusted far from it, but I hope you get the point.

Recently we started using CoffeeScript for our latest project and to be honest I have never liked it, it was good for organising code in a better structured manner and I will leave it at that – we are looking to move to TypeScript and this isn’t because it’s a Microsoft product, its open source and I just think it’s so much nicer due to the tooling. It’s a better too for the job in my opinion and in summary there is no magic answer to what the best technology is, decide upon the variables in play and go from there is what I would suggest.

Not everyone will agree so feel free to add a comment.