Monthly Archives: September 2017

It’s About Time for…#SQLSatOrlando!

Next week I am returning to Orlando not only to visit the mouse at his house, but also to speak at SQL Saturday Orlando! Last year was my first time there and I had a great time. This also happened after the event was pushed back to November 2016 because of Hurricane Matthew.

This year I will talking about deadlocking and blocking – something that is an issue for so many DBAs. Whether this issue is indexes or bad code…or you have been trying in use indexes to cover up bad code, blocks and deadlocks can happen in even the best environments under the right circumstances. If you are going to be at SQL Saturday Orlando come to my session where we will talk about detecting and preventing these arch enemies of the DBA!

AzureRM, PowerShell and Deleting Your VM the Easy Way

Before I worked on server migrations to Azure, I had only worked with Azure for a SQL Saturday session, and I was only using Azure as a host to the virtual machines (VMs) that I used to demonstrate PowerShell scripts running on a windows server that also accessed active directory. My only exposure to this technology was limited and focused on what I could do with the VM – not with how the VM was created or how I could use PowerShell to deploy a VM.

That professional experience with Azure finally came, and I got to work on PowerShell scripts that could be used to create VMs in Azure. With a script you have something that is consistent and less prone to human error, but even with that sometimes something is set up wrong that can’t be changed once the VM has been provisioned. Alternatively, maybe you are only using Azure for the testing of an application of project, you are done and the VM is no longer needed. You could simply decommission the VM, but if there is no need for the VM to still exist you probably want to delete it and all the parts associated with it.

The first one of these happened to me – there were three VMs where the configuration wasn’t right and it wasn’t something that could be changed from the portal. The VMs would have to be deleted and re-provisioned. I modified the creation script to have the right configuration for these VMs and got those created so work could continue. At this point I started to work on a script that would remove the VMs base on the name and resource group, including removal of all the parts that were tied to the VMs, such as the virtual network and the storage account.

Fast forward to today – I am working on my session for PASS Summit 2017. Instead of creating every part separately with the PowerShell cmdlets, PowerShell is used to apply a template that contains all the parameters and variables for a VM. If you need to make a change it is made to the JSON template, not to the PowerShell. Since I am testing, I am creating VMs and then I want to blow them away right after. I attempted to use the PowerShell script I had used before to remove VMs but that failed – enough time had passed that the cmdlets have been updated and what I ran before was no longer valid. I tried to revise the existing script and then ran across the OMG-I-can’t-believe-I-didn’t-do-this-before answer – just delete the resource group.

If you have contained all parts of the VM in the same resource group, and there is nothing else in the resource group other than the VM, cleanup is this simple. From what I recall about the server migration, there were multiple VMs associated with the resource group. If the resource group had only contained the VMs I wanted to blow away, I could have potentially run this for that clean-up operation. In this case, I was also removing disks from each of the VMs ahead of removing the VMs and had to run a script for that first. Looking back, if everything had been in one resource group, and had there been nothing else in there, I could have run this one line and been done.

For now, this solution works for me, but I know a more specific cleanup script may be more useful – one that will remove a VM and all of its parts based on the VM and the resource group. This will have to happen when I am done with my other testing, but in the meantime, this one line of code allows me to create and blow away VMs while using my personal Azure account…and not run up a ton of charges. Let me know if you find this useful or if you have any suggestions here – would love to have feedback!

PASS Board Elections – Voting Deadline is TODAY!

In case you have been under a rock, or buried in work, or otherwise occupied, the PASS Board elections are going on and end TODAY! There are some amazing candidates (thanks to the selection committee for all of their work in bringing us this fine list of folks) running for a handful of seats. Big question – have you voted yet?

When you vote you are exercising your voice and opinion on who from the SQL community best represents your views on the direction and future of the PASS organization. That said, the total number of people voting during each election cycle has steadily declined, with fewer that 1000 people voting last year.

With this being one of the easiest ways to be involved with PASS, you would think that these numbers would be increasing. If you have not voted yet, go check out the candidates. If you look at all of them, and just can’t decide who to vote for, give that Chris Hyde a second look – while it might seem like personal bias, I honestly feel he is well equipped for this position and will represent PASS and the SQL community with the same enthusiasm and vigor he has brought to the Albuquerque user group and all the other locations where he has spoken for user groups or SQL Saturday events (including the North Texas SQL Server User Group).

The voting deadline is 12 noon PST today (2pm CST). If you haven’t voted yet then put that query down and get to it!