-
Notifications
You must be signed in to change notification settings - Fork 1
/
CreateVM.azcli
87 lines (66 loc) · 2.01 KB
/
CreateVM.azcli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#login to Azure with Azure CLI
az login
#If you have more than one subscription, select subscription
az account set --subscription "Visual Studio Premium with MSDN"
#show your current subscription
az account show
#create resource group
az group create --name "nc-demo-rg" --location "westeurope"
#list resource groups
az group list -o table
#Create vnet
az network vnet create `
--resource-group "nc-demo-rg" `
--name "nc-demovnet-01" `
--address-prefix "10.33.0.0/16" `
--subnet-name "nc-demo-linux-subnet" `
--subnet-prefix "10.33.1.0/24"
#list vnets
az network vnet list --output table
#create public IP, public IP creation make take a while
az network public-ip create `
--resource-group "nc-demo-rg" `
--name "nc-demo-ubuntu01-pip-01"
#create nsg
az network nsg create `
--resource-group "nc-demo-rg" `
--name "nc-demo-linuxvm-nsg"
#list nsg
az network nsg list --output table
#create NIC for VM
az network nic create `
--resource-group "nc-demo-rg" `
--name "nc-demo-ubuntu-nic-01" `
--vnet-name "nc-demovnet-01" `
--subnet "nc-demo-linux-subnet" `
--network-security-group "nc-demo-linuxvm-nsg" `
--public-ip-address "nc-demo-ubuntu01-pip-01"
#list your nic
az network nic list --output table
#list azure locations
az account list-locations
#list vm images available on Azure
az vm image list --all
#list images with keyword
az vm image list -f Ubuntu
#create azure virtual machine
az vm create `
--resource-group "nc-demo-rg" `
--location "westeurope" `
--name "nc-demo-ubuntuvm-01" `
--nics "nc-demo-ubuntu-nic-01" `
--image "UbuntuLTS" `
--admin-username "ncvmadmin" `
--authentication-type "ssh" `
--ssh-key-value ~/.ssh/vmtest.pub
#get help creating azure vm
az vm create --help | more
#open port on azure vm
az vm open-port `
--resource-group "nc-demo-rg" `
--name "nc-demo-ubuntuvm-01" `
--port "22"
#get VM's IPs
az vm list-ip-addresses --name "nc-demo-ubuntuvm-01" --output table
#connect to azure linux vm
ssh -l ncvmadmin 40.114.227.74