How to add Open Source License to your GitHub repository

When you first create a new repository in GitHub, you get a very handy drop down of Open Source Licenses options to add. This is really useful and saves you trying to find the standard copy somewhere.

If you don’t choose one when you create the repo, then there is a sneaky way to get that drop down back and easily add a standard license file later.

  1. At the root of the repository, create a new file and type in ‘license’ or ‘license.txt’ into the filename field and voila! you will see the ‘Want to use a template?’ drop down on the right.2017-01-12_19-32-21
  2. Select the license you prefer from the drop-down and the text will be copied to the new empty file.
  3. Commit the file.

After you have added the license you like this you will see a short cut link to it in the <>Code tab.

For full details see

For help on choosing a license go to



Azure App Service – Force redirect from HTTP to HTTPS the easy way!

Once you have uploaded your SSL certificates to your Azure App Service and then configured the bindings (if you are using your own custom domains), there are two ways to force ALL requests to be redirected  from HTTP to HTTPS. The ‘Developer way‘ and the ‘Easy, no code way‘!

Developers way

If you have published your own code, then one way is to manually alter the web.config file with an IIS URL Rewrite and publish the changes.

If using ASP.NET MVC 3 or later then you can just decorate you controller class or methods with [RequireHttps] attribute too, but these days you really should be using HTTPS for everything.

To that end, the MVC 3 + way is to the whole site redirects to HTTPS (without needing attributes)  is to add

filters.Add(new RequireHttpsAttribute());

to the FilterConfig.RegisterGlobalFilters() method.

See for details on what you need to do to add the rewrite rule.

Easy, No code way

However, if you have just used one of the many templates to create an App Service, such as a WordPress site, then you probably don’t want to go messing with the web.config files yourself if you can avoid it.

So, the easiest, non techie way is to add the ‘Redirect HTTP to HTTPS’ Extension kindly created by Greg Hogan (

  1. In the Azure Portal, select ‘Extensions’ in the App Service blade
  2. Add a new Extension by clicking on the ‘+Add’ button at the top
  3. Select the ‘Redirect HTTP to HTTPS’ extension from the list given.
  4. Agree to the T&C’s
  5. Wait till it’s installed and then restart the service (which you can find in the ‘Overview’)

CAUTION: Don’t do this until you have tested that your site work using HTTPS first!

For more information see ). Alternatively watch out for my blog coming soon on using ‘Let’s Encrypt‘ for App Services.

Azure Portal, App Service SSL Certificates

Creating an Azure Virtual Network with VPN Gateway entirely with PowerShell not possible!

As I found the documentation for this somewhat lacking (especially for New-AzureRmVirtualNetworkGateway and New-AzureRmVirtualNetworkGatewayIpConfig), I thought I would try and see if it was possible to create and fully configure a Virtual Network and Gateway using PowerShell. I have posted my PowerShell script examples and efforst here.

NOTE: Several of these command return  a warning (shown below) which means things will be changing soon…again 😉 …and other just exception, so although you can setup a Virtual Network you can not create the Gateway!


I am using version 3.3.0 of the Azure cmdlets.

