In my previous article, I described the process for creating a Virtual Machine in the Azure Portal. A colleague asked me to show them what the Azure CLI script might look like to create the same Virtual Machine, therefore I have quickly put the following together.
The following script is being utilised to configure a single VM with an additional Data Disk. The sizing of the VM is based around keeping costs to a minimum and the location is in a UK data centre.
As can be seen from running this script, I have not included an Admin Password parameter, mainly because I didn’t want to store a password in clear text, therefore when you run the CLI Script, you will be prompted to enter a password for your local Admin user account.
Also, I have called this VM ‘DC02’ and in effect this VM is now configured similarly to the VM we created through the portal.
One last point to note is that some of the resources I have referenced in this above script were already in place, i.e. the VNET/Subnet as well as the resource group etc. If you are completing this from scratch, then you would want to accommodate those resources as well.