Late last week I decided to set up an Ubuntu box in Azure with the intention of installing SQL Server for Linux and VS Code on the same box. VS Code is necessary because there is no Management Studio shipped with SQL Server for Linux (command line only, see?) I know, I could use the command line, but I’m lazy and there’s an extension for VS Code called mssql, which funnily enough is exactly what you think it is. It also feels a bit bloody minded to ignore the whole VSCode and mssql extension and just use command line. And furthermore, I would like to get familiar with VS Code and SQL Server for Linux (there must be a shorthand for that by now?!)
So, I set about creating a Linux VM in Azure. And whilst the documentation is well written, it assumes some prior knowledge of using Linux, so I thought I’d link to the relevant “how-to” pages and fill in the blanks here, so that those of you who have never had to use Linux/PuTTY/vi will have an easier time of it.
Creating a VM: How Hard Can It Be?
I used Ubuntu exclusively for 18 months some 8 years ago, and used RedHat in university (over 10 years ago now), and also dabbled in it sometime before. I also worked a little bit on the Firefox OS that was released some years ago, which required building on Linux.  But it’s a bit of a dichotomy to use Linux as an OS when working with Microsoft technologies. And using Ubuntu when working with Microsoft products is not easy: I had to use MONO to develop and also the precursor to .NET Core, whose name escapes me right now. This was back in the day when Novell supported MONO, not Microsoft/Xamarin like today. And SQL Server? Forget about it. WINE had nothing of any use. And so after a while of making life extremely difficult for myself I gave up and used Windows 7, which frankly was a huge improvement on Vista.
Anyway, during this time I got acquainted with with apt get and package management and just the whole “how do I” when working with Linux. And Ubuntu moved on a lot from when I first installed it to where it is now. No longer do you have to trawl for drivers across the web. Which I think is one reason why Linux is a legitimate option for less tech-savvy people these days. And so being very familiar with creating VM’s in Azure I thought it would be the exact same process.
Not at all. Not by a long shot. Let me be clear in that whilst creating an Ubuntu VM is not hard, there’s considerably more steps than setting up a Windows VM.
Software You Will Need
Before you create an Ubuntu VM, do yourself a favour and download two things:
Enough Already, Let’s Get Going
So let’s start at the beginning, which I find the most useful place to start. Before we create the VM, we’re going to need a public/private SSH key. So open up PuTTYGen and generate a public/private key pair, leaving all the defaults as is. Save both public and private keys somewhere on your machine.
Now when you come to create your VM, select authentication type as Public SSH Key and enter the public SSH key in the text box.
The guide here is over-complicated, but useful: ignore the fraff about git bash.
This here is a good guide on creating your Linux VM. Follow only the “Create Virtual Machine” guide and ignore the rest of that page.
Now you’ve created your Linux VM, follow this guide on how to connect using PuTTY.
We’re on the home straight now, but we have to install xRDP and the Linux Desktop to connect to the machine and get a nice pretty UI. The steps are well documented, but there are two key things missing:
- One command mentions vi, which is a text editor. Vi will create a copy of the file and over write the original when you come to save. Vi also has two modes: command and insert. When you open a file you are in command mode, and to make changes you need to switch to insert mode. Type “i” to get you started. To leave insert mode press the ESC key. In command mode type “ZZ” to save and exit. This is a decent vi cheat sheet.
- When you have made all your changes, go back into the portal and create a password for your account. At this point, none exists (remember we set up using public SSH), so you cannot login. Make your password simple because your keyboard may have a different layout in the Ubuntu VM than what you have on your machine.
If all this results in a VM that doesn’t work, leave a comment.
 I was a big fan of that project, and was really sad when it got dropped. Just a shame that Mozilla don’t have a bottomless well of cash to throw at a project, because I felt that the idea behind it made sense and would’ve got off the ground were it not for the lack of funds.