Checking the Microsoft Container Registry for new SQL Server images

A while back I wrote a post on how to retrieve the SQL Server images in the Microsoft Container Registry (MCR).

It’s pretty simple to check the MCR but what about automating that check to alert if there are new images present? Let’s have a look at one method of doing just that with a powershell script using the BurntToast module, and a scheduled task.

Set the location of the gist that holds the existing images: –

$Gist = "https://gist.githubusercontent.com/dbafromthecold/db958d0d05866266bdc721bc8a3a27fb/raw"

N.B. – this is just a text file of all the existing images…I try and keep it up-to-date.

Set the registries to check for new images: –

$Registries = ("https://mcr.microsoft.com/v2/mssql/server/tags/list","https://mcr.microsoft.com/v2/mssql/rhel/server/tags/list")

Retrieve the images from the registries: –

foreach($Registry in $Registries){
    $PulledTags += ((Invoke-WebRequest $Registry -UseBasicParsing) | ConvertFrom-Json).tags

Retrieve the images from the gist (aka get the images that we know about): –

$ReferenceTags = (Invoke-WebRequest $Gist -UseBasicParsing).Content

Check each image in the MCR against the reference. Create a toast notification if there’s a new image: –

foreach($PulledTag in $PulledTags){
    $ExistingTag = $ReferenceTags -match $PulledTag
        $toastParams = @{
        Text = "A new image is available in the MCR! $PulledTag"
        Header = (New-BTHeader -Id 1 -Title "New SQL Server Container Image!")
    New-BurntToastNotification @toastParams

Cool! Ok, save that as a script and then create a scheduled task. There were a bunch of new images made available today so I got a few of these popping up…

Thanks for reading!