Chef and Azure:

I had not looked at the Chef docs for some time. They continue to be excellent. I was using them to see how deploying to Azure differed from a more on-premise VM. As far as I could see, the only difference was making sure that you had enabled the 80,5985 and 443 endpoints/ports in the Azure Portal. No amount of opening firewall ports on the provisioned VM will help if you have not done that.

I also suggest getting things working with the simplest possible test, and making network calls within a single server to start (I know what I mean hopefully you do, too late to explain more 🙂 )

I left comments here and here.

A very helpful post on WinRm and networking difficulties here.

Easiest way to get non-truncated history, btw (hm not so sure now):

h | select -Property CommandLine -unique > x.txt

Session edits.



Azure ARM: naïve single VM deployment

The aim is to get a real simple VM deployment working using a json template, and in doing that to sacrifice any guidelines on authoring best practice, so we can focus on getting familiar with the nuts and bolts of ARM deployment.

Download the template and PowerShell helper from here.

Assume you need Windows 10 Anniversary edition PowerShell versions for these client/deployment actions.

Open a PowerShell admin prompt in the download location, and run [.\deploy.ps1].

You will be prompted for your Azure login, a resource group and location (e.g. “uksouth”), and an admin password for the VM.

If all goes fine, then you will be able to rdp to the VM, and be able to start up SSMS.

Finally, a couple of pictures I took to focus the mind when trying to reduce the template to the bare minimum to get a working VM:

The next day… in fact I have started to remove the literals as I get more familiar. Again, I refer you the MS Azure docs above.

Docker on Windows: First Steps

Last night I wasted a few hours getting nowhere: various problems with the spec or config of machines I was trying Docker out against not matching up to assumptions in the msdn pages, blogs I was reading. However, remember this is firmly Windows. Sure, I dare say it is a breeze on Linux – I would not know.

Tonight in fact was a much better contrast. I have any number of SQLServer instances running on a single Windows Server 2016 Azure VM.

Let’s take it real slow… The first important step is to grab the right image in Azure for these purposes. One that works is this:

Always select the Resource Manager deployment model:

This is the size I usually pick: shut it down between use and it won’t be too expensive. I would not use 2 cores – I tried one a couple of days back, and it was REALLY slow. This speed is fine, for me:

That takes no more than 10 minutes to create.

Once it has been created, rdp onto it, and you will see that the Docker service is already running:

Then start a PowerShell admin session, and start playing. You will find there are already some images there:

docker images

Try these commands as well:

docker --help

docker --version

Across the Cloud of course the file transfers are blindingly fast – pulling down 10GB images is done in a matter of minutes, so this lot took me a max of minutes I think:

To get a new image, for example the latest SQL Server for Windows (as opposed these days to Linux, for example):

docker pull microsoft/mssql-server-windows

With that downloaded we can start the SQLServer instance:

docker run -d -p 1433:1433 -e sa_password=$dbpw -e ACCEPT_EULA=Y microsoft/mssql-server-windows

How to connect to the SQLServer instance

Run docker ps, and that gives you the Container Ids of all the running Docker… Containers:

docker ps

Stick that container id in a variable for later use, and run the inspect switch to get the ip address of the container..

docker inspect -format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $containerId

I could not see how to get the ip address directly into a variable, so again you have to do that by hand, e.g.


Now test your connectivity with sqlcmd before trying through ssms:

Now see my recent post on SSMS installation, and you see that what you created through the command line now appears in SSMS:

And finally for now shut down the container. In this shot, I try to stop a nonsense container, just to see how failure looks, and then stop the actual container. However I’d like better feedback than that (see the 2 docker stop lines). The second one has presumably silently failed. Trying to run sqlcmd against that ip address now fails… as you would want and expect. And although not shown, [docker ps] returns an empty set.



I don’t yet know how to run many containers against a single image, but this suggests to me it is possible.

Azure: removing Classic resources

The screenshots below record my attempts.. and I think eventual success in resolving this error, which happens in Classic Azure when you delete a VM… but the dependencies are orphaned because the deletion does not result in a cascade delete. (Later… in fact even though the Classic Portal says you have zero VMs… if you drill in to that, you will/may find images and/or disks that are associated with the storage account you are trying to delete).

The frustration people feel around this inability to delete the orphaned resource can be seen here.

