-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmanage-az-linux-vm.sh
More file actions
60 lines (52 loc) · 1.6 KB
/
manage-az-linux-vm.sh
File metadata and controls
60 lines (52 loc) · 1.6 KB
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
#!/bin/bash
# create and manage Azure Linux VM
# https://docs.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-cli
az account set -s 'Visual Studio Enterprise'
az account show
echo 'Resource group list'
az group list -o table
rgName='linux-demos'
location='canadacentral'
az group create --name $rgName --location $location
az group list -o table
vmName='rkLinux'
az vm create \
--resource-group $rgName \
--location $location \
--name rkLinux \
--image UbuntuLTS \az
--admin-username azureuser \
--generate-ssh-keys
az vm open-port --port 80 --resource-group $rgName --name $vmName
ssh azureuser@52.138.9.27
# bash script in VM
#sudo apt-get -y update
#sudo apt-get -y install nginx
az vm list -o table
rgName=LINUX-DEMOS
vmName=rkLinux
az vm list-ip-addresses --resource-group myResourceGroupVM --name myVM --output table
az vm deallocate -g $rgName -n $vmName
az vm show -n $vmName -g $rgName
az vm start -g $rgName -n $vmName
# https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-manage-disks
az vm create \
--resource-group myResourceGroupDisk \
--name myVM \
--image UbuntuLTS \
--size Standard_DS2_v2 \
--generate-ssh-keys \
--data-disk-sizes-gb 128 128
az vm disk attach \
--resource-group myResourceGroupDisk \
--vm-name myVM \
--name myDataDisk \
--size-gb 128 \
--sku Premium_LRS \
--new
az vm show -n $vmName -g $rgName
az vm list-ip-addresses -n $vmName -g $rgName # --query "{publicIpAddresses}" -o tsv
VMPublicIP=52.228.39.12
ssh azureuser@$VMPublicIP
# bash in vm
(echo n; echo p; echo 1; echo ; echo ; echo w) | sudo fdisk /dev/sdc