# Get Azure cmdlets version
Get-Module -ListAvailable -Name Azure -Refresh


  1. Setup variables, login and set current context
    # Setup Variables
    $location = "North Europe"
    $rgName = "MyResourceGroup"
    $strgAccount = "MyStorageAccount"
    $vnetName = "vnet-1"
    $gatewayPIPName = "gateway-2-pip"
    $clientAddressPool = ""
    $gatewayName = "mygateway1"
    # Setup PowerShell Environment
    Select-AzureRmSubscription -SubscriptionName "MySubscription"
    Set-AzureRmCurrentStorageAccount -ResourceGroupName $rgName -Name $strgAccount
    # get and check current context (ARM)
  2. Create the Virtual Network (include a subnet called ‘GatewaySubnet‘ specifically for the VPN Gateway. It appears this is required even if using the Portal to add a Gateway to a Virtual Network.)
    # Create the Virtual Network with 3 subnets)
    # Setup Subnets
    $gatewaySubnet = New-AzureRmVirtualNetworkSubnetConfig `
        -Name GatewaySubnet -AddressPrefix ""
    $frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig `
        -Name frontendSubnet -AddressPrefix ""
    $backendSubnet = New-AzureRmVirtualNetworkSubnetConfig `
        -Name backendSubnet -AddressPrefix ""
    # Create VNet
    $vnet = New-AzureRmVirtualNetwork -Name $vnetName `
        -ResourceGroupName $rgName -Location $location `
        -AddressPrefix "" `
        -Subnet $gatewaySubnet,$frontendSubnet,$backendSubnet
  3. Create a Public IP Address (PIP) to be used by the Gateway
    # Create a PIP
    $pip = New-AzureRmPublicIpAddress -AllocationMethod Dynamic `
        -ResourceGroupName $rgName -Location $location `
        -Name $gatewayPIPName
  4. Create the VNet Gateway (Attempt 1Although I can’t see any issues in the script below, unfortunately this is returning a 500 Internal Server Error. I have tried a number of variations!!)
    # Gateway config
    $vnetGatewayIPConf = New-AzureRmVirtualNetworkGatewayIpConfig -Name default `
        -PublicIpAddress $pip -Subnet $gatewaySubnet
    # Create VNet Gateway
    $vnetGateway = New-AzureRmVirtualNetworkGateway -Name "hmstraingateway1" 
        -ResourceGroupName $rgName `
        -Location $location `
        -IpConfigurations $vnetGatewayIPConf `
        -GatewayType Vpn `
        -VpnType RouteBased `
        -GatewaySku Basic `
        -VpnClientAddressPool $clientAddressPool


Attempt 2: I then thought I would see if it would be possible to complete the process using ARM Templates. When attempting to get an ARM Template for an existing Virtual Network Gateway we get the following errors.

Error details - Microsoft Azure 
  • The schema of resource type 'Microsoft.Network/virtualNetworkGateways' is 
    not available. Resources of this type will not be exported to the template. 
    (Code: ResourceTypeSchemaNotFound)
  • The schema of resource type 'Microsoft.Web/connections' is not available. 
    Resources of this type will not be exported to the template. 
    (Code: ResourceTypeSchemaNotFound)

This effectively indicates that the ARM capability of this type of resource is not yet all there in Azure. I seem to come across issue like this quite a lot.

Also with the ARM Virtual Network you can’t use the Get-AzureVNetConfig to download the configuration files either.

So in conclusion the only way to currently create a Gateway and complete the process, is to use the Azure Portal. Please comment below if you know of another way or have spotted an issue.


New-AzureRmVirtualNetworkGatewayIpConfig (

New-AzureRmVirtualNetworkGateway (


OneNote backups and clearing out old installation backups and cache.

If, like me, you are an avid user of OneNote then you may have some pretty large notebooks.

What many don’t know is that OneNote has a backup feature that can take up a lot of space.

To get access to the backups simply go to the ‘File’ > ‘Info’ and you will see the ‘Open Backups’ button on the far right.


You can review and change the backup settings from ‘File’ > ‘Options’ > ‘Save & Backup’.

The backups are extremely useful, however after an upgrade the backups made by the previous version are also left on your drives and now serve no purpose.

You can find the backups in the following location (unless you have chosen an alternate folder)


Use ‘Windows Key+r’ and copy this into the Run dialogue.


and you may see the more than one version like below. The backups are in the appropriately named ‘Backup‘ folder.

Delete Backups from previous OneNote versions


As shown above, you may have more than one version still on your drive.

It may be quite safe to delete the whole folder of the previous version ‘/15.0/’, but just to be safe I only deleted everything in the Backup and OneNoteOfflineCache_Files folders. These took up most of the space.


“Resource group not found” when using PowerShell with Azure (especially DSC)

I have been banging my head against a wall wondering why my Azure PowerShell DSC commands like

Publish-AzureRmVMDscConfiguration  ".\MyDSCConfig.ps1" 
            -ResourceGroupName "VM-Training" -StorageAccountName "hmsvmtraindsc"

was failing with a “Resource Group not found“, even though other commands worked with that Resource Group and my current context.

The answer is do NOT use the x64 build of PowerShell or the “Windows PowerShell ISE”!

Use the x86 versions for now!

I found this advice at the bottom of this page, and switching to the x86 ISE worked for me!

However, when I tried to reproduce the issue on the x64 ISE, the command worked fine??? However, by that time the Blob container had been created by the x86 version, so who know?

If I get time I will try to reproduce the error, otherwise please post a comment if the same thing happened to you.


Bulk update EXIF ‘Shot Taken Date’ on JPG photos using ‘ImageProcessing Console’.

If, like me, you have digital photo’s stretching back to the early days of digital cameras and even scans of film and slides, then you may have the same issue I had attaching the right date to the file. I have over 35,000 digital images, so developed a little command line tool to help called ‘Image Processing Console‘ (

Modern cloud photo facilities like Microsoft OneDrive Photos and Google Photos automatically organise images based on the dates. Which is great, unless you are missing the correct ‘Date Taken‘. These and other catalogs seem to use a preference order as so where they get this date from. I imagine it’s something like

  1. Date in the image metadata (EXIF, IPTC or XMP!). There are several dates often stored here. Exactly which is considered the definitive ‘Date Taken’ is not clear.
  2. If no metadata found , then the image files created date is used. This can and is often completely wrong if you scanned a photo or even did copying and editing.

In Windows you can easily view which of your images have valid ‘Date Taken‘.

  1. In Windows Explorer, change the view to ‘Details’, then right-click on the columns and add the ‘Date taken’ column.
  2. You should then see a listing like this, clearly showing if the image does not contain the right metadata.
  3. If you also turn on the Details pane (View ribbon), you can manually edit the ‘Date taken’, as well as other details.

Some images are too old to have metadata, other have lost their metadata after being edited and yet more are missing it as they were scanned direct from photographs, slides and film.

The created and modified dates can also easily become useless once they are copied from system to system and disk to disk.

Image Processing Console (open source project)

To resolve missing ‘Date Taken‘ metadata in images files, I have just created an open-source command line tool. This tool can be used to set a specific ‘Date Taken’ on one or more files, or you get ask it to infer a shot taken date based on other files close by.

You can get more details on GitHub at and download the latest release or source code here. It’s functionality is currently limited to JPG’s only.

Just unzip the ‘‘ and extract it to some folder. Then open command console at this location.


>ImageProcessingConsole --help
======= HMS Image Processing Console App =======
Image Processing Console
Copyright © Nicholas Rogoff 2016
MIT License
-------- Examples -------
- Update a single image
>ImageProcessingConsole -f "c:\myphotos\myphoto.jpg" -s 2003-11-17
- Update all images in a folder (inferred)
>ImageProcessingConsole -f "c:\myphotos\\"

  -f, --filepath             Required. The full path of the image file,
                             including the filename and extension (jpg only).
                             Or the folder to search and fix all 'Date Taken'
                             metadata in JPGs only. NOTE: You need to add an
                             extra '\' at the end when specifying a folder.

  -i, --includeSubfolders    Include subfolders. Use in combination with folder

  -s, --shottakendate        Set to this Shot Taken Date. Date must be formated
                             as follows 'yyyy-mm-dd hh:mm:ss'. If this date is
                             not specified then the 'Date Taken' (if exists) of
                             the nearest file in the same folder (ordered by
                             name) will be used.

  -o, --overwrite            Force overwrite of 'Date Taken' even if one
                             already exists for the file.

  --help                     Display this help screen.

Bulk update missing ‘Date Taken’

The most useful facility is when you have the odd image here and there that does not have a ‘Date Taken‘. This will probably be the images that you did some work on and saved a copy etc..

If you don’t supply a ‘shot taken date‘ (-s) then the app will try to infer a date based on image files in the same folder that do have dates.

The app will find the closest file by searching the files before and after when ordered alphabetically ascending.

When targeting specific files (without specifying a ‘shot taken date‘), we can see as shown below, that Faces-28.jpg will be given the 26/05/2006 02:21, but Faces-30.jpg will given 18/04/2004 07:49

>ImageProcessingConsole -f "D:\Gallery - Faces\Faces-28.jpg"
>ImageProcessingConsole -f "D:\Gallery - Faces\Faces-30.jpg"


When targeting a folder then the preceding date cascades down.

>ImageProcessingConsole -f "D:\Gallery - Faces\\"