The solution for me anyway used a combination of plugging away at the orphans in the newer Portal, in the classic Portal, and using the Azure Storage Explorer, available here.

PowerShell DSC: Creating IIS things on an Azure VM

I started out with an Azure VM (WS 2012 R2, SQLServer 2016). My aim was to deploy a web application so that the index.html was visible to the external world.

Additions I did not yet manage to achieve in DSC were a) adding endpoints for http and https in ARM, b) setting up self-signed certificates on the host VM. The http part right now is a Must.. the https might be considered optional but sensible.

Right now, this is the exciting output as an external user:

That already highlights one new thing: The UK now has its own Azure data centres… previously I noticed I would often get my browser language in Dutch.

Before I show you the whole of the DSC config, some key points were:

  • the use of the CimSession parameter to Start-DscConfiguration
  • as in a previous post, the need to delete pending configurations… assuming you are sure you don’t want them
  • There seems to be no “Let it be so” option for an existing virtual directory… so might have to replace that with some imperative code.


Code here.

Azure RM: get an Image from an ImageFamily and use it

$family = "SQL Server 2014 SP1 Enterprise on Windows Server 2012 R2"
$image=Get-AzureVMImage | where { $_.ImageFamily -eq $family } | sort PublishedDate -Descending | select -ExpandProperty ImageName -First 1


Returns for example:


And now say I want to a VM that is running SQL Server 2016. This is the (or at least a) question to ask (after some initial selects to test the water):

$image2016 = Get-AzureVMImage | where { $_.ImageFamily -eq “SQL Server 2016 RTM Enterprise on Windows Server 2012 R2”}

And that returns me:


Below is the history give or take I used to get there (btw, only just discovered that e.g. [ Set-Clipboard] does not truncate output whereas [clip]does. For example:

Get-History | select -Unique | Set-Clipboard

azure login
cd "E:\gitrepos\AllThingsAzure\AzureCLI"
$global:password = "whatsthis"
$family = "SQL Server 2014 SP1 Enterprise on Windows Server 2012 R2"
$image=Get-AzureVMImage | where { $_.ImageFamily -eq $family } | sort PublishedDate -Descending | select -ExpandProperty ImageName -First 1
Get-AzureVMImage | where $ $_.label -Like "*2016*"
Get-AzureVMImage | where { $_.label -Like "*2016*"}
Get-AzureVMImage | where { $_.label -Like "*sql*2016*"}
$image2016 = Get-AzureVMImage | where { $_.label -Like "*sql*2016*"}
$image2016 = Get-AzureVMImage | where { $_.label -Like "*sql*2016*"} | select {$_.Label}
function prompt{}
$image2016 = Get-AzureVMImage | where { $_.label -Like "*sql*2016*"} | select {$_.Label, $_.ImageName}
$image2016 | Format-Table
$image2016 | Format-List
$image2016 = Get-AzureVMImage | where { $_.label -Like "*sql*2016*Enterprise*R2"} | select {$_.Label, $_.ImageName}
$image2016 = Get-AzureVMImage | where { $_.label -Like "*sql*2016*Enterprise*R2"}
$image2016 = Get-AzureVMImage | where { $_.ImageFamily -Like "SQL Server 2016 RTM Enterprise on Windows Server 2012 R2"}
$image2016 = Get-AzureVMImage | where { $_.ImageFamily -eq "SQL Server 2016 RTM Enterprise on Windows Server 2012 R2"}
Get-History | clip
Get-Help clip
alias clip
Get-History | Set-Clipboard
$x = Get-History
$x = (Get-History | Set-Clipboard)
$x = Get-Clipboard
alias get-clipboard
alias get-clipboard gclip
New-Alias -Name gclip -Value Get-Clipboard
gclip | unique
$x = gclip | unique 
$x | Set-Clipboard
Get-History | select -Unique | Set-Clipboard

Azure: VM deallocation in PowerShell

… and implicit in that is Resource Manager, not Classic.

So interesting: if you execute this cmdlet against a running VM, then it becomes deallocated (as opposed to just Stopped):


That is, the default action is Deallocated.

If you now run the following, while keeping an eye on the Portal status, you see this:

That is, you can from a Deallocated state to a Stopped state. The key difference is the  [-StayProvisioned] switch.

This is useful for various PowerShell actions against Azure RM.

This is useful for the various sizes of VMs.