Build an Azure Virtual Machine using PowerShell6 min read


Recently I have been taking an online training course in preparation to take the Microsoft 70-532 certification exam.  My studies have made me realize how easy to use and fun playing in the cloud can be.  You can create a virtual machine, install some stuff, do some stuff and then delete it all in no time.  To do something similar on my laptop or an on-premise VM could take a few days.  While my company is not looking to move to Azure anytime soon, this is a skill I would like to put on my resume as well as a technology that I would like to start taking advantage of to make testing and automation easier.

When I run across cool demos or blogs I try to execute all the steps in order to learn, although it can be hard to get Azure credits to do this testing and investigating.  With my A Cloud Guru course I was able to create a free account with Azure and get $200 in credits that lasted a month.  Too bad I left a Redis device running that the class covered about half way thru that ate up 75% of those credits.  I also have an MSDN Visual Studio Professional Subscription through my work where I get $50 in credit a month.  My Azure time is limited by when the 17th of the month rolls around and my MSDN subscription resets.  Yay!!!

On Tuesday when I saw a tweet by the famous Bob Ward ( t ) advertising how the SQL Team had just released a self-paced tutorial to GitHub on how to install SQL Server on Linux and use Containers.  For me that was a trifecta of things I have been trying to fit in to my schedule and learn!!!  And the fact I just got my shiny new $50 Azure credits, it was go time.

I spent the bulk of my day Wednesday going through the Prelab steps outlined in the lab.  I was extremely impressed by this lab and how every step was correct and accurate down to the letter.  Then the more I thought about it, the steps are built around using an Azure Virtual Machine.  With this you get a common machine, framework and steps to build around.  You do not have to worry about the users’ local settings or scenario.  You are starting from the exact same point of reference every time.  So that was fun to connect via SSH to a Linux machine and install SQL Server 2017 and Docker from the command line.  While I know it was easy because someone was telling me what to type, it was still fun to see how the other side (Linux People) live.

Today I was in an adventurous mood to try something new.  I had been wanting to put together a PowerShell script that would deploy an Azure Virtual Machine.  I started down the path a couple time and got stuck so I lost interest.  I thought this was the perfect opportunity to get over the hurdle and combine the Prelab steps in this lab with doing those steps with PowerShell.  So below you will find my first go at building an Azure Virtual Machine using PowerShell to replace the manual steps in the Prelab process.  Not that there was anything wrong with those steps, I just want to try and use a tool that I have been working to learn and use on a day to day basis.  Wish me luck.

Deploy an Azure Virtual Machine running Linux
  1. Login to Azure

You will get this prompt to login to your Azure Account

2. Next you will want to set some configuration settings that will be needed to proceed

Here we Choose a Location for our resources


Now we choose the Offer


Finally we select the Sku


3. Now that we have our OS information needed for the Virtual Machine we can set our variables for Storage, Network and VM configurations settings that will be used to deploy the virtual machine.

4. Now with all our variables set with the configurations we want it is time to build the resources in Azure.

All the resources!!!

5. Now with all the supporting resources configured and showing in the Portal, we can run the final command that will do all the work of creating the Linux Virtual Machine and starting it in our Azure Portal.

Ta Da !!!


6. Now only six minutes later we have a new Azure Resource Group with all the resources for our new Linux Virtual Machine and I can prove it.




With the creation of the Virutal Machine, I can now work to complete the remainder of the demo lab and learn some Linux SQL and Container goodness!!!

Happy reading and I hope this helps you in your learning journey.  And as always any feedback or more efficient methods are welcome.


Leave a Reply

Your email address will not be published. Required fields are marked *