Blog

29 07, 2020

IHostedService / BackgroundService IIS 8 issue

By |July 29th, 2020|Uncategorized|0 Comments

Recently I started using the IHostedService interface for some long running jobs in my API service. Of course there are many alternatives for setting up these scheduled jobs.

I followed the instructions at https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-3.1&tabs=visual-studio, tested locally and everything was running smoothly. My job was getting kicked off every 5 mins and I can see the output in my logs and debug output.

Problems started arising when I deployed my changes to my server (admittedly this API is running on a Windows 2012 R2 server, that is way past it’s life span). This is your typical “it works on my machine” issue.

say it works on my machine one more time - Samuel L Jackson | Meme ...


My background service would only launch once and never run again! Turns out IIS has a feature called Application Initialization that needs to be installed and then adjusted in two area:

Installation

Make sure to install Application Initialization 👇

Application Pool configuration

Open up IIS manager and right click on the application pool, and then choose Advanced settings, set the start mode to AlwaysRunning.

Site configuration

And finally, right click on the website and select Manage Application -> Advanced settings, make sure to set Preload Enabled to True

Wrapping up

Make sure to perform an IISReset after making the changes, if you have any questions please feel free to contact me.

6 12, 2019

Cyber Security Month Checkup

By |December 6th, 2019|Security|0 Comments

October is considered national cyber security month. It’s a good time to perform an online security checkup. Here are some tips for getting started:

Checklist

Action Item Reason
Create a unique password for each website/app that you use. Use a password manager such as LastPass or BitWarden If your password was compromised in a breach from one website, it can be used on other websites and services to attempt to login
Securing your e-mail should be top priority If someone has gained access to your email they can reset the passwords on all important websites that you use such as your banking
All Items Descriptions
19 09, 2018

Juniper VPN client keeps disconnecting

By |September 19th, 2018|Windows|0 Comments

Are you using Juniper VPN Network Connect client but having issues staying connected? Maybe you are getting disconnected every 5-10 mins? I had this issue and it took me sometime to figure out this issue. I decided to write this blog post for anyone else experiencing this issue.

The error is: “The Network Connect session terminated. Do you want to re-connect?” “nc.windows.app.23711”

There is a common reason for this, when you’re on the VPN software running on your computer is trying to re-write the routing table. There are some known software packages that cause this, disable or remove the following to see if it fixes your problem:

Software Package Solution
Bonjour Service (it runs as MDNSResponder.exe), this is located in C:\Program Files\Bonjour\mDNSResponder.exe. Remove it from Add/Remove Programs
HP Software  If you’re hooked up to an HP printer remotely. This software always attempts to re-write the routing table, remove anything related to HP networking, you can keep your HP drivers but the miscellaneous software should be removed.  The only software I have left is “HP Smart”

 

Hope this helps you out, if you’re still having issues, please reach out to me on twitter.

20 09, 2017

Searching Azure blob storage by file extension

By |September 20th, 2017|Azure|0 Comments

Here is a powershell script to search azure’s blob storage by file extension:

## Install Azure powershell, instructions @ https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps
## GDURGHA - 2017-09-20
$StorageAcctName = 'STORAGE ACCT NAME'
$StorageAcctKey = 'SECURE KEY HERE'
$ContainerName = 'myfiles'

$StorageContext = New-AzureStorageContext -StorageAccountName $StorageAcctName -StorageAccountKey $StorageAcctKey
$blobs = Get-AzureStorageBlob -Container $ContainerName -Context $StorageContext -MaxCount 10

# Search by Suffix using powershell
Write-Output $blobs | Where-Object {$_.Name -like "*.jpg"} | Select-Object {$_.Name}


Write-Output "-- Search finished --"
28 06, 2017

Best Domain Registrar 2017

By |June 28th, 2017|General Web Development|0 Comments

Working as a web developer you encounter domains that are registered on various domain registrars. Some clients are on Google Domains, GoDaddy, Namecheap, etc. In my opinion the best registrar to use in 2017 is NameCheap.

They are a well known domain registrar founded in 2000. They made a name for them early on by allowing you to register second class TLD (.club, .info), etc.  I personally use NameCheap on a daily basis, their DNS servers are fast, support is great, friendly user interface for managing your domain names. To me it’s important that a registrar provides top class security as well. I’ve turned on 2 Factor authentication (more commonly known as “2FA”) to keep my account secure. Whenever I login there is a prompt for me to enter in the 2FA code, this is sent via an SMS text message.

As I mentioned earlier the support services are great, you can contact them via live chat, support ticket or phone.

So how much does a .com domain cost? As of June 28th 2017 it costs $10.88 for a .com domain registration for one year (this also includes the free whois guard protection for 1 year).

Visit Namecheap

 

 

27 06, 2017

Visual Studio 2017 Preview 3 is out

By |June 27th, 2017|Coding|0 Comments

Preview 3 of Visual Studio 2017 is out, learn more about this update at: https://www.visualstudio.com/en-us/news/releasenotes/vs2017-preview-relnotes

6 06, 2017

Azure Automated Login via Service Principal

By |June 6th, 2017|Azure|0 Comments

In order for this setup to work you must be an administrator for your azure subscription:

  • Create a new application registration under Azure Active Directory.
  • Generate a key for the application.
  • Assign the application to your azure subscription(s).

The community has put together an excellent how to document which will walk you though the 3 steps mentioned above, this can be found at https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal

After performing all 3 steps, you should gather the following information:

  • Tenant ID/Directory ID: This is found under the Properties blade of the Azure Active Directory
  • Application ID:  This is found under the Properties blade of the Register application
  • Secure Key: This is found and generated under the Keys blade of the Register application

After you’ve gather all the information, plug it into this script and execute it. I’ve tested this on Azure Powershell version 4.0.2. To get your version of Azure Powershell execute the following:

Get-Module -ListAvailable -Name Azure -Refresh | Select Version

Here is the script to authenticate your service principal:

$key = '' # Found under Azure AD -> Application -> Keys
$applicationId = '' # Application ID - Self explanatory 
$tenantId = '' # This ID is found under Properties for the Azure Active Directory

# Create credentials
$pass = ConvertTo-SecureString $($key) -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $applicationId, $pass

# Authenticate
Login-AzureRmAccount -Credential $cred -ServicePrincipal -TenantId $tenantId

 

12 04, 2017

Windows Subsystem for Linux (WSL) – Copy ssh key from windows

By |April 12th, 2017|Windows|0 Comments

I found myself needing to connect to github via bash on windows. But I didn’t want to have to register a new public key with github. I decided to use my existing key from Windows. To do this I simply copy the file from windows to wsl.

Here is the command I used, you might find it useful:

 

cp /mnt/C/Users/gordon/.ssh/{id_rsa,id_rsa.pub} ~/.ssh/ && chmod 600 ~/.ssh/id_rsa

Make sure to use the full path to your ssh folder on windows.

30 03, 2017

Appending to your PATH variable

By |March 30th, 2017|Windows|0 Comments

If you ever need to append to your PATH variable on your system follow these instructions (Windows 10).

  • In your windows 10 search, type “system variables”, then click “Edit the system environment variables”
  • Click on “Environment Variables…”:
  • In the second list, search for a variable called “Path”:
  • Double click it and then click the “New” button and enter your new path entry and click Ok.
13 03, 2017

What’s new in Microsoft Visual Studio 2017

By |March 13th, 2017|Coding|0 Comments

Here is an excellent poster to find out what’s new in Visual Studio 2017:

 

(source: https://blogs.msdn.microsoft.com/visualstudio/2017/03/13/visual-studio-2017-poster)