Author : MD TAREQ HASSAN | Updated : 2020/11/09
Prerequisites
Create required resources beforehand to use those during VM creation. If not created beforehand, required resources will be created during VM creation.
Create Resource Group:
- Go to: https://portal.azure.com/#create/Microsoft.ResourceGroup (login to Azure portal first, then click the link)
- Fillup details (i.e. name ‘
demo-rg
’, select subscription etc.) - Create
Create required resources:
- Create Network Security Group
- Create VNet and subnet
- Create public IP address
- Create network interface (NIC)
- Associate public IP address to NIC
- Create storage account for VM diagnostics
Azure CLI installation
Download and install Azure CLI: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
Create Virtual Machine
- Either use Azure Cloud Shell or open CMD/Git Bash (locally) as Admin
- Azure Cloud Shell is preferred
- When using CMD/Git Bash (locally)
- type
az
and enter to check Azure CLI is installed properly (will show “Welcome to Azure CLI”) az login
(to login to Azure)
- type
- When using Cloud Shell => use Bash
- Execute commands line by line
- It will take some time to create resources
- Note: Azure VM images come with 128GB OS disk, to change size of OS disk, create custom image or find an image in the marketplace that uses smaller/larger OS disk size
Commands to create VM (Cloud Shell is preferred)
az account list --output tsv
az account set --subscription "Free Trial"
az group create --name IaaS-cli-rg --location japaneast
az vm create \
--resource-group IaaS-cli-rg \
--name IaaS-cli \
--location japaneast \
--vnet-name IaaS-cli-vnet \
--subnet IaaS-cli-subnet \
--nsg IaaS-cli-nsg \
--public-ip-address IaaS-cli-ip \
--image win2016datacenter \
--admin-username vmiaasdemo \
--admin-password VMiaasdemo.001
az vm open-port --port 80 --resource-group IaaS-cli-rg --name IaaS-cli