How to create a virtual machine using the Azure CLI
Overview
With UKCloud for Microsoft Azure, you can leverage the power of Microsoft Azure to create virtual machines (VMs) for your on-premises applications. As UKCloud for Microsoft Azure is built on UKCloud's assured, UK-sovereign multi-cloud platform, those applications can work alongside other cloud platforms, such as Oracle, VMware and OpenStack, and benefit from native connectivity to non-cloud workloads in Crown Hosting and government community networks, including PSN, HSCN and RLI.
Prerequisites
Before you begin, ensure your Azure CLI environment is set up as detailed in Configure the Azure Stack Hub user's Azure CLI environment.
Creating a virtual machine
When you've created the resource group, you must choose which image template to use for your VM. To obtain a list of available images run the following command:
az vm image list --all --output table
You are retrieving all the images from server which could take more than a minute. To shorten the wait, provide '--publisher', '--offer' or '--sku'. Partial name search is supported.
Offer Publisher Sku Urn Version
------------------- ---------------------- ------------------------------------ ------------------------------------------------------------------------------------------- -----------------
UbuntuServer Canonical 14.04.5-LTS Canonical:UbuntuServer:14.04.5-LTS:14.04.20180818 14.04.20180818
UbuntuServer Canonical 16.04-LTS Canonical:UbuntuServer:16.04-LTS:16.04.20180831 16.04.20180831
UbuntuServer Canonical 18.04-LTS Canonical:UbuntuServer:18.04-LTS:18.04.20180911 18.04.20180911
CentOS OpenLogic 6.9 OpenLogic:CentOS:6.9:6.9.20180118 6.9.20180118
CentOS OpenLogic 6.10 OpenLogic:CentOS:6.10:6.10.20180803 6.10.20180803
CentOS OpenLogic 7.3 OpenLogic:CentOS:7.3:7.3.20170925 7.3.20170925
CentOS OpenLogic 7.5 OpenLogic:CentOS:7.5:7.5.20180815 7.5.20180815
RHEL RedHat 7.5 RedHat:RHEL:7.5:7.5.20182111 7.5.20182111
KaliServer KaliLinux 14.04.12-LTS KaliLinux:KaliServer:14.04.12-LTS:1.0.0 1.0.0
WindowsServer MicrosoftWindowsServer 2012-Datacenter MicrosoftWindowsServer:WindowsServer:2012-Datacenter:3.127.20180216 3.127.20180216
WindowsServer MicrosoftWindowsServer 2012-R2-Datacenter MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:4.127.20180912 4.127.20180912
WindowsServer MicrosoftWindowsServer 2016-Datacenter MicrosoftWindowsServer:WindowsServer:2016-Datacenter:2016.127.20180912 2016.127.20180912
WindowsServer MicrosoftWindowsServer 2016-Datacenter-with-Containers MicrosoftWindowsServer:WindowsServer:2016-Datacenter-with-Containers:2016.127.20180912 2016.127.20180912
WindowsServer MicrosoftWindowsServer 2016-Datacenter-Server-Core MicrosoftWindowsServer:WindowsServer:2016-Datacenter-Server-Core:2016.127.20180717 2016.127.20180717
WindowsServer MicrosoftWindowsServer 2019-Datacenter MicrosoftWindowsServer:WindowsServer:2019-Datacenter:2019.127.20190521 2019.127.20190521
WindowsServer MicrosoftWindowsServer 2019-Datacenter-with-Containers MicrosoftWindowsServer:WindowsServer:2019-Datacenter-with-Containers:2019.127.20190521 2019.127.20190521
WindowsServer MicrosoftWindowsServer 2019-Datacenter-Core MicrosoftWindowsServer:WindowsServer:2019-Datacenter-Core:2019.127.20190521 2019.127.20190521
WindowsServer MicrosoftWindowsServer 2019-Datacenter-Core-with-Containers MicrosoftWindowsServer:WindowsServer:2019-Datacenter-Core-with-Containers:2019.127.20190521 2019.127.20190521
SQL2014SP2-WS2012R2 MicrosoftSQLServer Web MicrosoftSQLServer:SQL2014SP2-WS2012R2:Web:12.20.0 12.20.0
SQL2016SP1-WS2016 MicrosoftSQLServer Web MicrosoftSQLServer:SQL2016SP1-WS2016:Web:13.1.900310 13.1.900310
SQL2016SP1-WS2016 MicrosoftSQLServer SQLDEV MicrosoftSQLServer:SQL2016SP1-WS2016:SQLDEV:13.1.900310 13.1.900310
SQL2016SP1-WS2016 MicrosoftSQLServer Standard MicrosoftSQLServer:SQL2016SP1-WS2016:Standard:13.1.900310 13.1.900310
SQL2016SP1-WS2016 MicrosoftSQLServer Enterprise MicrosoftSQLServer:SQL2016SP1-WS2016:Enterprise:13.1.900310 13.1.900310
SQL2016SP2-WS2016 MicrosoftSQLServer Web MicrosoftSQLServer:SQL2016SP2-WS2016:Web:13.1.900310 13.1.900310
SQL2016SP2-WS2016 MicrosoftSQLServer SQLDEV MicrosoftSQLServer:SQL2016SP2-WS2016:SQLDEV:13.1.900310 13.1.900310
SQL2016SP2-WS2016 MicrosoftSQLServer Express MicrosoftSQLServer:SQL2016SP2-WS2016:Express:13.1.900310 13.1.900310
SQL2016SP2-WS2016 MicrosoftSQLServer Standard MicrosoftSQLServer:SQL2016SP2-WS2016:Standard:13.1.900310 13.1.900310
SQL2016SP2-WS2016 MicrosoftSQLServer Enterprise MicrosoftSQLServer:SQL2016SP2-WS2016:Enterprise:13.1.900310 13.1.900310
SQL2017-WS2016 MicrosoftSQLServer Web MicrosoftSQLServer:SQL2017-WS2016:Web:14.0.1000320 14.0.1000320
SQL2017-WS2016 MicrosoftSQLServer SQLDEV MicrosoftSQLServer:SQL2017-WS2016:SQLDEV:14.0.1000204 14.0.1000204
SQL2017-WS2016 MicrosoftSQLServer Express MicrosoftSQLServer:SQL2017-WS2016:Express:14.0.1000320 14.0.1000320
SQL2017-WS2016 MicrosoftSQLServer Standard MicrosoftSQLServer:SQL2017-WS2016:Standard:14.0.1000320 14.0.1000320
SQL2017-WS2016 MicrosoftSQLServer Enterprise MicrosoftSQLServer:SQL2017-WS2016:Enterprise:14.0.1000320 14.0.1000320
SQL2017-SLES12SP2 MicrosoftSQLServer Web MicrosoftSQLServer:SQL2017-SLES12SP2:Web:14.0.1000320 14.0.1000320
SQL2017-SLES12SP2 MicrosoftSQLServer SQLDEV MicrosoftSQLServer:SQL2017-SLES12SP2:SQLDEV:14.0.1000320 14.0.1000320
SQL2017-SLES12SP2 MicrosoftSQLServer Express MicrosoftSQLServer:SQL2017-SLES12SP2:Express:14.0.1000320 14.0.1000320
SQL2017-SLES12SP2 MicrosoftSQLServer Standard MicrosoftSQLServer:SQL2017-SLES12SP2:Standard:14.0.1000320 14.0.1000320
SQL2017-SLES12SP2 MicrosoftSQLServer Enterprise MicrosoftSQLServer:SQL2017-SLES12SP2:Enterprise:14.0.1000320 14.0.1000320
SQL2017-Ubuntu1604 MicrosoftSQLServer Web MicrosoftSQLServer:SQL2017-Ubuntu1604:Web:14.0.1000320 14.0.1000320
Declare variables
Variable | Variable description | Input |
---|---|---|
--resource-group | Name of the resource group to be created | |
--location | The location to deploy the VM in | |
--name | Name of the virtual machine to be created | |
--image | The image template to deploy the virtual machine from | |
--admin-username | Username of the VM to be created | |
--admin-password | Password of the VM to be created |
Create a resource group
Before creating a VM, you must create a resource group to deploy the VM to. If you've already created the resource group, you can skip this step.
az group create --name '' --location ''
Create the virtual machine
After you've selected which image you want to use, run the following command. The 'az vm create' command will also create any resources required for the VM (for example, a network interface card, a network security group, and so on):
az vm create --resource-group '' --name '' --image '' --admin-username '' --admin-password '' --location ''
This will produce the following output:
- Running ...
{
"fqdns": "",
"id": "/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups//providers/Microsoft.Compute/virtualMachines/",
"location": "",
"macAddress": "111111111111",
"powerState": "VM running",
"privateIpAddress": "10.0.0.1",
"publicIpAddress": "11.111.111.11",
"resourceGroup": ""
}
Feedback
If you find a problem with this article, click Improve this Doc to make the change yourself or raise an issue in GitHub. If you have an idea for how we could improve any of our services, send an email to feedback@ukcloud.com.